So I’ve been wanting a smart button to turn on/off certain lights. I already have plenty of ESP boards and buttons etc, but all I really need is a guide to make this happen. I hope someone can point me in the right direction.
“Smart button” can mean a lot of different things… maybe clarify the criteria for the type of smart button project you are considering.
Hi, I use smart buttons. I created in the settings->devices-> helpers a button. I created then an automation with this button as the trigger and link actions to it. Is this detailed enough. If not I can make a better guide tomorrow.
Isn’t this what scenes are for?
I made a couple of these buttons: ESP-01 IoT WiFi Button by Tommy_Tc - Thingiverse
Thingverse is great for getting stl files for 3D printing projects. But without a schematic “smart button” is still a nebulous universe.
Post the schematic and the code (in code tags) and you will get a lot more people willing to look at your issue.
Even just a detailed description of what you have and what you are trying to achieve would be better than giving us “homework”.
I will be using the following board:
I want to attach this many momentary switch buttons:
Those buttons will be attached to the following pins:
I need each button to have this many press options:
It doesn’t have to be that code. I just want to control a lamp with a ESP connected to a button and I’m looking for a guide that will allow me to do that.
Again. “Button” is remarkably vague. If you built the button in Thingverse, then what code did you flash to the ESP?
I haven’t flashed any code yet. That’s why I am asking if there’s a guide that covers this. I know this has been done loads of times before, but since I’m completely new to this I was hoping that there would be a guide that I could follow
There is a basic tutorial available from Kian.Smarthome on YouTube.
Connect a momentary button to ground and a gpio pin.
Configure it as per this. GPIO Binary Sensor — ESPHome
When you compile it and connect it to ha it will create an entity which will change state when you click the physical button.
That video is amazing. There’s literally only 1 flaw in that guide and that is that the board is on 24/7 so powering it with a battery won’t work without having to change it daily.
Search the esp home docs for ‘deep sleep’
Waking up when you press the button may not be fast enough, if so, look at ZigBee.
That is easy to do. I have a few around my house. The problem as you have already noted is that the ESP has to be on all the time or in deep sleep until you press the button. On all the time would exhaust a pair of AAA batteries in less than a day. Wake on a button press has an inherent delayas the ESP is basically rebooting when you press the button so you have to wait for it to establish a WiFi connection.
As @nickrout said, Zigbee would be best because it doesn’t draw power until you press the button and it sends its data almost immediately. Here is one that uses a magnet on a reed switch, and the battery lasts for months. You could unsolder the reed switch and put in your own pushbutton. There are also a lot of 433MHz buttons that are similar but they work at lower frequencies and have slightly etter range than the Zigbee.
Both solutions, however, have additional hardware requirements, but once the Zigbee Dongle or the 433MHz Bridge are installed on Home Assistant, adding additional buttons, switches or sensors is easy.
Beside solutions that are low power already (like the mentioned 433) you might think of a cheap BLE Tag which has a button.
If you want to stay with your esp design as a button you probably want to avoid WPAx TCP/IP WIFI completely as it sucks your battery like crazy. Instead switch to something like esp-now which is optimized for low power but not yet available in esphome stable (but custom components are floating around).
This is the one i made, it uses a d1 mini and usb power so not wireless though.
Other then that i use a zigbee button that has 3 options, short long and double press:
I love it when people change the parameters after the solution.
How do I do x with z?
Oh you do a and b.
But that won’t do y ?
When multiple people take the time to ask you to clarify your request like Stephen, Nick, and I did, please take some time to make sure you are asking a Good Question