Posts: 131
Joined: Thu Jun 21, 2012 1:58 pm

Thermometer, relay & raspberry

Thu Jul 04, 2019 9:23 am

In a pi zero w i have a DHT11 module and by making use of the adafruit's libray i read the temperature/humidity in a room. I use the following code to write in a csv file. So far so good.
I am looking to attach a relay and switch on/off the aircondition if the temperature is out of a predefined range. Let's say the temperature to be 15 and 25 degrees of Celcius.
The relay that i am looking is the following ... way&sr=8-8
I would appreciate any help available please.

Posts: 6403
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Thermometer, relay & raspberry

Thu Jul 04, 2019 9:33 am

The first thing to be aware of is that a lot of these relays designed to work with the arduino don't work with the pi, because of its 3.3v gpio.
So you may need to add an interface circuit between the gpio and the relay board. ... 8#p1225448

once you know if your relay is active high or active low then an interface circuit is simple to design.

If you post your existing code ( please use code button or code tags ), and say if you want the relay on or off at what temps we can help with some example code.

but basically you just need to compare the temperature to some references and act accordingly.

Code: Select all

temp =( get temperature from sensor )

if temp >= 25:
    turn on relay
if temp <= 15:
    turn off relay
We want information… information… information no help
The use of crystal balls & mind reading are not supported

Return to “Automation, sensing and robotics”