A dashbutton for the Internet of Things called Octoclick

Basic idea of the octoclick was to create an optimized version of my dashbuttons. Optimized here means, to eliminate the main disadvantage of the ESP8266 respectively any other mcu: the deep sleep current.

I came to the dashbutton thing while playing around with my home automation. I found out that there is nothing for just switching a device, a scene or a group of any actions by a single button press (or when there are devices like that, they were really really expensive and do not fit my budget). There are several other opportunities to use these devices, such as controlling things in IFTTT, using the three buttons to act like a game remote control or exchange the button with anything else like reed switches or PIR motion sensors. The dashbutton problems were the limitation of the functionalities:

  • only one button (reset button)
  • uses deep sleep mode which draws a lot of current (compared to the octoclicks sleep current)
  • button can only be used to reset the device (not to read its state)
  • different scenarios for button press and button hold are not possible

All these are reasons why I have invested a lot of time to create the octoclick devices. Octoclicks come with an additional self latching power circuit which solves all the key points listed above. The mcu itself will hold its power through a trigger line after it was powered by a physical input (here: button press). The main part of the circuit is a switch (mosfet) between the lipo battery and the mcu. It basically can cut off the power to the ESP8266, whereby the switch can be controlled in two different ways:

  1. by pressing a button (could be as many as the microcontroller has gpios)
  2. by the trigger line which comes from the mcu itself

Basic idea

The octoclick is completely off. By pressing a button, the switch will be closed and the mcu will get power. The first task of the mcu is to set the trigger line which will close the switch as well as the button did. After the button is released, the switch stays closed till the task of the mcu has been done. Then the mcu will cut off its own power by setting the trigger line to 0. The switch will be open and there is no current flow anymore.

This circuit can be shift to any other mcu as well, but keep in mind that the button has to be pressed till the mcu has finished booting and sets the trigger line. For the ESP family this won’t be a problem, because it boots up in a few milliseconds. A normal button press is something between 20 and 200ms. Some microcontrollers use much more time to boot, for them this circuit doesn’t make fun, because like every second button press will be a ‘failed one’…


The octoclicks are powered by a single LIR2450 rechargeable lipo coin cell. It has a capacity of 120mAh. In on state the device uses around 70mA of current, whereas in off state it uses almost nothing, but let’s calculate with 1µA. Per click the device will be in on state for about 2-3 seconds, let’s calculate with 3 seconds. Battery loss factor of 15%.

3s * 70mA = 210mAs = 0,058mAh per click would result in 120mAh * 0.85 / 0,058mAh = 1758 clicks without considering the sleep current
(clicks/day * 3s * 70mA + (3600s * 24h/s - clicks/day * 3s) * 1µA) / 3600s * 24h/s results in 8,29µA for 3 clicks/day or 25,3µA for 10 clicks/day.
120mAh * 0.85 / 8,29µA = 12304h = 512d = 1,4 years for 3 clicks/day
120mAh * 0.85 / 25,3µA = 4032h = 168d = 0,46 years for 10 clicks/day

So in general it is only depending on the number of clicks per day. Calculating without a sleep current it would last for 1758 clicks. For a sleep current of 1µA we can reach up to a total number of 1536 clicks when clicking 3 times a day in a period of 1,4 years or 1680 clicks when clicking 10 times a day in a period of round about half a year. These are great results in my opinion. 🙂

Another example I would talk about is a simple button near your bed for switching off all the lights in your home when you want to go to bed. This would be one click per day for the normal people 😀 and it would result in 3,4 years of battery lifetime! Unfortunately the self discharge of the lipo would drain the battery faster than with your clicking…

Parts you will need

  • PCB
  • ESP8266-12F
  • MCP1700 3,3V voltage regulator
  • IRLML2502 N-channel mosfet
  • IRLML2244 P-channel mosfet
  • Resistors 0603 (1M, 470k, 100k, 47k, 10k, 1k)
  • Capacitors 0603 (1µ)
  • Diodes 4148 SOD123
  • LEDs 0805
  • Buttons (3x white smd, 2x micro black)
  • LIR2450 battery with holder clip

The schematics

In this chapter you will find out how that latching power circuit of the octoclicks are working. I will show you several pictures of the same schematic, but with different highlighted parts to explain it.

First of all, the first picture shows the whole schematics. Of course, the main part of this circuit is the mcu, an ESP8266-12F which actually does whatit is supposed to do. In the most cases these devices will boot up, connect to a specified wifi network and sends a request or publishes a message via mqtt. After this procedure, most devices will go back into deep sleep mode and after the reset button is pressed it starts a new cycle. The octoclicks doesn’t make use of this deep sleep functionality. It uses the latching power circuit for switching off its own power supply, which saves a lot of battery power. Compared to the deep sleep current of at least 25µA, the latching power circuit needs almost nothing while in inactive state.

