About This Project
(MQTT code included at the bottom of this article)
My goal was to build a simple programmable unit to control standard 433MHz switch units. Want to use that to control the lights in our house if we’re not at home. I am not a programmer and used some Turbo Pascal back in the 80’s in Electronics school. Hooking up an Arduino to a real time clock and copy/pasting code is no problem but writing code to compare times and dates is way to complicated for me at this moment. Then I discovered Cayenne! On Thursday I received my Wemos D1 and after a few hours of playing around the first version is working.
Getting the 433MHz transmitter to work from the Arduino/Wemos D1.
I used the following resource to get it to work and used a 433Mhz receiver to discover the code that the manual remote control unit was transmitting. Elro – Arduino, ESP8266, ESP32 & Raspberry Pi stuff
Figuring out the @#%# Pin mapping of the Wemos D1.
Having played around with the Arduino I was somewhat confused by the Wemos D1 pin mapping.
Check the following page for more information: Arduino/pins_arduino.h at master · esp8266/Arduino · GitHub
For this project I used the Wemos D1 pins labelled D9 (=2 in my sketch) and D3 (=5 in my sketch). Took me some time to figure that out.
What’s Connected
Wemos D1 V2 (includes Wifi, supports most Arduino code but has a weird pin mapping)
433Mhz transmitter
Elro 220V switch unit
Img 0 : These are the 433Mhz transmitter and receiver I use.
Img: this is basically all it takes, the D1 and the 433Mhz transmitter
Triggers & Alerts
I am not using triggers or alerts (yet)
Scheduling
Scheduling is one of the two main functionalities. I have built the controller for 1 channel but can easily add multiple channels by copy/pasting code. One channel can control multiple switch units in parallel.
Dashboard Screenshots
It’s a very simple set up at this moment but as said, I can easily add other channels.
Photos of the Project
Img 1: D1 connected with the orange Data wire to the transmitter. I also hooked up a LED to indicate if the switch is supposed to be on or off. (don’t forget to put a 1k ohm resistor in series to ground)
Img 2: The 433MHz transmitter. It has 4 pins but only the Data, + and - are used.
Img 3 The 220V switch unit and the manual remote control unit.
The sketch code
cayenne_WemosD1_V2.txt (2.0 KB)
Explanation is embedded in the code
Issues
- I sometimes encountered issues with scheduling. At this moment I am running a duration test and scheduling is working well. The issue I had was that I scheduled an event and it just did not work.
Update April 1st 2018: migrated to MQTT
I changed to MQTT and that works well. I only have an issue selecting a device/actuator when using the schedule from the IOS app (raised a ticket for that).
MQTT sketch included 20180401_MQTT_code_433Mhz_remote_switch.txt (3.4 KB)