Tiny ESP8266 Dash-Button (Re-Configurable)

1,168

18

20

About: I like eletronics, AVR's and 555timers. Mini Pumpkins! I also love jerky & ☕️.

Intro: Tiny ESP8266 Dash-Button (Re-Configurable)

This is a tiny ESP8266 based dash-button. It stays in deep sleep, once you press the button it performs a GET request to the specified URL and if configured also passes the supply voltage as a variable. The best part is that by simply bridging two pins you can make it enter configuration mode. Allowing you to change all the settings without reprogramming.

For following along this instructable I am assuming you know some things, like; how to solder, how to follow a schematic and how to upload a program and SPIFFS data to an ESP.

Step 1: Materials and Tools Needed

For this project you will need:

  • An ESP-01 (Obviously)
  • A 50mAh or similar Li-Po Battery
  • 2x1 female pin header
  • A 3.3V LDO (Highly recommend the HT-7333A, It has an excellent standby current of 4uA and 170mV dropout)
  • A tiny push button
  • Some thin wire (Wire wrapping wire works great)

You will also need:

  • An ESP programming board
  • A soldering iron / solder / flux
  • A desoldering pump
  • Tweezers and/or wire strippers
  • Sandpaper
  • Superglue

Step 2: Programming

This project is fully open source, if you want to modify the code it's on my GitHub. But there is no need to. This button can be reconfigured without reprogramming.

You can download the pre-compiled code here.

Just plug in your ESP programmer and your ESP8266(Remember to connect GPIO_02 to GND to enter programming mode) and upload the .bin file and the SPIFFS data.

It's very important to upload the SPIFFS data folder, without it the code will not boot. And after removing the pin headers having to go back to reprogram will be very tedious.

