Full Automatic Roller Shutter Controller
by BobbyBalsa in Circuits > Microcontrollers
658 Views, 1 Favorites, 0 Comments
Full Automatic Roller Shutter Controller
Before introducing this project I would like to give credits to the people who's hard labour made this project possible :
The people from sunrise-sunset API :
https://sunrise-sunset.org/api
Rui and Sara Santos from Random Nerd Tutorials :
https://randomnerdtutorials.com/
The Micropython community :
https://docs.micropython.org/en/latest/esp8266/tut...
Alan Wang for his Web-based clock :
https://www.hackster.io/alankrantas/very-simple-mi...
Take care when building/testing/operating this project ! 220V( or 115V ) present ! Use at your own risk !
And now something completely different ( Monty Python ) ...
My roller shutters were oldskool pushbutton operated and I felt the need to improve . But it was almost impossible to use COTS ( commercial off the shelf ) stuff because the neutal wire was hidden somewhere ...
Because I don't like to use crowbars , sledgehammers and other heavy stuff let's have some electronic/software fun !
The solution is a battery-operated system , ultra-low-power , so an ESP8266 was chosen ( using the deepsleep mode ) . But if you can reach the neutral wire feel free to use a power supply .
Working principle is very simple : the controller is in deep-sleep mode for 10 minutes , wakes up and connects to your router . It fetches UTC time , sunrise-sunset times and compares them . After sunrise the shutters go up , after sunset they go down . When up a flag is set to prevent unnecessary relay operation ( save power ) , same logic if the shutters are down . Time accuracy is about 10 mins because of the sleep mode used .
Supplies
Hardware :
links are to my favourite supplier in the Netherlands :
ESP8266 controller ( use ESP12E) for low power : click here :-)
FTDI or other USB-to-serial programmer
2 Arduino 5V single relay modules : click here :-)
5V power supply ( if acces to neutral wire is possible) : click here :-)
2S1800mAh Lipo ( if not )
1 or 2 step-down converters ( 1 if power supply is used ) : Banggood or Ali
2 or 3 transistors BC547B ( 3 if optional buzzer is used )
5V buzzer ( optional )
3 resistors 27kOhm 1/4W
prototype PCB
connectors etc.
soldering gear
Software :
Micropython flashed into the ESP12E
Thonny IDE or your favourite environment
Pick Your Version ( Battery or Line Operation )
If you have access to the neutral wire it's better to use the power-supply version , no need for a LiPo battery .
It's also possible to buy COTS-gear (what is COTS ?)and ignore this Instructable but it is more fun to DIY !
Remove the mechanical switches and look for the neutral wire ( caution : pull the circuit breakers first !! )
You'll need only one step-down converter and a decent 5V supply .
Refer to the schematics "line powered version " .
If you're unlucky : refer to the schematics "battery powered version" ...
Test/Modify/Adjust Your Hardware
It is always a good idea to test your modules before putting things together . This will save troubleshooting time when Murphy strikes ( again ) ...
Line powered version : connect your 5V supply to the mains and verify 5V present at output .
Step-down converter : connect input to the 5V from the supply and carefully adjust for 3.3V .
Battery version : the safest thing to do is using a lab power supply set to 8V and current to 100mA or so .
If something is wrong a Lipo pack will smoke everything connected to it ...and sometimes itself ...
Adjust one converter to 5V ( relay power ) and one to 3.3V ( controller ) .
If OK both can have their inputs connected to the battery pack .
The relay modules can be tested very easily : connect 5V to Vcc , GND to GND and short the IN and GND terminals . Relay should "click" and green LED should illuminate . Red LED is always ON ( 5V power ) .
If both relay modules are tested and OK it's recommended to unsolder the red and green LED if you're building the battery powered version . Less power , more battery time ! If my calculations are OK the battery must be charged approx. every 40 days .
Preparing the ESP12E
Because we all have different computers/operating systems it's kinda hard to write a guide on installing Micropython . But we have a helping hand from the people of Random Nerd Tutorials , they did an excellent job !
Here's the link : Installing Micropython
Thank you very much Rui and Sara Santos for your excellent work !
We are using the ESP12E to save power so we need an extra device to flash/program it . No problems , it's all covered here : see "uploading code to the ESP12E"
When using ESPtool.py it's best to erase the flash , then unplug the programmer and ESP12E , plug it in ,then flash the firmware . Disconnect . When done disconnect the GND-GPIO0 connection or the chip will enter flash mode when plugged in . Look for the REPL REPL micropython .
This can also be done in your favourite IDE ( I use Thonny on an Ubuntu machine ) .
Very important : check the firmware integrity : at the REPL , type :
import esp
esp.check_fw()
Output should be "True"
After flashing the firmware the ESP has boot.py already installed . Now download my silly script (main.py) . It must be edited ( Thonny again ...) in order to work . Change following lines :
ssid = "your_SSID"
pw = "your_password" with the correct SSID and password for your router .
url_time = "http://worldtimeapi.org/api/timezone/Europe/Brussels"
Replace Europe/Brussels with your location ( unless you're a Belgian like me )
url_sunrise_set = "https://api.sunrise-sunset.org/json?lat=51.16697&lng=4.45127&formatted=0"
here insert the correct lat/long values
up_relay.on()
utime.sleep(40) replace the "40" by the time (in seconds) needed for the shutters to open
up_relay.off()
do the same for the down_relay .
Done ? save the file and load it into your ESP :Uploading the script
Downloads
Building the Hardware
Build the hardware as shown by the schematics . Start by the step-down converters and the decoupling capacitors . Make sure the 5V and the 3.3V are within tolerances ( the ESP12E will be destroyed when Vcc > 3.6V ) . Then solder the rest of the parts , check and double-check everything . Ready ? Go to the next step !
Downloads
Checking the System ...
Before making the connections to the shutters ( and the dangerous potentials ! ) we must test our circuit .
First test : the relays must remain unpowered at power-up or return from sleep .
- remove the test jumper IO12-27k resistor ( disable beep )
-put your DMM in Ohms-beep mode and connect to the C and NO relay contacts
-power-up , the contacts must stay open on both relays
Second test : testing the "up"-relay after sunrise .
-this test must be done after sunrise
- connect the "beep-jumper"
-put your DMM in Ohms-beep mode and connect to the C and NO relay contacts of the "up"-relay
-power the circuit , beeper wil sound at power-up , after sleep mode ( 5s ) beeper will sound again and then the "up"-relay contacts should close for the time you programmed ( DMM should beep ).
-when the system reboots after a 2nd sleep the beeper must beep twice to indicate the rollers are already up .
Third test : testing the "down"-relay .
-put your DMM in Ohms-beep mode and connect to the C and NO relay contacts of the "down"-relay
-power-up the system just before sunset , DMM should beep when the "down"-relay is energised after sunset .
-after reboot the beeper should beep 4 times to indicate the rollers are already down .
When all tests pass you can disconnect the beeper .
Connect the System to the Rollers
I re-used the switches ( Somfy ) to create a manual/auto switch and a manual up/down switch ( see schematics ) . My rollers are mounted on the sliding backdoor to the garden and it's not good to be locked out after sunset ...
Again , be very very carefull when installing to the roller-hardware , ask a friend or skilled electrician when in doubt !
That's all folks , have lots of DIY-fun and don't hesitate to contact me if something 's not clear or can be improved or ...
See ya !
Bob