Hey makers, it's maker moekoe!
In this Instructable I want to show you how to bring more comfort and luxury to your homes. When reading the title, you may guess what we gonna build here. Everyone who visits the amazon online shop at least once, will be confronted with this little thing called amazon dashbutton. With these battery powered devices, which you can stick everywhere in your home, it's possible to reorder a specified product by a single button press.
In this how to we are going to make something similar, but without to reorder anything on amazon. We gonna control the Internet of Things or let us call this the Things of Internet - just because IoT is in everybodys mouth and Toi sounds more special to me... And what the Things of Internet could be is up to you. You could possibly control everything which has at least a wifi connection. In my case, I want to control my smart home devices such as lights, radiators and scenes by connecting it to my existing Apple HomeKit framework.
So actually, the goal of this project is to build an electronic device with self-designed PCB which occupies following aspects:
- as simple as possible by containing only one control button
- as small as possible
- as fast as possible to minimize latencies
- as portable as possible, or let us call it battery powered
- and as... well, it should have a wifi connection
The result in general consists out of a PCB with a voltage regulating unit, a microcontroller, a LiPo battery and a simple button. During a short period of time I optimize the dashbutton PCB twice, so that we are at the third version of the PCB until now.
When you want see the behavior of this little thing, then check out this video on my Instagram. There are plenty videos of the dashbuttons in action and how they are built. So, for all of you who want to see more, you can find everything here @maker.moekoe.
Step 1: Things You Will Need
To build your own IoT dashbutton you only need a few components. Even though there are slight differences from version to version, the voltage regulating part stays the same. For all versions you will need:
- MCP1700 3,3v LDO voltage regulator
- 2x 1µF 1206 SMD capacitors
Additionally for the round or the rect version (left part of the picture above):
- PCB (version 1 or 2)
- JST PH-2 90° Lipo connector
- 100mAh Lipo battery with dimensions of 25x12mm
- 3x6mm SMD button
Or additionally for the coin cell version (right part of the image above):
- PCB (version 3)
- WS2812b rgb(w) LED
- 0,1µF 1206 SMD capacitor
- 6x6mm SMD button
- 2450 coin cell holder
- LIR2450 coin cell battery
Of course, you can think about a small housing for the dashbutton. A simple idea can be found in the fifth step of this Instructable.
Step 2: Printed Circuit Board
When I started with this dashbutton thing, I created the pcb version one without any specials - only connecting the few parts with electrical traces. I wouldn't recommend this version because it was the first draft and it is not developed like the others. Here is a small summary of all three versions:
Version 1 was my first final draft which has some things to optimize. Maybe I will update it in the future but it is working already. The PCB has the outer dimensions of 24x32mm. It is powered by a small LiPo battery and has just a voltage regulating unit for powering the ESP8285-M3. The battery sticks with some doublesided tape on the bottom of the dashbutton.
Version 2 consists of another outer shape of the PCB. It is round with a diameter of 30 mm and includes a ground plane over two-thirds of the area. The other third is the antenna of the microcontroller and shouldn't be overlapped with any of the traces or ground signals to reduce interferences. The schematic is the same as version one. And just as version one it is based on an ESP8285-M3.
Version 3 has another outer shape as well. Main difference is that it is powered by a standard LIR2450 battery which can be replaced easily if it's getting empty and therefore the PCB has to be a little bit bigger than the other versions. Additionally, it consists of an WS2812b rgb(w) led to inform on different things. Furthermore and in contrast to the other two versions it is based on an ESP8266-07S.
So just choose a version from the attached files and place your order at your favourite PCB company.
I definitely recommend version two, because it is the most developed of all and the small size of just 30mm is very handy in my opinion. When you want to have more features in that little thing, then refer to version three, but this version is still a work in progress and may has to be optimized in some aspects...
Step 3: Complete Your PCB
If you're holding your PCB in your hands, it is time to solder the components to it. To do so, you can use whatever technology you like. In my case I soldered the components with solder paste and reflow technology. For this you will need some solder paste in a syringe, a reflow soldering station (or something like a hot air gun) or a oven. Like shown in this video (for version two) or the video above (for version three), you have to dispense a little bit of the solder paste to every smd wire pad before you place the components to its provided space. In the video for version two it is shown with a semi-automatic dispenser and placer but the applied components are big enough to solder them completely manually like shown in the upper video for version three.
After this you can put the PCB into the oven or solder them with your chosen technology. This process is also shown as a timelapse in the upper video.
Of course, this should be possible with a normal soldering iron as well, but I think that won't be the easiest way and you have to be very patient.
Step 4: Flashing the ESP
Flashing the microcontroller on the pcb may not the easiest part. But thererfore that the dashbutton should be as small as possible, there are also as less as possible components on it. To flash it, there are three important things which you should make use of.
- The GPIO0 (PROG for version three) wire pad jumper should be shortened to put the ESP in programming mode. Have in mind, that the microcontroller won't start as usual with a shortened GPIO0/PROG wire pad.
- You have to connect the four wire pads (3,3v - gnd - rx - tx) to an external FTDI adapter. Doing so, you don't have to solder some wires to it. Because I have aligned the four wire pads in the 2,54 mm, grid you can take a 4-pin pinheader, connect it with jumper cables to the FTDI adapter and press it against the wire pads while uploading the sketch. And because a picture is worth than thousand words, I added one showing this process.
- Right after the uploading message inside the Arduino IDE appears, you have to press the reset button once (it is THE button - the only button on the dashbutton). After this the blue led on the ESP should flash a few times until it flashes constantly while the uploading bar inside the Arduino IDE fills up.
My dashbutton is integrated into Apples HomeKit framework to control different things in my home. I won't go into detail how to install it or how it works because this would go beyond the scope. If you want to do it the same way you can refer to the awesome work of KhaosT, who worked on a node.js implementation of the HomeKit accessory server, which I used as well. For those who gonna use it I attached the Dashbutton_accessory.js file.
However it is possible to integrate the dashbuttons into another existing smart home application, or even more. The attached Arduino code is working with MQTT, which will operate with nearly every smart home implementation.
When you want to start with the attached Arduino code, then simply add your wifi credentials and the MQTT brokers IP address in the following code lines:
const char* ssid = "XXX"; const char* password = "XXX"; const char* mqtt_server = "192.168.2.120";
The sketch simply wakes up the ESP from deepsleep mode when the reset button is pressed once. After this it will connect to the specified wifi network as well as to the MQTT broker, before it publishes a simple message (like a single '1') to the defined topic. Afterwards the ESP goes back into deepsleep mode. Should your network be unreachable for the ESP, it will go back to deepsleep mode after six seconds, but of course without publishing anything. This is just to prevent the battery gets empty very fast.
Step 5: Print a Housing
The dashbutton should be already working when you have reached this step. But it should get a small case to prevent some damages to the PCB or to the electronics. Of course this is the creative part of this Instructable. So, if you want, you can design your own housing and print it on your 3d printer like I did. You can start from scratch or you can use my case and add some modifications. Obviously, the housing can be found on Thingiverse, but I have attached the files here as well.
The case or - to be more accurate - the lid for version 3 is not ready yet, but I will update it as soon as possible.
Step 6: Have Fun and Be Creative
So, hopefully you're able to switch your lights by a single button press now!
At least, my calculations have shown that the battery capacity of version one and two will reach up to 150 days with following values:
- LiPo capacity of 105mAh
- load current of 70mA
- deepsleep current of 20µA
- time for publishing of 3 seconds
- button intervall of 2 per hour (that is more than it will ever reach, I guess)
- battery loss factor of 30% (which is very high as well)
The battery lifetime of version 3 should be at least the same, whereas it has 120 mAh capacity. However, it has the ws2812 led on board, which will draw some current as well.
Now it's up to you! Hope that you enjoyed reading this Instructable or maybe enjoyed building such a nice little thing.
If you have any suggestions or if something is unclear to you, then feel free to ask me in the comments below or write me a short message.