Introduction: IoT-cloud Globe Light
My kids don't like to go to bed in complete darkness. So, a while ago, we bought globe light, which isn't very bright, but it makes room lit enough so kids aren't scared of shapes and shadows.
That globe isn't on through the whole night, it is needed just until kids fall asleep, so I turn it off when I go to bed. But, sometimes I'm lazy. Ok, I'm lazy often. And I wanted to make it lazy-friendly. First version of IoT-cloud connected globe was external hideous thing, big, ugly, brick-like, with miniature button which was in collision with globe's one on the cable - I could turn globe of with cable switch, but also cut power on IoT brick, and then cable switch was useless as it couldn't light it up without power... My wife also wasn't very satisfied with that brick...
That's why I've decided to make it better - everything should be embedded, only one switch, child-proof, and fool-proof - so ANYBODY could use it. My plan was to embed everything in base of globe, big, black hunk of plastic. It turned out that it has enough space for everything with off-the-shelf parts: Wemos D1 mini, solid state relay board, metal button with LED light and 220V to 5V driver. Only small drilling is needed to fit button and pull cable for power internals through base.
- Wemos D1 mini - buy it here
- Solid state relay board- buy it here
- 220V to 5V driver - extracted from an old cellphone power supply, but can be used one like this
- Button with LED- buy it here
- Bunch of interconnecting wires
- Some better wires for 220V
- Some euro-style cable connectors
- Soldering iron
- Soldering tin
- Small drill with tiny drill and sanding attachment (for button and cable holes)
- Exacto knife
- Hot glue gun (to stick everyting to the base)
Time to build: 2 hrs
Time to program: 15 min
Time to set Cayenne up: 30 min
Step 1: The Internals
I use Wemos D1 mini as board of choice, which is built around ESP8266. It has more than enough ports for this project, it is fast, easy to use and cheap. Programmed in Arduino IDE, it took less than 30% of space on ESP, which is great.
Solid state relay board switch pin is connected to Wemos's D5 pin, metal button is coneected to D6 pin and GND pin, and everything is connected to power supply's 5V and GND pin (Wemos power, relay power, button's LED).
Sketch is fairly short and easy to understand - Wemos monitors button, and when it's "short-circuited" to ground, it becomes LOW - then it's time to toggle relay. In Arduino IDE, pin D6 is set as pullup. It is also connected to MyDevices Cayenne cloud, and also gets Cayenne's button state. One more thing, when hardware button is pushed, it toggles Cayenne's button and one 2 state software sensor. Just to have FULL control of the thing.... :-)
I'll upload sketch later.
Step 2: Plans
As this is project for myself, I have hard-coded WiFi and Cayenne parameters, but I got few inquiries about IoT conversion, so I'll include WiFi Manager library and will have to make my library for Cayenne token. Also, I'll have to make instructions how to set up and use Cayenne for non-geeks.
Few ideas I got after building this are to fit globe with motor so it revolves slowly (also controlled via Cayenne, and MAYBE with hardware buttons) and to include DS18B20 thermal sensor so it reports temperature in room. While DS18B20 sensor is easy, almost trivial to fit, motor installation won't be so easy, but I guess I'll manage something out :-)
Participated in the
Microcontroller Contest 2017