aaronwmorris / indi-allsky

Software to manage a Linux-based All Sky Camera.
GNU General Public License v3.0
224 stars 37 forks source link

Enhancement: Add support for Si7021 and SHT40 temperature/humidity sensors #1275

Closed Vertikar closed 4 months ago

Vertikar commented 4 months ago

Hey Aaron, I've already got a few of these floating around and would be handy to be able to use these:

https://www.adafruit.com/product/4885

https://www.adafruit.com/product/3251

I think there's sample code for both of them on the Adafruit website.

aaronwmorris commented 4 months ago

This should not be a big deal. I can just add the code without having the devices if you want to test them.

aaronwmorris commented 4 months ago

As of #1278 these two sensors should be supported. I have not tested the code, I just used the example code and implemented from that. Barring typos, this is pretty straightforward.

Vertikar commented 4 months ago

As of #1278 these two sensors should be supported. I have not tested the code, I just used the example code and implemented from that. Barring typos, this is pretty straightforward.

Awesome thanks, I'll give them a test over the next few days

Vertikar commented 4 months ago

Have updated and can see it trying to grab the temp and humidity, but it seems to have an issue with the humidity:

May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception: Traceback (most recent call last):
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/sensor.py", line 75, in run
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     self.saferun()
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/sensor.py", line 123, in saferun
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     temp_data = sensor.update()
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/devices/sensors/tempSensorSht4x.py", line 16, in update
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     rel_h = float(self.sht4x.humidity)
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception: AttributeError: 'SHT4x' object has no attribute 'humidity'
May 29 10:48:34 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:
May 29 10:48:34 allsky [INFO] MainProcess-22739/MainThread allsky._startSensorWorker() [491]: Starting Sensor-225 worker
May 29 10:48:34 allsky [WARNING] MainProcess-22739/Sensor-225 tempSensorSht4x.__init__() [69]: Initializing SHT4x I2C temperature device @ 0x44
May 29 10:48:34 allsky [INFO] MainProcess-22739/MainThread allsky._queueManualTasks() [1176]: Checking for manually submitted tasks
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread capture.saferun() [204]: Camera last ready: 14.2s
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread capture.saferun() [205]: Exposure state: OK
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread capture.detectNight() [1209]: Sun altitude: 27:03:06.8
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread capture.detectMoonMode() [1227]: Moon altitude: 15:21:46.3, phase 68.8%
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread indi.getCcdTemperature() [889]: Camera temperature: 25.0
May 29 10:48:39 allsky [INFO] Capture-2-22789/MainThread indi.getTelescopeRaDec() [874]: Telescope Coord: RA 2.98, Dec -37.92
May 29 10:48:42 allsky [ERROR] MainProcess-22739/Upload-2 uploader.processUpload() [495]: Tranfer failure: Sync error: 500
May 29 10:48:42 allsky [WARNING] MainProcess-22739/Upload-2 miscDb.addNotification() [858]: Not adding existing notification
May 29 10:48:42 allsky [INFO] MainProcess-22739/Upload-2 generic.connect() [52]: Connecting to mqtt (1883) as  with paho_mqtt
May 29 10:48:42 allsky [INFO] MainProcess-22739/Upload-2 generic.put() [66]: Uploading /var/www/html/allsky/images/ccd_b73718bf-cf33-42d9-8e99-3c06019cca2c/exposures/20240529/day/29_10/ccd3_20240529_104825.png
May 29 10:48:43 allsky [INFO] MainProcess-22739/Upload-2 paho_mqtt.put() [131]: File transferred in 0.5412 s (11853.82 kB/s)
May 29 10:48:43 allsky [INFO] MainProcess-22739/Upload-2 uploader.processUpload() [526]: Upload transaction completed in 0.5652 s
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception: Traceback (most recent call last):
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/sensor.py", line 75, in run
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     self.saferun()
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/sensor.py", line 123, in saferun
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     temp_data = sensor.update()
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:   File "/opt/indi-allsky/indi_allsky/devices/sensors/tempSensorSht4x.py", line 16, in update
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:     rel_h = float(self.sht4x.humidity)
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception: AttributeError: 'SHT4x' object has no attribute 'humidity'
May 29 10:48:47 allsky [ERROR] MainProcess-22739/MainThread allsky._startSensorWorker() [484]: Sensor worker exception:
May 29 10:48:47 allsky [INFO] MainProcess-22739/MainThread allsky._startSensorWorker() [491]: Starting Sensor-226 worker
May 29 10:48:47 allsky [WARNING] MainProcess-22739/Sensor-226 tempSensorSht4x.__init__() [69]: Initializing SHT4x I2C temperature device @ 0x44
aaronwmorris commented 4 months ago

I had the wrong property name. Fixed in #1282

aaronwmorris commented 4 months ago

I forgot to hit the Merge button. It is merged now.

Vertikar commented 4 months ago

Cool that's sorted now, I'll dig out the Si sensor and test that soon too

May 29 13:32:37 allsky [INFO] MainProcess-27725/Sensor-1 sensor.saferun() [117]: Dew Point: 8.3, Frost Point: 5.1
May 29 13:32:37 allsky [INFO] MainProcess-27725/Sensor-1 tempSensorSht4x.update() [21]: SHT4x - temp: 23.5c, humidity: 38.1%

Where is that temp value exposed to be used in indi-allsky anyway?

aaronwmorris commented 4 months ago

This is a document I still need to write, but the temperature values are available for the Image Labels/Overlay. The data is stored in the available slots according to the config for the sensor. The dew points or temperature may be used for the dew heater controls, as well.

https://github.com/aaronwmorris/indi-allsky/wiki/Image-Labels#user-sensors

I will assume you have Sensor Slot 10 selected, this means the temperature will be in slot 10 and humidity will be in slot 11. The dew and frost points will stored in slot 2 and 3 (slots lower than 10 are system managed).

Vertikar commented 4 months ago

Tested the Si7021 today and its working fine. Will close this off now