Mariuszcz86
Posts: 2
Joined: Tue Feb 25, 2020 5:04 am

Can a 12v relay be run using inputs from a different sensor.

Tue Feb 25, 2020 5:17 am

Hello, I am completely new to all of this so forgive me if my terminology is incorrect. I wanted to know if it's possible to activate a 12v relay using the input from a sensor. Specifically, I would like to turn on a relay (for 3 seconds every ten minutes) that activates a ceramic diffuser when the reading from a humidity sensor is below 68%. If the humidity is above 70% I do not want the diffuser being activated. Is this a complicated thing to do as far as coding it(is that the proper term?)
This is a set up I would like to build for an inwall cigar humidor that's automatically controlled.

The diffuser I'm looking at is in the following link.

https://www.amazon.com/YEMIUGO-Ultrason ... 0486842066


The relay is a simple one like this:

https://www.amazon.com/HiLetgo-Channel- ... 726&sr=8-3

And the humidity sensor I saw is:

https://www.amazon.com/Digital-Temperat ... umi&sr=8-7

njh
Posts: 73
Joined: Wed Aug 09, 2017 2:07 pm

Re: Can a 12v relay be run using inputs from a different sensor.

Tue Feb 25, 2020 11:24 am

Yes, it can all be done! As always, try to find out as much as possible about the components and modules you will be using.

Relay modules vary. Many 12V ones will work from 5V, but it would be better to use a 5V relay. Important: Make sure the relay can be controlled from a 3.3V signal without danger of pulling the data pin above 3.3V, which is a well-known way to destroy a Raspberry Pi.

Try to choose or configure the relay module to act as "active high / common ground". Then connect it to 5V supply and GND, and measure the voltage on the data wire (don't connect it to a GPIO yet). Stop if the data wire is above 3.3V. Test the relay by touching the input alternately to GND or 3.3V, and listen for relay operation. If it works, then you can connect it to any "normal" GPIO pin on the Raspberry Pi. If that doesn't work, you may need a transistor circuit to drive it...

The sensor appears to be a "1-wire" device. Power it from 3.3V and GND and connect its data output to GPIO4 (header pin 7).

Yes it will require some code. You will need to learn some Python. The essential logic (turn something on when some reading is below a threshold) is very simple; the more difficult part will be decoding the signals from the sensor. This might help:
https://www.instructables.com/id/Raspbe ... he-DHT-22/

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

Re: Can a 12v relay be run using inputs from a different sensor.

Tue Feb 25, 2020 2:40 pm

So the relay you linked requires 12V to power it so you would required a separate 12V power supply, you may also find you cant drive it on/off directly from the pi gpio which is only 3.3v so you may need an interface circuit between the gpio pin and the IN terminal on the relay.

the DHT22 sensor is not a true 1-wire device that will work with the 1-wire interface on the pi you will need specific software to interrogate it , most people use the software from adafruit.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

PhatFil
Posts: 1665
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Can a 12v relay be run using inputs from a different sensor.

Tue Feb 25, 2020 3:10 pm

If using to manage conditions for valuable contents i would suggest looking at more robust and reliable sensors than dht22. or at least consider the expected life and easy replacement of the sensor you use..

https://raspberrypi.stackexchange.com/q ... y-accuracy

Mariuszcz86
Posts: 2
Joined: Tue Feb 25, 2020 5:04 am

Re: Can a 12v relay be run using inputs from a different sensor.

Wed Feb 26, 2020 1:04 am

Thank you so much everyone for all the input. I found relays that are just 3v so that part can be simplified. I also found better quality humidity sensors, thank you for pointing that out. I'll be acquiring these components and doing some testing. Once I have it, I'll definitely be coming back to you all for further help, but I'll be checking in if anyone posts further information.

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

Re: Can a 12v relay be run using inputs from a different sensor.

Wed Feb 26, 2020 11:15 am

You should be aware you can't drive relays directly from the gpio pins if they do not have there own driver circuit on the pcb,

So if you are going to purchase just the relay like this

Image

then you really need to purchase the 5v version and then build your own driver circuit to connect it to the pi.

You can do it with a 3v relay but you can't power the relay from the 3.3V pin on the gpio header as it will cause your pi to reboot on relay activation, so you have to add more components to power it from the 5v gpio header pin and then reduce the 5v to 3v.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

PhatFil
Posts: 1665
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Can a 12v relay be run using inputs from a different sensor.

Wed Feb 26, 2020 4:09 pm

Fyi i use the bluetooth sensors detailed in this project https://zsiti.eu/xiaomi-mijia-hygrother ... pberry-pi/
with my pi, but as i use node red i also use the xiaomi-ble-node to query my sensors rather than python.. At circa £10-12 they are pretty good vfm imho and as they broadcast thier battery level as well as temp and humidity you can set alarms to prompt a battery change fairly easily..

Return to “General discussion”