Before I will talk about the latching power circuit, some infos according the mcu. For letting the ESP boot up in normal mode, it needs several things to go with. First it needs some power via the VCC and the GND pin. To enable the mcu a pull up resistor of 100k will work for the chip enabling pin CH_PD. Last but not least the GPIO15 has to be pulled down with a 10k resistor.

Both the buttons in this highlighted part are used to flash the mcu. Holding the PROG button while booting the ESP will bring the mcu into the flash mode. So for flashing you have to hold the PROG button while pressing the reset button once.

This version contains both of the buttons on the board itself but for further versions I will outsource them to save a bit of space on the PCB.

This highlighted part shows the main difference between the devices which uses deep sleep functionality. Before the battery voltage of 3,6 to 4,2 volts will be regulated to 3,3 volts for the mcu via the MCP1700, it can be switched via the mosfet Q1 (IRLML2244). Just because the voltage regulation part is also behind the ‘switch’ (mosfet), the whole circuit gets unpowered and there won’t be any current flow in off state.

The off state will be reached through the pull up resistor R1 on the mosfets gate. Something around 1M will work.

Next to that pull up resistor the gate of Q1 can also be controlled via the mosfet Q2 (IRLML2502). This mosfet will pull the gate of Q1 to GND and ensures that the mcu will get power. The gate of mosfet Q2 can be controlled in two and a half ways. The half way is the pull down resistor R3. It is a half way, cause it is not controllable via this method, it just ensures that Q2 will be open if nothing else happens.

One of the two main ways of controlling the gate of Q2 is by pressing one of the three buttons. They are connected to VCC of the battery and the gate of Q2 with a diode. Pressing a button will close the mosfet Q2 and this in turn will pull the gate of Q1 to GND which closes that mosfet. At the same time the LEDs at the bottom of the schematics will light up according to the pressed button.

The second way of closing the gate of Q2 is via the highlighted trigger line in this picture. It is connected to any GPIO of the MCU, in this case GPIO16. The procedure of the whole device is an interaction with these two methods. First you will press a button, then the mcu gets power and the first thing it will do is to pull the trigger line high to ensure the power flow to the MCU.

For every octoclick with more than one button (and octoclicks with one button and a different application), it is neccessary to get informations on which button has been pressed. Therefore the three voltage dividers behind the buttons are to lower the lipos battery voltage of max. 4,2 volts to something under 3,3 volts which can be read by the mcu without destroying it and which will represent a HIGH signal. Referring to the ESPs datasheet the IO level for a high input is 0,8*Vio which is something around 2,6 volts. By using a voltage divider with 100k and 370k we will get an input voltage of 3,3 volts with a full battery (4,2 volts) and an input voltage of 2,8 volts for an empty battery (3,6 volts). This isn’t the best solution, but it works for me and it was the easiest to implement. A better solution would be by using optocouplers or something like this to isolate the two potentials and to get stable/constant IO signals.

The last picture shows the battery guard, which consists of a simple voltage divider with R/1 and R/2 directly behind the main mosfet. It converts the lipos battery voltage to a max value of 3,3 volts which can be read by the ADC of the ESP. That voltage reading can be converted to a battery capacity.

The printed circuit board

This is what the circuit looks like on a PCB. Of course this is the creative part of the work and there are several layouts which will work. I like to get things ordered that is why I try to use mirrored coordinates for main components like buttons, leds and of course the ESP. For all other components this could get really tricky, but sometimes I try – the diodes above button 2. 🙂

These pictures are taken from the board viewer on aisler.net. At this point I wanna thank Aisler for supporting my projects by sponsoring me PCBs! It is definitely the easiest and fastest way to transform ideas to PCBs.

You can found the PCB link in the Parts section of this post or here. There you can play around with the board viewer or order your own octoclicks. If ordering then use the code MOEKOE50 which will give you 50% on your first order.

The Code

Well, there isn’t magic in the code. The only thing which differs from other, is that there is no deep sleep call. The only part for this is setting the latch pin HIGH or LOW.

You can download the code here. I uploaded the octo_bare_minimum.ino which is the minimal setup to control the octos and a full example with MQTT. If you are interested in some other sketches, like IFTTT or a simple game remote control than please let me know and I will update it.

Have fun

Now, let’s stop talking and enjoy some pictures of the octos. Have fun 🙂

%d bloggers like this: