Building a button box

I started with Home Assistant a few weeks ago to drive my lighting mostly. Controlling things from my phone is handy, but I thought it might be nice to have some pushbuttons near the front door as well. Given I had pretty much all the parts, I decided to make a button box, that sends short or long press messages for 4 buttons over MQTT to my Home Assistant.

More at

It’s certainly not leading edge technology, but hopefully the write up might be useful for your own projects.


wow,thank you so much for sharing it, with us, very nice Project, i want to make similar Project, but with battey, look this Project,its very nice too.

I looked into the power saving modes of the ESP8266. If you go into sleep mode it uses very little power, and so you could use a battery to power it. The problem is how long it takes to reconnect to wifi once it wakes up. This would be a few seconds. For a sensor that is OK, but for something like a light switch, that is a bit too slow. (IMHO)

I’m not clear on how fast it reconnects if you go into the mode where the modem is powered down. It seems like it would stay connected to the access point.

Yeah you want the lights to come on the moment you hit the switch, not even 5 s later. In that time you can fall down the stairs or trip over the dog.

Thanks for this project. I think my wife will want something a little nicer in terms of switches, something less “industrial” - but your circuitry and sketch are a great kick start. Thanks.

My idea was to have a button under my dining table so that when I finished eating, I pressed the button and the coffee machine switched on. But I did not want to have wires going under the table. The solution would have to be something self-powered.

For inspiration, this doesn’t need a battery and generates the required power from kinetic energy, neat!

very nice, but the price… its very expensive …

Yeah too expensive… This article has some info on how it is powered

1 Like

Most of the self powered solutions I have seen use BTLE, Z-Wave, or something like 433MHz broadcast.

You save a lot of power if you don’t need to keep the radio on like you do for WiFi.

Plenty of micro-controllers let you wake up the system when it gets a digital input. In sleep mode, your batteries will last a long time.

If you don’t mind a couple of seconds wait, then an ESP8266 solution could work well. Your code sends it into deep sleep, woken by pressing a button. When it wakes up it connects to WiFi and sends a message. You can save on the connection time by using a static IP address, and by connecting to your broker by IP address (saves on DHCP time, and saves on DNS resolution time).

1 Like

I would be very glad if you could do this project and share with us.
If you have some sp8266 with you, share the code with us, it would be very interesting, because there is nothing like this here.
And I have seen that you have enough knowledge to do so.

Can a pi zero be configured in this way too? Possibly heading off on a tangent here but would be awesome to add a low power display, perhaps e-ink like below… I would like a button box with a display so that I can set various modes for the house on the way out and get visual confirmation of the state. Another simle solution would be to have a dial, retro…

An arduino mini pro paired with an nrf24l01 could also probably work, powered by 2xAA batteries. Batteries should last well over a year as the arduino and nrf module draw practically nothing when in sleep mode. Haven’t tested this myself yet, just waiting for the arduinos to come. I do have other sensors built around the house based off an arduino+nrf module.

very cool, after share with us your Project.

How about a ble button like a Flic

I use them reliably with hass. Just need ble on your server. I use a cheap dongle on my pi2.

Very small. Battery lasts about a year and could be stuck under the table.

Thanks for your suggestion but I prefer something cheaper.35 dollars is expensive in my opinion.

Check this out

And even more relevant, place the microcontroller in a dimmer switch

That first video bloody impressive. Very nice setup, and something I could probably even train my wife to use.

And the second one is cool too. Surely though we should be using esp8266 cos most of use don’t have wiring for wired ethernet.

I agree, wireless is the way to go for most people. I am investigating the Zerynth platform, would allow to run the same code on a whole range of micro-controllers so collaborating on these kinds of projects would be easier as everyone has their favourite micro-controllers