Step 3: How the Code Works (If You're Interested, Otherwise Just Skip)

When the ESP boots up, it reads and parses the 'config.jsn' file from the SPIFFS file system using the ArduinoJSON library. This loads up all the configurable settings into variables.

Then it checks to see if GPIO_03[RX] is connected to ground if it is it will enter configuration mode.

If it is not it will attempt to connect to WiFi and then the server. It completes a GET request and enters deep sleep to conserve power.

In configuration mode, you can set all the settings. (more on this on step 13)

Since saving power is essential here, if anything takes too long or if connecting to wifi/server fails, it will simply blink five times fast and then a long blink to indicate an error and return to deep sleep.

If it all goes right, it will do a short blink then a long blink. To show it succeed. Then enter deep sleep.

Still curious? have a look on my GitHub https://github.com/Gangster45671/IFTTT-Dash-Button

Step 4: Schematic

This should help you build it, during the next few steps.

Step 5: Desolder the Pin Header

First, be 100% sure that you programmed the ESP8266 correctly and 100% sure you uploaded the SPIFFS data.

Then the first step is to desolder the 2x4 pin header, this will let us make our button smaller. But it also means you can't reprogram without resoldering it. Make sure the program and SPIFFS are flashed.

You will still be able to reconfigure the settings.

This is a lot easier with a pointy soldering iron tip and a desoldering pump. My strategy is to first bridge all the eight pins with solder, then heat all of them at once and yank the header out with some tweezers. Then after removing the excess solder, I poke the holes from the top with the iron and suck the solder out with my pump through the bottom.

Step 6: Solder the Switch

Next, you will want to solder your push switch between GND and RST. In my case the button pins were just a bit too thick, so I had to cut them a bit thinner with some snips. Make sure the button sits flush with the board, otherwise it might break over time with the stress of being pushed.

Step 7: Connect CH_PD to VCC

To allow the ESP to run the code, don't forget to connect CH_PD to VCC.

Step 8: Remove the Power LED

The button needs to consume as little power as possible. And since it is always on, the power led would always be consuming ~4mA. This would reduce the battery life to twelve hours. So desolder it or snap it off.

Step 9: Solder Configuration Switch

To enter configuration mode, GPIO_03[RX] needs to be connected to GND. To make it easy to do so I soldered a little lever that can be pushed to the side to make the connection.

Step 10: Add the Power Supply, Regulator and Connector

This is the longest part of the build. You will need to solder the battery, voltage regulator and the charging connector according to the schematic.

To make it all fit within the tiny space under the ESP-01 I had to sand down the voltage regulator's TO92 package. Make sure to plan your layout before soldering, it will be very tight but should be still do-able.

If your battery is too big, you might choose to omit the voltage regulator. This will work but will risk damaging the ESP8266. It is only rated to go up to a maximum of 3.6V, but a fully charged LiPo outputs 4.2V. Proceed at your own risk.

Step 11: Superglue It Toghether

The last step to keep everything in place is to superglue everything in place.

Step 12: Charging

To charge your button you will need some sort of LiPo charger, I simply use a generic USB Li-Po charger board connected to the button via the charging connector. Be careful not to switch the polarity around.

Step 13: Configure

You are almost ready to use your button for the first time.

To enter configuration mode you need to connect GPIO_03[RX] to GND, this will be easier if you soldered a lever like in step 9. Then by pressing the button to reset the ESP, it should enter configuration mode. You can now disconnect the lever.

Then you can simply:

  1. Connect to 'ESP_Button' WiFi Access Point, with the password 'wifibutton'
  2. Visit http://192.168.4.1 to open the configuration page.
  3. After setting your values, click on the 'Save' button then the 'Restart'
  4. Your button will restart, perform the request and enter deep sleep.

Make sure to only type the hostname in the host field, no http:// or https:// and separate the rest of the URL in the URI fields.

Step 14: Try It Out

You should be all good to go, pressing the button will make your GET request.

The video above is my button connecting to my website and IFTTT, posting a custom generated tweet.

Setting up the GET request is out of the scope of this instructable, but you should easily be able to connect this to IFTTT or any other service. If you are willing to write some custom PHP code and host it on your own website like I did you might even be able to monitor the battery.

If you have any issues or need help troubleshooting please leave a comment down below.

Anyone is welcome to give ideas on how to improve this, like maybe a case? xD

Leave a comment if you are a Doctor Who fan, or if you ship Whoufflé.

Cheers!

Step 15: Update: 3D Printed Case

After some time using the dash button i've decided to make a case for it. STL and Fusion 360 files attached.

Share

    Recommendations

    • Fix It! Contest

      Fix It! Contest
    • Furniture Contest 2018

      Furniture Contest 2018
    • Metalworking Contest

      Metalworking Contest

    20 Discussions

    0
    None
    ShaunM57

    1 hour ago

    Could this be set to send a message to a MQTT broker?

    0
    None
    2BECKHAM2

    5 months ago

    Excellent project Ploopy.

    1) I've uploaded the .bin file from github to ESP01.

    2) Soldered CH_PD to VCC

    3) Connected Rx to GND and powered on ESP01.

    The blue led is blinking at the same time not able to view the 'ESP_Button' WiFi Access Point for me to configure.

    Please help. - Thanks in advance.

    16 replies
    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    Hi,
    Glad to know you are giving it a try.
    From my code, the ESP8266 only blinks the led if its trying to connect. When it enters configuration mode the led should stay on, without blinking.
    Double check your connection from Rx to GND.

    0
    None
    PloopyPloopy

    Reply 5 months ago

    If that does not work I would try to compile and upload the .ino sketch and open the serial monitor to see what is going on. I hope it works!

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    Many thanks for the quick response Ploopy. Will check again and update by uploading .ino with data folder. Is there any way to check the code and set up with wemos D1 before porting in to ESP01?.

    Thanks in advance and have a good day.

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    I've uploaded the .ino file. After the successful upload observed the below in serial monitor.

    ***********************************************************

    ...................Session Terminated. Giving up after 21 tries connecting to WiFi.

    entering deep sleep

    ***********************************************************

    Upon pressing Reset button:

    Button Booting...

    SPIFFS Content:

    FS File: /config.jsn, size: 195B

    FS File: /edit.htm.gz, size: 4.02KB

    FS File: /index.htm.gz, size: 1.51KB

    Parsed JSON Config.

    Loaded ssid: SSID Here

    Loaded password: Password Here

    Loaded host: examplewebsite.com

    Loaded IsIP: 0

    Loaded uri: /makemyrequest/

    Loaded WiFi Connect Persistance: 10

    Loaded GET Request Persistance: 10

    Loaded Send VCC: 0

    Loaded VCC Param.: batt

    Connecting to SSID Here

    ....................Session Terminated. Giving up after 21 tries connecting to WiFi.

    entering deep sleep

    Please suggest.

    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    Hi,
    It looks like it's not entering configuration mode. It's just trying to connect to a WiFi network that does not exist. Make sure your connection from GPIO3 to ground is there during startup, and that it's reliable. I've had it happen to me where breadboard jumpers are broken and you don't even know until something like this happens. It will say when it is in config mode in the serial monitor. Good luck!

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    Thanks for the quick response.

    I've tried connecting D3 of wemos to GND and restarted, observed junk character in the serial monitor (nothing printed in the serial monitor) even connecting through 10k resister as well.

    Should i have connect D3 through pull up resister or value of the resister to be changed?

    Suggest me to for any change of wemos pin?

    Thanks.

    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    Hi,

    The serial monitor should still work when GPIO3 is connected to ground. GPIO3 is RX so only receiving serial should be disabled, sending should still work.

    It's common to get junk printed out when you reset the board.

    You should not need a resistor...

    I would try to maybe swap the ground wire between RX and TX, the printing on your weemos board might be swapped (I've only tested on NodeMCU boards).

    As for changing the pin, if your using your weemos any pin should do.

    Pin out here: https://www.projetsdiy.fr/wp-content/uploads/2016/...wemos-d1-mini-gpio-pins.jpg

    One last thing, have a look at the built in led on the esp module. It blinks when connecting to wifi but it should stay a solid on during config mode. If that does not work you can try changing line 34 in my code

    from:

    //#define NOT_DEBUG //wether to enable debug or to show indication lights instead

    to:

    #define NOT_DEBUG //wether to enable debug or to show indication lights instead

    that toggles the led indication, which could have something to do with it.

    Lemme know how it goes, if it still does not work I can tell you which line to change to make it startup on config mode.

    Good luck

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    You are great....and thanks for the quick response. Will check as suggested and update. - Many thanks.

    0
    None
    2BECKHAM22BECKHAM2

    Reply 5 months ago

    Hi Ploopy,

    Observation when tested with NodeMCU:

    1) Upload successful with //#define NOT_DEBUG

    Serial Monitor:

    ..................Session Terminated. Giving up after 21 tries connecting to WiFi.

    entering deep sleep

    b) when restarted with D3 connected to GND. - No output in the serial monitor.

    c) Uploaded #define NOT_DEBUG and restarted with D3 connected to GND. - No built-in LED indication on the NodeMcu.

    d) The HTTP request is getting initiated successfully when the ssid, pass, host, uri in the .json file configured and uploaded, at the same time not getting initiated when the D3 is connected to GND.

    Thanks.

    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    That is weird, why is it not reading GPIO 3?

    Ok. Leave line 34 to //#define NOT_DEBUG

    and try this sketch to see if we can read the pin.

    void setup() {

    Serial.begin(115200);

    }

    void loop() {

    pinMode(3, INPUT_PULLUP);

    Serial.println(digitalRead(3));

    delay(2);

    }

    that is very peculiar...

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    Thanks, Ploopy for your help.

    Now its working fine with NodeMCU after changing #define CONFIG_PIN 5.

    Thanks again for the excellent project. Will port it to Wemos D1 and ESP01. Have a wonderful weekend!

    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    Glad to know it worked!

    Post some pictures of it with the 'I Made It' button above when you are done, would love to see it.

    0
    None
    2BECKHAM2Ploopy

    Reply 5 months ago

    Sure Ploopy. Testing with wemos D1 is completed and working. Once I am done with ESP01 will post the pictures. Many thanks again for the wonderful project.

    0
    None
    2BECKHAM22BECKHAM2

    Reply 5 months ago

    Hi Ploopi, I've managed to get this working in ESP01 as well. The issue was due to the wrong set of Flash Size: in the IDE. In fact, the ESP01 what I am using is 8Mb and changing the Flash Size: to less size really helped. The IDE has not given any warning or failure prompt for wrong Flash Size: setting instead has given 100% successful every time during upload.

    Many thanks.

    0
    None
    Ploopy2BECKHAM2

    Reply 5 months ago

    That should explain why it was acting weird. Glad it works now!