I’m currently attempting to build a auto greenhouse and so far have:
Raspberry Pi 3b
Seeed Studio Hat
Grove Temp & Humidity Sensor
Grove - 4-Channel SPDT Relay
So far I have managed to get the temp sensor working but know I need to figure out how to code it so the relay will turn on and off at certain temps, I’m no coder so any help is appreciated In finding out how to write the code for this project?
Hi @nodejunky, Can you share your existing code and share the details what you need to achieve?
If you only need to control a relay using temperature, you can use a simple conditional statement
example:
if(temp < 50)
{
// turn on relay
}
else {
// turn off relay
}
50 is the threshold temperature when the temperature is great than 50, code inside the if clause will run once and check the condition again(that’s depends on reset of the code) if temperature is lessthan 50 the relay remain off.
Hey @salman I dont really have any code as of yet I just have the temp reading out like in the example code for the DHT11 sensor, I’m a bit confused as to what I should be using to program this as the sensor is in Python & I cannot find out how to load the relay as theres only code for Arduino not the Pi for the relays.