theyosh / TerrariumPI

Home automated terrarium/aquarium or other enclosed environment with a Raspberry Pi
https://terrarium.theyosh.nl
GNU General Public License v3.0
403 stars 97 forks source link

Request: #247

Closed swekley closed 5 years ago

swekley commented 5 years ago

Hi,

I've ordered a co2 sensor to be able to regulate the co2 in a greenhouse, and an infrared temperature sensor to measure the temperature inside a plant. TerrariumPI doesn't support these yet, but I think it would be great if you could support these sensors as both have multiple purposes. I've added links to python codes/libraries of these sensors below.

co2: MH-Z19

IR temp: GY-906 MLX90614ESF

stuartabrown commented 5 years ago

The IR temp sensor sounds interesting. As I understand heating for reptiles it's useful to distinguish between air temperature (which is less easy for a reptile to benefit from) and substrate temperature (which a reptile can more easily generate energy from). I measure the substrate temp via an IR gun (this sort of thing https://www.ebay.co.uk/p/EXO-Terra-Infrared-Digital-Pocket-Thermometer/2254714221?iid=252315602703&chn=ps). Could the GY-906 MLX90614ESF replicate those measurements?

theyosh commented 5 years ago

Ah new sensors... @swekley there is only a new policy: New features will cost you some pictures ;) #210

The CO2 sensor is a bit strange, because you can't specify the address. But it is added to the branch issue/247. So if you do a git pull && git checkout issue/247 you should get the new code for the CO2 sensor. As I am unable to test it, I have you to ask for feedback when you add the sensor to your system.

In order to make sure it is all working, a rerun of the installer is needed. So after the git pull rerun the installer and reboot. When adding the sensor, just put any text in the address field. It does not matter

theyosh commented 5 years ago

The IR Temp sensor is a bit unhandy, as it does provide different temperature types... So I have to find a way to add multiple temperatures from the same sensor as multiple sensors in my software like some humidity sensors that also provide temperatures. Need some more thinking about it...

swekley commented 5 years ago

@stuartabrown The sensor does exactly the same as the IR gun. If the plant temperature differs more than ~2 degrees from the environment temperature it will slow down the photosynthesis of the plant. kinda the same with reptiles :)

@theyosh Wow I didn't expect it to be added this quick. I've ordered the sensors a week ago but they will be shipped somewhere this month because of chinese new year.. so I will test when I receive the sensors.

About the IR temp sensor, it does ambient temperature and object temperature. Maybe you could add object temperature as sensor type, or am I getting it wrong?

I wanted to post my setup already but then I decided to build it all in an aluminium box. I'll post some pictures on monday when I'm home

stuartabrown commented 5 years ago

@swekley, that IR sensor does look awesome. Do you know if there is a max distance from sensor to surface to be measured?

theyosh commented 5 years ago

@swekley I would just use the temperate other way around. Because ambient temperature can also be measured with multiple other temperature sensors in the same room.

Temperature at the object, that is the specialty of this sensor, and therefore, I think that should be the normal temperature. So I am thinking of creating an address that looks like: I2C_address,A where the A is for ambient.

Natrixz commented 5 years ago

I wouldn’t mind testing this either. Might actually suit my needs to measure the slab of stone where my temp sensor for the hotspot is on

theyosh commented 5 years ago

Added support for MLX90614 sensor.

use the normal I2C address for object temperature. Add a second sensor with the same address but than add ',a' for ambient temperature in stead of object temperature.

Both values will be handled as just temperatures.

This is all not tested jet. Just ordered some MLX90614 sensors to test with..

swekley commented 5 years ago

I have received the MLX90614 and confirm that the module itself is working really good. I haven't tried it on the Pi I use for TerrariumPi yet but I will do that this weekend.

theyosh commented 5 years ago

Nice, thanks for the update

swekley commented 5 years ago

