A wave of flu hit my hometown. And I wasn't spared. So my drink of choice for about three weeks was tea. I remembered how I saw a video, years ago, where someone used an Arduino Uno and a servo to dip a teabag into a cup. Well, it shouldn't be so hard to make a similar project with an ESP8266, should it?
Materials
Well, since I felt too sick to go outside, I took, what I've found in the basement. I still got some SG90 servos. And for the stand I used some angle brackets, which I fixed with some zip ties. As an arm for the servo, I found some plastic tongue depressors.
Setup
Quite simple. You can use the same 5V input for powering the servo and the NodeMcu. All you need is to select a digital pin for the servo. Any pin will do, since every digital pin on the NodeMcu has PWM capability.
Video
Maker Faire
The IoT TeaMaker was first featured at the Maker Faire Ruhr 2019 in Dortmund, Germany. Everyone could see the TeaMaker in action and try it for themselves.
AVNET invited me to the "electronica 2018" in Munich to hold a speech about IoT and Neopixels. So I thought, wouldn't it be great if I could finish my speech with presenting a functional project on stage by controlling Neopixels with a smartphone. Something with a practical, everyday use in home automation? .... Yeah, I got it! A hat! Home automation at it's finest .. somehow.
Setup
Quite easy. We just need a pin for the Neopixels. Although the WeMos and the Neopixels are working with 5Volts, they can be both be powered by a 3.7V LiPo battery for a short period. To wrap the stipe around the hat once, I needed a total of 19 Neopixels (with a specification of 60 LEDs / meter).
For a very special woman, I needed a very special and unique present. Something really cool. How about a NeoPixel lamp, that can be controlled with a smartphone.
And why not adding some really funky features? Like turning the lamp on/off by the wave of your hand. And some nice animations. How about transmitting the temperature and humidity to your phone. And why not adding a scheduled sunrise, like the one from the sunrise simulator project? Too much? We'll see!
The Build
First of all I need a housing. I decided to use two old CD spindle boxes with different heights. The bigger one will house the Neopixels, the smaller one all the electronics. To make a little glow effect, I wanted to make the transparent plastic look like frosted glass. You can achieve it, by 'polishing' it on the inside with sandpaper. To mount the Nepixels I used a pump spray bottle, that I've cut into length. A lot of hot glue, some holes for the wires and it's a piece of cake.
Video
Problems
Problem 1: APDS 9960
As soon as the APDS 9960 gesture sensor starts working it blocks the processing of the microcontroller as it tries to check for a gesture. This leads to the stage that the animations stopped working smoothly.
So I outsourced the gesture readings to an Arduino Nano. It communicates with the NodeMcu via three digital pins. I made my own small 'protocol'. By setting the pins to HIGH/LOW I can transmit eight different sensor states.
Problem 2: BME 280
The temperature sensor doesn't want to initialize with the begin()-function of the library.
I uploaded a I2C-scanner and checked for the I2C address. I searched the library of the sensor and find a method where you can define the address. With the call of begin(0x76, &Wire) the BME sensor just worked fine.
Wiring
Does it look a little complicated? Maybe. But it's quite easy. Everything needs power, corresponding to it's specifications. The sensors can be powered by the voltage pins of the microcontrollers. The Neopixels need more current, as the controllers can provide, so it needs to be powered directly by the power supply. The APDS-9960 sensor is connected via I2C to the Nano. So it has to be pin A4 (SDA) and A5 (SCL). On the NodeMcu it doesn't matter which two pins we use, since nearly every two pins can be configured to act as I2C.
Features
The lamp communicates via the MQTT protocol. I've put in a small Raspberry Pi Zero W, that acts as a MQTT broker. The Arduino Nano handles the gesture sensor and sends a signal to the NodeMcu to turn on/off all Neopixels. The NodeMcu has access to the BME280 sensor and publishes the temperature and the humidity to the MQTT broker. You can switch modes between On/Off and several animations. For nearly all functions (except the sunrise alarm and the disco light) you can set the desired RGB color.
The NodeMcu syncs time with a NTP server. So you can set a time when to start the sunrise-mode.
Modes
Off (0)
Well, every NeoPixel is turned off. The Lamp still reacts to the gesture sensor
On (1)
Sets all NeoPixels to the desired color.
Animation (2)
Sets the color of the stripe one pixel at a time, starting from the bottom, rising to the top.
Blue Light (3)
A rotating light. Like the one the firefighter or the police use it. But in any color you want.
Fire Simulation (4)
Random flicker, that starts at the bottom, rises and falls randomly.
Sparkle (5)
Turns on all LEDs at the desired color. Adds randomly some white sparkles to the light.
Blink (6)
Remember the classical blink-sketch? Now with a hole lamp and the color you like.
Sunrise Alarm (7)
You set the hour and minute where the alarm starts and it simulates a sunrise (like in the sunrise simulator project).
Disco Lights (8)
Randomly sets up to 4 LEDs to a random color.
FAQ
Why using three boards, when one can do the trick? Raspberry Pi Zero W - Well this is not really part of this project. But I wanted a MQTT broker for the ESP. And for upcoming projects. So why not put it in the lamp? Where I have the place and already the needed power line?
ESP 8266 - The heart of this project. Why not an ESP32? Cos' I don't have one
Arduino Nano - I had a small delay with the library controlling the APDS 9960 gesture sensor. I could have used a ESP32, but I don't have one. I could programmed it on the Pi, but I didn't want to. It increases the cost by about 3.50 € and I found a simple way to transmit simple data. So, who cares?!
Everything fits in the CD case on the lower section. And the more boards you can see there, the cooler it looks. And I like the way it looks.
Many devices uses current on standby mode. So we like to plug them into a power stripes with a switch on it. And we hide it behind some furniture because it's quite ugly to look at some cables. But now it's hard to reach. So.. if we could control the switch remotely within the comport of our couch? That's what IoT is made for.
Wiring
Video
Attention!
Working with 110V AC or 230V AC is very dangerous and should be done only by a professional! Not only can it kill you, you also suffer incredible pain while you die!
Configure MQTT-Client
The MQTT broker and your client device has to be either in the same network or at least reachable through the internet (not really recommended).
You enter the IP and port of your broker to connect to it.
Add a new widget for on/off mode.
Then you subscribe to the channel the ESP is sending it's status to. It is: "esp/3/power/out" in this code.
You need now to enter the channel, where you want to publish commands to. The ESP subscribes messages from this channel. I used "esp/3/power/in" for this case.
Now, the only thing left to do is to define the messages for on and off. Usually it would be best to use 1 for on and 0 for off. I go for 10 for off and 11 for on.
Is yours too small? You want to get more? No, that is no advertisement for a penis enlargement product. It's for a board to extend the numbers of analog inputs to your microcontroller.
It's quite rare that you run out of analog inputs, when using an Arduino Uno, Nano, Micro, etc. Even a ATTiny is already equipped with 4 analog inputs. BUT if you are so keen in using a ESP8266, like I am, you'll find your self in the position having only 1 (!) analog in. This is where a digital to analog converter comes into play.
It's all about libraries
The name of the sensor (ADS1115) already can lead to the conclusion that the board is developed by Adafruit. And of course, if you'll open the library manager in the Arduino IDE and search for ADS1X15. There you have it all. Ready-To-Use library, good commented examples.
I2C on your NodeMcu board
The default pins for I2C on the NodeMcu board are pins D1 (SCL) and D2 (SDA). But the cool thing with the NodeMcu board is, you can define for yourself where the I2C has to be.
With the command: Wire.begin();
You usually start the Wire-library, that is responsible for the I2C bus. But you can also add the pins for SDA and SCL as parameters: Wire.begin(D2, D1);// Wire.begin([SDA-Pin],[SCL-Pin]);
There can be more than one
The ADC1115 has a fixed I2C address, like any other I2C device. Fixed? Not quite! It has up to five different I2C addresses. The default one, and four more addresses, that you can select by connecting the address pin (ADDR) with either SDA, SCL, GND or VDD.
On the 28.02.2017, the fifth birthday of the Raspberry Pi, a new version was released. The Raspberry Pi Zero W. The W stands for wireless and indicates that Wifi and Bluetooth is already integrated on this board. Finally.
The 'old' Raspberry Pi Zero costs about 4£ plus shipping, while the new version costs about 9.60£ plus shipping.
Difference in power consumption
One thing that was on my mind is: does the integrated solution draws more or less power other than attaching external Wifi and Bluetooth.
The solution I found most similar to the configuration on the new Pi Zero W was the HAT from Redbear. It also extends the Pi Zero with the same connectivity as the new one has now.
So I installed the same Version of Raspian on both models (Kernel 4.4, Release Date: 2017-03-02), turned Bluetooth on and connect with active Wifi to my home network.
Pi Zero + Redbear HAT
Pi Zero W
...
...
140-160 mA
130 mA
More expensive or cheaper?
Well, kind of a tricky question, isn't it? On the first sight, you see the same-sized board with identical specs for more than the double of the price. But think about it. If you want to use it, as a streaming-client, a home cloud server, a broker for IoT projects or even a small PC, you need what? Internet connection. So you need a Wifi dongle. And since it wouldn't fit, you also need a OTG adapter. And a small USB hub would be also nice. Oops! That's a lot of extra to buy.
Watch the Pi Zero W
Worth it?
If you are looking for a small single board computer as a replace for a Lunix based desktop computer, you should probably go for the Raspberry Pi 3.
But if you want to buy a Pi Zero anyway, you should go for the version with the integrated connectivity. Because if you are a maker and want to build your own IoT device, a Webserver or even a autonomous robot, you wish earlier or later that you can communicate with your Pi.
I always wanted one of those fancy LED stripes that you can control with your mobile or tablet. Should be easy to install, lightweight and customiseable.
Well, my brother-in-law is fascinated of this topic as I am. And Christmas was at our doorstep. So what better to do than try to build him a DIY-light.
Well getting started with it was quite frustrating. And it took me quite a while to figure out how it is done since this was my fist contact with the ESP8266.
After I posted a video of the result on FB, I was getting many requests for a manual to this.
Shopping List
Before soldering it to a PCB, I prototyped it on a breadboard. Here is everything you'll need.
The level shifter might not be necessary. The NeoPixel stripe could also work with 3.3 V on the command line. But it would be best if the difference between supply voltage and command voltage would not be so high.
And be aware not to power a whole NeoPixel stripe from your controller. On other Projects I blew up two Arduino Nano.