Thank you for your response. I am not sure where I would edit the code once I have run the sense-hat plugin commands in the terminal. I am familiar with the sense-hat python code and can run it on the sense-hat’s 8x8 LED, but not sure how to then have Cayenne report onto 8 x 8 LED screen.
I checked out the Git hub example scripts and they are great! Do I just run them from the Rasberry Pi in Python 3 or Thonny?
Sorry, I am not more knowledgeable.
which method do you want to use? 1 or 2 ?
there are two things you need to do:
- add images in the folder
/etc/myDevices/plugins/cayenne-plugin-sensehat/data
- edit the code in
sudo nanno /etc/myDevices/plugins/cayenne-plugin-sensehat/sensehat/__init__.py
-
need to initialize the image file path.
def init(self, use_emulator=False):
“”“Initializes Sense HAT device.
Arguments:
use_emulator: True if the Sense HAT Emulator should be used. This requires the Emulator to be installed and running on the desktop.
“””
self.use_emulator = use_emulator
self.sense_hat = None
self.digital_value = 0
self.analog_value = 0.0
self.image_file = os.path.join(‘/etc/myDevices/plugins/cayenne-plugin-sensehat/data/image.png’)
self.image_file_temp = os.path.join(‘/etc/myDevices/plugins/cayenne-plugin-sensehat/data/image_temp.png’)
self.call_sense_hat_function(‘clear’)
-
need to edit the sensor function:
def get_temperature(self):
“”“Gets the temperature as a tuple with type and unit.”“”
temp = self.call_sense_hat_function(‘get_temperature’)
if ( temp > 50):
self.call_sense_hat_function(‘load_image’, self.image_file_temp)
else:
self.call_sense_hat_function(‘clear’)
return (temp, ‘temp’, ‘c’)
similarly, you have to do for other function.
i have not tested the code, so might give you some error
shramik_salgaonkar thank you so much for your detailed information and help. I will give it a shot later today and let you know how it went! Thanks again!
1 Like
Any updates on adding native support by the agent for Sense Hat?
Hi everyone, I did the plug-in, works, except I do not see any of the sensor data? Here’s what it looks like?
can you share the logs after restarting the agent,
sudo service myDevices restart
tail -f /var/log/myDevices/cayenne.log
Hi
Thank you, below is the log:
2020-07-03 06:35:11 - myDevices - INFO - Sensors info: []
2020-07-03 06:35:11 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:11 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:11 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:11 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:11 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:11 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:11 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:11 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:11 - myDevices - INFO - Send changed data: [{'sys:cpu;load': 16.5}, {'sys:cpu;temp': 48.85}, {'sys:ram;usage': 302604288}, {'sys:storage:/;usage': 3119116288}, {'sys:net;ip': '192.168.166.94'}, {'dev:sensehat:4': 0}, {'dev:sensehat:5': 0.0}] + sys:gpio
2020-07-03 06:35:26 - myDevices - ERROR - Failed to get sensor data: Temperature GGMMo5GMCJpwLKG
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/sensors/sensors.py", line 322, in SensorsInfo
value = self.CallDeviceFunction(func)
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/sensors/sensors.py", line 264, in CallDeviceFunction
result = func(*args)
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/devices/sensor/__init__.py", line 116, in getCelsius
return self.__getCelsius__()
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/devices/sensor/tmpXXX.py", line 48, in __getCelsius__
d = self.readBytes(2)
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/devices/bus.py", line 157, in readBytes
return bytearray(self.readDevice(size))
File "/usr/local/lib/python3.7/dist-packages/myDevices-2.0.4-py3.7.egg/myDevices/devices/bus.py", line 153, in readDevice
return os.read(self.fd, size)
OSError: [Errno 121] Remote I/O error
2020-07-03 06:35:26 - myDevices - INFO - Sensors info: []
2020-07-03 06:35:26 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:26 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:26 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:26 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:26 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:26 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:26 - myDevices - INFO - Sense HAT service connection refused
2020-07-03 06:35:26 - myDevices - ERROR - [Errno 111] Connection refused
2020-07-03 06:35:26 - myDevices - INFO - Send changed data: [{'sys:cpu;load': 0.0}, {'sys:cpu;temp': 45.084}, {'sys:ram;usage': 302784512}]
Yep, I am. The Hat works otherwise, I can pull temperatures with example py code, all sensors work. I can even get it to work to Cayenne using a separate py script that pulls and sensors and dumps them into a “custom device” which I have created. What does not work is the GitHub “official” plug-in for Sense Hat.
Here’s my custom device which I had to create with a py script - works like a charm. I am bringing this issue up as a possible defect in the GitHub - myDevicesIoT/cayenne-plugin-sensehat: A Sense HAT plugin for Cayenne
okay. thank for pointing out. we will look into it.
1 Like
@bubba198 can you run groups cayenne
and share what it returns.
1 Like
@shramik_salgaonkar here it is:
pi@raspberrypi:~ $ groups cayenne
cayenne : cayenne spi i2c gpio
pi@raspberrypi:~ $
can you check if /usr/bin/python3 -m sensehat.startservice
is running and if so under what user
@shramik_salgaonkar strange output, I have most definitively NOT setup an emulator, I am using real bare metal Sense Hat. Could the default install of the plugin assumes emu?
pi@raspberrypi:~ $ /usr/bin/python3 -m sensehat.startservice
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/dist-packages/sensehat-0.1.0-py3.7.egg/sensehat/startservice.py", line 9, in <module>
File "/usr/local/lib/python3.7/dist-packages/sensehat-0.1.0-py3.7.egg/sensehat/manager.py", line 35, in start_server
File "/usr/local/lib/python3.7/dist-packages/sensehat-0.1.0-py3.7.egg/sensehat/manager.py", line 24, in use_emulator
ModuleNotFoundError: No module named 'sense_emu'
what is the output of dpkg-query -s sense-hat
@shramik_salgaonkar Thanks for the quick reply, below:
pi@raspberrypi:~ $ dpkg-query -s sense-hat
Package: sense-hat
Status: install ok installed
Priority: optional
Section: misc
Installed-Size: 111
Maintainer: Serge Schneider <serge@raspberrypi.org>
Architecture: all
Version: 1.2
Depends: raspberrypi-bootloader (>= 1.20150820-1), librtimulib-dev, python-sense-hat, python3-sense-hat
Recommends: librtimulib-utils
Conffiles:
/etc/RTIMULib.ini c8bc7ab2e1ca339eb6b463563bacbfd3
Description: Sense HAT configuration, libraries and examples
Configures the Sense HAT, installs RTIMULib and Astro Pi libraries, calibration
data and example code.
pi@raspberrypi:~ $
check if you have /usr/lib/python3/dist-packages/sense_emu
or /usr/lib/python3/dist-packages/sense_hat
directories