Somehow my relays stopped working, and so did 1wire since i changed the 1wire pin to bcm 20. Anyway, when I add the mh-z19 to terrariumpi I get this

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 46, in webserver_headers return fn(*args, **kwargs) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 88, in wrapper return func(*a, **ka) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 282, in __update_api_call result['ok'] = self.__terrariumEngine.set_config(path,postdata,request.files) File "/home/pi/TerrariumPI/terrariumEngine.py", line 1159, in set_config update_ok = self.set_sensors_config(data) File "/home/pi/TerrariumPI/terrariumEngine.py", line 713, in set_sensors_config self.__load_sensors(data) File "/home/pi/TerrariumPI/terrariumEngine.py", line 186, in __load_sensors self.__unit_type) File "/home/pi/TerrariumPI/terrariumSensor.py", line 462, in __new__ raise terrariumSensorTypeException('Power switch of type \'{}\' is unknown. We cannot controll this sensor.'.format(hardware_type)) File "/home/pi/TerrariumPI/terrariumSensor.py", line 431, in __init__ super(terrariumPowerSwitchTypeException, self).__init__(message, *args) NameError: global name 'terrariumPowerSwitchTypeException' is not defined

same for the MLX90614

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/local/lib/python2.7/dist-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 46, in webserver_headers return fn(*args, **kwargs) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 88, in wrapper return func(*a, **ka) File "/home/pi/TerrariumPI/terrariumWebserver.py", line 282, in __update_api_call result['ok'] = self.__terrariumEngine.set_config(path,postdata,request.files) File "/home/pi/TerrariumPI/terrariumEngine.py", line 1159, in set_config update_ok = self.set_sensors_config(data) File "/home/pi/TerrariumPI/terrariumEngine.py", line 713, in set_sensors_config self.__load_sensors(data) File "/home/pi/TerrariumPI/terrariumEngine.py", line 186, in __load_sensors self.__unit_type) File "/home/pi/TerrariumPI/terrariumSensor.py", line 462, in __new__ raise terrariumSensorTypeException('Power switch of type \'{}\' is unknown. We cannot controll this sensor.'.format(hardware_type)) File "/home/pi/TerrariumPI/terrariumSensor.py", line 431, in __init__ super(terrariumPowerSwitchTypeException, self).__init__(message, *args) NameError: global name 'terrariumPowerSwitchTypeException' is not defined

theyosh commented 5 years ago

Hmm, you are still on branch issue/247? Do a git pull. This will add a lot of new code and requires a rerun of the installer. After that reboot the Pi and try adding only the MH_Z19 sensor. Not the other one.

Lets just test one sensor at a time.

swekley commented 5 years ago

I've just ran a git pull and reinstalled, nothing changed. Both sensors still give the same error when i try to add them separately

theyosh commented 5 years ago

Strange... But are you sure that you are on the branch issue/247? Because I cannot reproduce those errors. I can just add them. I do get errors that the sensors are not working due to not having one.

But I am able to add them through the webinterface....

swekley commented 5 years ago

I tried git pull && git checkout issue/247 but it gave some error about issue/247 that it couldn't find it i think.. I'm not at the place where I have terrariumpi running so I'm now installing terrariumpi on a new pi 3b+ and might just use that pi in my environment next week if it'll work now. Do I still have to run git checkout issue/247 on a new installation?

stuartabrown commented 5 years ago

@swekley it depends (I think) on whether @theyosh has merged that issue branch into master. If not you will need to switch to that branch once installed 'git checkout issue/247'

Edit, yes I think you will need to, https://github.com/theyosh/TerrariumPI/tree/issue/247?files=1 (view on desktop) shows that the issue branch is ahead of master

swekley commented 5 years ago

After modifying terrariumSensor.py I confirm both sensors are working. the only thing that needs to be changed is that it'll run the co2 command in python 3 when using 3.

theyosh commented 5 years ago

Cool! I updated the code to fix that issue. As well, I saw that the sensor can also readout temperature. So that is added also. Could you test that also? Jut add the mh_z19 sensor a second time with temperature option.

swekley commented 5 years ago

Temperature works fine. I didn't even know it had that feature 😋 image

theyosh commented 5 years ago

Cool. I had the feeling it would work, So this code is also in the master branch. So now you can switch back to the master branch and update to the latest master.

git checkout master

git pull

restart

It should trigger again an installer run due to again new modules :) But then it should run with your new sensors... Thanks for testing!

theyosh commented 5 years ago

Ok, I close this now, as the code is in the master branch and working. Thanks again for testing!