Power supply control
Power supply control
Hi!
New to the forum, but I skimmed through it in search of anyone trying to control power supply for appliances (in my case fridge and low effect heater).
The project is a temperature controller for a fermentation station of my home brewery. (Yes I could do it manually but what would be the fun?). I have seen some contibuted temperature sensor drivers, but I want to be able to control the temperature inside a fridge. The normal way to do this is just by setting it to minimum temperature and then controlling the power supply. Then I would like to add a small heater (heat lamp from a terrarium is probably enough since the fridge is insulated).
But what I need is to control the power outlet with two channels, anone done anything similar?
New to the forum, but I skimmed through it in search of anyone trying to control power supply for appliances (in my case fridge and low effect heater).
The project is a temperature controller for a fermentation station of my home brewery. (Yes I could do it manually but what would be the fun?). I have seen some contibuted temperature sensor drivers, but I want to be able to control the temperature inside a fridge. The normal way to do this is just by setting it to minimum temperature and then controlling the power supply. Then I would like to add a small heater (heat lamp from a terrarium is probably enough since the fridge is insulated).
But what I need is to control the power outlet with two channels, anone done anything similar?
Re: Power supply control
Just turning something on or off can be done with a relay or a SSR (Solid state relay).
You can get ready-made relays for controlling 120v AC: https://www.sparkfun.com/products/10747
Or you can use an SSR dierctly: https://www.sparkfun.com/products/13015
When you use a real mechanical relay, you generally need a diode across the coils, and you use a GPIO to control a transistor/MOSFET which is the thing which actually controls the relay.
You can get ready-made relays for controlling 120v AC: https://www.sparkfun.com/products/10747
Or you can use an SSR dierctly: https://www.sparkfun.com/products/13015
When you use a real mechanical relay, you generally need a diode across the coils, and you use a GPIO to control a transistor/MOSFET which is the thing which actually controls the relay.
Re: Power supply control
Hi. I just start contributing to the forum so forgive me if I am late and your project has already done.
First an assumption: I am always looking for the most simple, reliable and cost effective way to solve problems. My mantra is: if something can be done simpler and with less components just do it (other would say Keep It Simple Stupid
In this case I just would use:
- ESP8266 (of course I use a WeMos as it is very reliable and fits with serial drivers in Ubuntu very easily . Aliexpress WeMos
- Relay : I use this http://www.aliexpress.com/item/1PCS-fre ... 65e5e97b45
- Temperature sensor DS18B20: I use this http://www.aliexpress.com/item/Free-Shi ... 15885.html (don't forget the 4.7kohm resistor)
Some other spare components like
- usb charger + short usb cable
- electric plug
-
Electrically you should connect:
ESP GND - RELAY -
ESP 5V - RELAY +
ESP D4 - RELAY S
ESP 3.3V - DS18b20 +
ESP D4 - DS18b20 data
ESP GND - DS18b20 -
Total BoM cost is around 10US$.
Besides that there is the software which is very fun. Basically it will be a loop like
while True:
... get temperature
... if temperature < THRESHOLD:
... do something
... else:
... do something else
... DEEP SLEEP for sometime
Result is this (my assembly) https://www.dropbox.com/s/6jpklux5ua2i6 ... 4.jpg?dl=0
First an assumption: I am always looking for the most simple, reliable and cost effective way to solve problems. My mantra is: if something can be done simpler and with less components just do it (other would say Keep It Simple Stupid
In this case I just would use:
- ESP8266 (of course I use a WeMos as it is very reliable and fits with serial drivers in Ubuntu very easily . Aliexpress WeMos
- Relay : I use this http://www.aliexpress.com/item/1PCS-fre ... 65e5e97b45
- Temperature sensor DS18B20: I use this http://www.aliexpress.com/item/Free-Shi ... 15885.html (don't forget the 4.7kohm resistor)
Some other spare components like
- usb charger + short usb cable
- electric plug
-
Electrically you should connect:
ESP GND - RELAY -
ESP 5V - RELAY +
ESP D4 - RELAY S
ESP 3.3V - DS18b20 +
ESP D4 - DS18b20 data
ESP GND - DS18b20 -
Total BoM cost is around 10US$.
Besides that there is the software which is very fun. Basically it will be a loop like
while True:
... get temperature
... if temperature < THRESHOLD:
... do something
... else:
... do something else
... DEEP SLEEP for sometime
Result is this (my assembly) https://www.dropbox.com/s/6jpklux5ua2i6 ... 4.jpg?dl=0
Re: Power supply control
You shouldn't connect a relay to ESP8266's pins directly. Not only the coil draws much more current than the pins can safely provide, but it also feeds back a powerful back-current spike when it works, which can damage your board even easier. The solution to that is to connect the coil through a transistor (NPN or a mosfet), there are lots of examples of that on the Internet, and even some ready relay modules that already include the transistor.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Power supply control
Looking at the link for the relay it appears to have some kind of driver on the PCB so perhaps it is suitable for the job. Technical details are somewhat scarce though, unless I'm missing something.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Power supply control
A better description and a (wrong) schematic is here: http://tinkbox.ph/sites/tinkbox.ph/file ... KY-019.pdf
It shows an NPN transistor (collector/emitter drawn wrong) switching the relay coil including the recovery diode.
It shows an NPN transistor (collector/emitter drawn wrong) switching the relay coil including the recovery diode.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Power supply control
Oh dear, that's very topsy-turvy Assuming the transistor is correctly wired it should work with the Pyboard: the one caveat is that it's specified for a 5V minimum control voltage. Whether it will work with the Pyboard's 3.3V output levels will depend on the transistor's gain. A quick and dirty fix might be to short out the LED which would give the transistor about 16mA of drive.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Power supply control
Some of those relay modules use PNP transistors that need switching down from supply voltage, in which case GPIO high state (relay OFF) must be at supply voltage (5v).
NPN should be OK.
NPN should be OK.
Re: Power supply control
I was thinking whether it was designed as an emitter-follower, trying to save the costs for two resistors. For a 5 V signal that would work, even if not really well, but not if driven from a 3.3 V device. The voltage at the relay would be like 2.6 V, which might be too low for operation.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Power supply control
With an incorrect schematic everything is up for grabs. However two things point to an NPN transistor incorrectly drawn. The (Chinglish) spec says that a logic 1 is required to actuate the relay, and the polarity of the LED confirms this.
Confucius he say: "To make the coil of relay energized you must need to have an input of 1 in the signal pin."
Confucius he say: "To make the coil of relay energized you must need to have an input of 1 in the signal pin."
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.