Introduction: Emergency Button for 7$, Arduino, WIFI and ESP8266

Picture of Emergency Button for 7$, Arduino, WIFI and ESP8266


There are a lot of projects today trying to help aged people to stay more independent. As my grandmother is now 95 and she still lives by herself in her apartment, I wanted to check how I could help her staying at her place as long as possible.

One of the main problems for old age people is keeping their balance while walking. It is getting more and more difficult to move, and if they fall down it's very complicated to get back up. My family is calling my grandmother every evening to check for this kind of problem. There are some emergency buttons that can help, but you often have an expensive monthly payment for the call center. In addition, most old people don't like to wear some gray plastic technologies around their neck.

So my question is :

How to make a device cheap, reliable, easy to integrate, discret and with no monthly payment?

Step 1: How Does It Work

In most apartments today, you can easily reach 10 or 20 wifi connections. So I decided to build a wifi connected device, which make things easy to communicate with the external world. As a lot of old age people don't actually have a wifi, i decided to ask the neighbors for wifi access. Most of them were very happy to help and even asked to add their Email address to the list so they can quickly help in an emergency.

If a person is in distress for a reason, he or she has to press a simple button on the device. A LED turn on to confirm the emergency is activated. The device will connect to the internet box and send an Email to a pre-entered Email address. As a lot of people receive Email on their phone and check their phone 30 times a day (like me :s), the emergency can be quickly followed by calling the person or knocking at the door.

The device has to be easy to wear and to integrate. Therefore, it was important to reduce dramatically the size and the weight. As a result, the device is 2.5 * 1.5 * 1 cm in size ( 1*0.6*0.4 inch) which can be easily integrated to bracelets, necklaces or clothes. As some aged people are trembling a lot, the button is quite big, which makes it easier to press.

The price is also a very important question. If you want to make a wifi connected device today, the ESP8266 board is a very good choice! It costs only a few dollars and it has its own 32bit reprogrammable micro-controller (The Atmega328p on the Arduino UNO is only 8bits). A big community is now using this device and it recently became Arduino IDE compatible.

The electronic cost is around 8$ which is affordable for most people and you have to add a battery of your choice. All the components are easy to find and to adapt if you want to make a new design by yourself. A standard 110 mA battery should work more than 2 months, a CR2032 for 5 months and a 1000mA for 2 years.

Step 2: Part List

Picture of Part List

For this project, i used the cheapest and smallest components I could find. The ESP8266 is a great tool for any microcontroleur/wifi application today. Plus, it's now Arduino compatible!

As i was adding program inside the ESP8266 100 times a day, I decided to also build a user-friendly programmer. You actually don't really need it if you don't want to change a lot of thing on the code.

Device Part List :

  • ESP8266 7$ uC, Wifi and Wifi antenna.
  • Button 0.5$ choose the one fit the best in your model, I used a "pushbutton 12*12*8cm".
  • LED 0.35$Resistor 0.02$ (I used a flat top 3mm bought on Ebay)
  • Battery 6.95$ In a bigger device you could use a CR2032 to multiply the autonomy by 2.3 or even this bigger Battery to multiply by 9 !
  • SMTP2GO Account FREE. It forward the mail between the device and your mail account (the Free version is limited to 20 mails a day).
  • Email Adress FREE. I used a GMAIL one with this code.

To program your device, you gonna need a few wires and :


  • Arduino board with removable chip like UNO (but not the SMD version!).

On the second part of this Instructable, I explain how to make a more reliable programmer. You need to add the following components if you want to build it :

Step 3: Programming Your Board

Picture of Programming Your Board

There are many ways to program your ESP8266 board :

The most important component for programming is a Serial to USB converter like the FTDI FT232RL. You can find one in a special device like a FTDI board but you also have one in every Arduino Board that you can program over USB (On the UNO the FTDI has been replaced by a 32u2, but it worked exactly the same).

If you have a UNO board for exemple, if you remove the microcontroleur you can use the RX, TX, GND, 3.3V Pin to reprogram the ESP8266. Of course, the Arduino board has to have a removable chip...

The second important note is you have to change the GPIO 0 Pin to be able to program (Ground state) and use (3.3V state). It's sometime a bit confusing because after programing the new device code will start automatically even if GPIO 0 is still grounded. But if you restart the program you have to make sure that GPIO 0 is 3.3V or it will not work!

So with few wire, an Arduino UNO you can program your ESP. But this technique can easily give you headache if you are programming the board a lot, because when it's not working or when you need to add other components you never know if the problem is hardware or software... So you spend a lot of time checking if no wire got unplugged or plugged in the wrong place! That's why I have built a prototype board.

Step 4: Software

Picture of Software

The first thing to do is to install the Arduino IDE for the ESP8266. You have all the information you need here

Now we have the programer for the board, we have to take a look at the software. The device need to connect to the WIFI network and send a Email throw SMTP. As GMAIL (and many other Mail serveur) doesn't accept SMTP protocol, i used a SMTP2GO server as a mediator. So the device send a mail to SMTP2GO and then it is forwarded to your Email account. To open an account on SMTP2GO, it's free and take only few minutes.

As this project is using Internet connection over Wifi and need to send Email, we have to change few lines of code for every applications. In this case it's gonna be all the places with some ******** on the code :

- Your SSID of the internet box, the name of your wifi network

- Your password of the internet box (WPA2/PSK in mine), so the device can connect

- Your network setting, you have to add a fixed IP address on your internet box corresponding to the MAC address of the board. You can also program your board and read with the Arduino IDE on Serial and see when the device connect. The IP address will appear. (The problem is, it can sometime change, depending on the internet box). I think those line are actually not really useful :s

- Your Email Address, to receive Email from the device. I used a GMAIL account and it worked fine, you have to check that your mail address is compatible with SMTP2GO.

- The mail address and the password of the smtp2go account in base 64. You have to translate it from this website for exemple

- You can also change the object and contents of the Email.

Once you have done this, you can compile your file and send it to the ESP8266. Now, every time the ENABLE PIN is getting LOW and then HIGH the device will restart, turn the LED ON, connect to your Wifi, send a mail, turn the LED OFF and go to a sleep mode. The process can take between 10 and 30 seconds depending on how fast it connect.

The only difference between the device code and the programer board is in the second one, it send a mail only when you press the button.

Step 5: Device Board Assembly

Picture of Device Board Assembly

So, now the ESP8266 is programed, it's time to build the Hardware part of the device.

The circuit is quiet simple, I drew a schematic on Fritzing to understand how the components are connected. You can adapt the 1k resistor (brown, black, red) depending on how bright you want your LED.

Step 6: Prototype Board Assembly

Picture of Prototype Board Assembly

How to build a good and stable programer board?

As i said in the Parts List, it can be useful to build a programer board to ease the communication with the ESP8266.

Here is the components I used :

- A protoboard to solder the components so everything has good and reliable connection,

- Two buttons : one for the Enable (to reset) and one plugged on the GPIO Pin 2 (if you need to easily control an action, in my case "Send a mail") One LED on the GPIO Pin 0, it can help a lot on debugging. Plus in my case, it show that the sending mail action is processing.

- Two male Header to switch from Pull Up, Pull down and nothing for the GPIO Pin 0 and 2. The GPIO 0 configuration is essential to load a program on the ESP8266. I used a three Pin Header and I plugged the GPIO in the middle and change a Jumper positions depending on what i need. I also used some angle Male Header to be able to plug the power supply and the FTDI board.

- Some Female Header to plug the ESP8266.

- A regulator and a 10uF capacitor to have a clean 3.3V signal. The ESP can have some 200mA power peak, it is way better to have an external power supply than use directly the one from the FTDI. Lots of people have reboot problems with the ESP8266. The power stability is a first key to avoid this. You can power with a 5V power supply or USB, but also with a 1cell 3.7V Battery (I used an old Iphone cable at the beginning and then a Battery) On the pictures you can see how i plugged all this.

Now we have a nice little device, that send mail and turn LED when you push buttons. The second code I posted is for this programer. The only difference is it read the GPIO Pin 0 and connect only if it's pushed. So you can control better when you want to activate the device.

Step 7: Battery Management

Picture of Battery Management

In every embedded device, you always ask yourself a question : how long will my device be autonomous?

To answer this, we can go in this tutoriel. The 7.1 section of the technical documents seems to specify a consumption of 75mA when it's operating and 60uA in deep sleep mode. But this tutorial also add a very important information : the LED consume around 8mA which is huge compare to the 60uA we are trying to reach. So the best solution is to unsolder those two onboard LED (specially the power one, which is ON all the time!).

When you start the device with the code, it will turn the LED on (on GPIO 0), connect to the wifi and send a Email. And then we call the function :

ESP.deepSleep(0, WAKE_RF_DEFAULT);

This will set the ESP8266 into a deep sleep mode with no waking up (the 0 here means no wake up). The button is solder on the ENABLE line of the ESP8266, so when it's pushed the all system restart. In this solution we don't need any other hardware modifications than the unsolder LED to reach our deep sleep mode.

A delay is following the deepSleep function, it's important to let the uC the time to enter in the sleep mode. Without this it will probably not sleep.

If we calculate now the autonomy in a ideal state when we don't press the button with a full 110mA battery:

Time (H) = 110 000(uA) / 60(uA) = 1833 hours.

1833 / 24 = 76 days

On a CR2032 accus which has around 250mA we can reach around 173 days so almost 6 months

On a 1000mA battery we have almost 2 years!

With those calcul we can see how the choice of the battery is important when you design a device!

Step 8: Covering

Picture of Covering

I really like drawing electronic project, but I have to admit that it's not very esthetic... especially for aged people.

A friend helped me to find a CAO of a band and to draw with SolidWorks the top and bottom part. The device perfectly integrate in this "watch shaped" plastic cover with the 110mA battery. As it's been print on the side, the band is really strong and flexible.

I little bit of painting give a final touch to the housing. ;)

Step 9: How to Improve the Project

When i am designing a project, i feel like it's never gonna be done... the longer you work on it, the more functionalities you want to add! Here are some ideas :

- The button hit the Enable signal, which means if you press it every few seconds, the message is never gonna be send until you stop! An interrupt would be better, but in this case we can't come out from deep sleep mode. Another solution could be designed.. But i am not sure it can be done with those chip.

- To add or change your mail or internet box configuration, you have to reload the entire code in the chip. A configuration mode could be designed to push this information through the WIFI for example.

- We could add a recharge circuit for the battery.

- A low battery indicator could be nice too. If we use the ESP8266-12 for example, we have access to more Pin. We could easily add another LED with a red color to warn from low battery.

- The integration of the electronic is a bit difficult right now with small wires and resistors, I could design a little board to ease the solder.

Step 10: Conclusion

Picture of Conclusion

I hoped you all enjoyed my first Instructable.

As you can see on the last step, there is many ways to improve this little device... If you have any ideas or any questions, I ll be glad to work with others people on making it more reliable and efficient.

I ll present the results to my grandmother next week and probably post some new pictures soon. :-)


MichaelB247 (author)2017-05-24

This is an awesome instructable. Very clever. One thing to note that may be of help to some who have tried to get this to work unsuccessfully: the LD1117 3.3V voltage regulator has quite a high dropout voltage, almost 1V, so for a 3.7V Li-ion battery, this means a drop to about 3.2V on a full charge (which is around 4.2V). This means that your ESP will work when the battery is fully charged but will begin to fail when it drops below 3.8V or so. A much better voltage regulator is the MCP1700, which has a dropout voltage of 0.178V and provides 250 mA which is more than enough for most ESP applications. It's also much smaller :)

jeanotP1314 (author)MichaelB2472017-08-29

Thanks for the advice! I will buy few MCP1700 to run some test ^^

hemanth kumar reddy (author)2017-03-14

Can you plz look at this

small help thanks

Slash09 (author)2017-01-01

Why you dind not connect VCC of the FTDI USB to the capicitor ?

here is mine ...i dont know where i will connect the VCC of the FTDI !!!!

does the openLog wires are True or not ? and the auther GPIO ?

and how to add the battery after programming and removing the FTDI ?

i'm beginner :) i need help and thx lot brothers

jeanotP1314 (author)Slash092017-01-02


Your schematic seems to have a little problem. The input VCC and the ground are linked. Is your regulator 3V or 5V? A three volt regulator transform a higher voltage to a smaller one. For example a 3V regulator will transform 4V ( or more as input) in a 3V.

You want your circuit to be able to charge the battery when the USB is plugged, and use the battery when the USB is unplugged? In this case, you are going to need a battery "switch" to make the electricity goes in the good direction... (for example a MCP73831T).

Using an ESP with an FTDI board directly powered by the VCC is a bit unstable. The FTDI board isn't suppose to give enough current to power the ESP. Adding an external power supply is a better solution.

Slash09 (author)jeanotP13142017-01-02

i fix some wires...what about this diagram ....this diagram is when flashing the ESP will be Power up by FTDI USB (3.3v) ..does it is enought or must add a battery but this will be dangerous on the components !!!

Also i have problem with the Blue Led it must light when the send Data Button in ON ..does it is possible to add Led+push button is same Gpio when the led=digital output and the pushButton= digital input !!!!! ???

jeanotP1314 (author)Slash092017-01-03

If you power your device from FTDI, you will sometime have problems when you send datas. The device will disconnect because it drain to much power...

If you want to add a battery, to use your device autonomously, you can check this board. It uses a very nice way to switch between the USB, the battery and the circuit

For the blue LED. I don't think you can wire it this way. Basically you added a pull up to a pin of the ESP. So this Pin is HIGH. When the button is press, the ESP pin is Low BECAUSE of the resistor with VCC.

This resistor has to be pretty high (we usually use more than 10kohm). If the resistor is too low, the circuit will be shortcut when you press the button.

As you need a big resistance, the LED can't be powered...

hemu.katiyar (author)2016-09-19

getting error:

334 VXNlcm5hbWU6

334 UGFzc3dvcmQ6

Sending From

535 Incorrect authentication data

sthanet (author)hemu.katiyar2016-12-21


I have the same problem. Can you fix it?

jeanotP1314 (author)sthanet2016-12-21

Hum, I have to do some testing.

Can you give me more details? You have uploaded the code on the ESP8266 and connected it to your internet network? Or not yet?

sthanet (author)2016-12-21

Hi Jeano,

getting error:

334 VXNlcm5hbWU6

334 UGFzc3dvcmQ6

Sending From

535 Incorrect authentication data

shivayla (author)2016-05-12

nice...good explanation and clarity is awesome...

jeanotP1314 (author)shivayla2016-11-05

Thanks ^^

nodoubtman (author)2015-12-20

Hi. Nice project :

what is : EHLO


thank you :)

jeanotP1314 (author)nodoubtman2015-12-22

Hey, thanks!

I forgot to mention, you have to add your IP address there. I am not actually sure what the word EHLO stand for...

chrisqaq (author)jeanotP13142016-03-22

In case anyone are still interested, "EHLO" is a command using in the email protocol (smtp) for identifying yourself. The server will then respond with its capabilities.

jeanotP1314 (author)chrisqaq2016-03-22

Didn't know that! thanks :)

t0bi (author)2016-02-26

Hi Jean, I got an email, so everything is OK!!! Thank You!

I moved the block "byte sendEmail()" before the "void setup()", as You mentioned, but it was not enough. I had to move the block "byte eRcv()" and the block "void efail()" . I have some more smaller problems, but I can manage them.

How can be upgraded this program, that can send an SMS to a phone?

Thanks once again.


jeanotP1314 (author)t0bi2016-02-26

I am glad I could help ;)

I didn't work on the process on sending text message yet, but there probably many possibility. You can check the comment from Bighatgmw on this tuto from 4 months ago, he was talking about this...

I have another big project to finish on the next few weeks, so i am not gonna have time to implement text message soon. But if you find any solutions, keep me in touch :)

t0bi (author)2016-02-25

Hi jeanotP1314, congratulation for the good idea, I want to make the same project.

I have some problems, please help me. I can not send the program (Emergency_Final) to the board, I get the following message:

Emergency_Final:44: error: 'sendEmail' was not declared in this scope

-so something is missing. Thanks!

jeanotP1314 (author)t0bi2016-02-25


I just checked my program and it seem that your Arduino compiler doesn't see the function sendEmail(). The function sendEmail() exist, it's on line 58.

Sometimes, the program doesn't check the function located under the setup and the loop. Maybe you can try to add the line

byte sendEmail();

on line 24. He should see that a function actually exist...

Is this doesn't work you can try to copy the entire function "sendEmail()" (from line 58 to line 127) and add it above the setup (line 24)

The program should see it

Tkdwn (author)2016-01-24

Nice project, consider this for upgrade!

It adds a periodic ping and continues to deep sleep. And it activates the "panic" segment of the loop only on button press.
For now im stuck without the best battery choice and becouse of that, didn't jet make a suitable housing.

My project:

jeanotP1314 (author)Tkdwn2016-02-04

Sorry for the late reply!

I didn't really work on the software the last few weeks, but i am very happy to see someone helping me to improve it :)

By adding a periodic ping, do you keep the wifi connection with the internet box? If yes, how often du you have to do it?


Tkdwn (author)jeanotP13142016-02-11

Nope, the device sleeps and consumes a bare minimum of energy, when it wakes up it connects to wifi network and sends a ping. the ping is there to ensure that the battery and the device are still working even tough the button is not pressed. You can experiment with deep sleep and put the optimal time delay for the ping, but if the device does not send a ping for a day, then the battery can die and you won't notice for a whole day.

skjha2k made it! (author)2016-01-31

Hello Jeano, I made it, it worked in 1st shot itself, without giving the MAC ID of esp. esp is able to send the mail by pressing RESET switch.

When the MAC ID is required?

jeanotP1314 (author)skjha2k2016-02-04

Great! Congratulation!! :)

I think the mac ID is useful when you keep a internet connection active. It's suppose to be the unique "hardware" ID of your device. As you are just connecting for few seconds, you don't have much risk of interference with another device with the same ID.

But I think it's still a good idea to randomly change it (if several people use my code to connect to smtp2go with this ID it could probably create some problems...)

vbarbosa (author)2015-11-26

I am sorry, maybe I am mistaken but isn't CR2032 a 3.0V batery ?

If so, It won't work, because it doesn't have enough power for the chip to connect to the AP right ?

jeanotP1314 (author)vbarbosa2015-11-27


That's a good question, I actually tried with a fully charged CR2032 and it worked, but sometime it randomly doesn't connect to the AP. So I guess when the battery is going to drop down it will get worse... The solution is probably to add two batteries in serial so you can have 6V.

arjandv (author)jeanotP13142016-01-07

Even that will not help you. The problem is the current. Those type of batteries can only deliver several mA. There are also 3V batteries like the cr2 or cr123 that can deliver much more current. And this is required because the Wifi chip can use approx. 200 mA at peak times.

mirocastroambr (author)2015-12-12

Great work! Congrats.
I've used your function sendemail in my project
Thanks a lot!

haha, so you built a communicating boiler?? That's cool :) Glad I could help!

SMTP2GO (author)2015-12-03

Thanks for the mention! We love being part of the Arduino community experiments. Feel free to grab yourself a free account with SMTP2GO - you can send 25 messages per hour and a total of 1000 per month. Paid plans offer more, of course! :)

jeanotP1314 (author)SMTP2GO2015-12-04

Thanks a lot, that's awesome!! I will definitely use your service in other projects!

ohoilett (author)2015-11-25

Really cool!

jeanotP1314 (author)ohoilett2015-11-26

Thanks :) :)

ohoilett (author)2015-11-25

Really cool!

DragNfLyDale (author)2015-11-12

Hey jeanotP1314

Great Instructable. Indeed it can be used in many practical situations with only the slightest modifications.

I have built the prototype board as per your fritzing image and have just a few questions before I add any load to this. Please do excuse my ignorance. I am a complete #ArduinoBeginner or noob as some might say ;-)

The buttons on your fritzing image. Are these not supposed to go in one end and out the other?

The red lead that comes from VCC and passes over the capacitor. Are these connected?

Your fritzing diagram shows 4 resistors where your build image only has 3. Very confusing for an #ArduinoBeginner

There seems to be no VCC (red line) on the fritzing image from the FTDI. Please indicate how this wiring should be done.

Looking forward to your response. Eager to power up.

jeanotP1314 (author)DragNfLyDale2015-11-12

Haha, it look nice :)

Q1: On many pushbutton the connection is like I show on the Fritzing. With a multimeter you can easily check if it connect when you press the button. (if you have no multimeter, power up a led and see in which position the current is passing)

Q2: Yes those two lines are connected.

Q3: I actually have 4 resistors. It's just that one is under the ESP8266 so we don't really see it on the picture..

Q4: the idea is to have an external power for the ESP8266. So you don't need to plug the one from the FTDI. The ground must be plugged so the ESP and the FTDI are based on the same power level.

Be careful with the regulator, there is so many of them and they don't have always the same connection, i can't see which one it is from your pictures. To check the datasheet of your regulator write " the name + datasheet" on google, it will tell you the INPUT(where 5V is entering), THE OUTPUT (The 3.3V for the ESP) and the GROUND.

Hope I could help ;)

DragNfLyDale (author)jeanotP13142015-11-12

Hehe, Thanks. many hours for me.

Q1: Thanks I will do this

Q2: Thanks

Q3: Cool

Q4: Very confusing for me. So in this image >
... your VCC is not wired up?

My regulator is LD33CV > It looks like the same pinout as yours?

Are you able to send me the fritzing design. I'd like to move things around as I have it wired up on my board and ask you more questions.

Currently the ESP does not power-up when I plug USB in. I have checked wiring many times over. I am not sure which of the pins to use and when. Can you elaborate on these please.

I am determined to get this working. Your help is appreciated.



jeanotP1314 (author)DragNfLyDale2015-11-12

Q4: yes on the picture, the circuit isn't power up. You need to add a 5V power supply. A one cell (or two) battery should work too.

DragNfLyDale (author)jeanotP13142015-11-12

So on the image ...where is this getting power from if it is not powered up. I understand that you need a 5V power supply but your image does not have one either. Surely the FTDI should be wired to the 5V.

You answered my question regarding the capacitor in a private message to me. I think it is imperative that you answer questions here on the instructable so others can see the mistakes I have made and learn from them. Your capacitor is is not the same as mine (LD33CV) so I will have to swop around my INPUT and OUTPUTS pins. I hope I have not fried anything. #WARNING to others trying to build this instructable.

Are you able to send me the fritzing design? I'd like to move things around as I have it wired up on my board and ask you more questions.

jeanotP1314 (author)DragNfLyDale2015-11-13


You can link the power from the FTDI. But it's not gonna be very stable as the FTDI cannot give enough current. But it will probably work as long as you don't transmit a lot.

When I tried to answer yesterday, the Reply button was not working to send a big text, that's why I sent you a private message...

I didn't give any references for the regulator, in this case you have to adapt your parts. Reading a datasheet of the components is very important if you want to understand what you are doing.. Never plug a circuit before checking how to use every component.

I add the Fritzing to the step 6 if you want to build your own design.

DragNfLyDale (author)jeanotP13142015-11-13

Thanks for your valued input.

Back to the drawing board. I will let you now when I make progress.

Have a great weekend


DragNfLyDale (author)2015-11-12

Also I notice there is no VCC line from the FTDI on your fritzing image. Can you indicate where this runs please.

Timofte Andrei (author)2015-11-10

This project could work inside a mail box and instead of that button you can connect a reed switch or a different type of switch to detect when there's something inside the box. :)

The ESP8266 can be used in so many different project. In few weeks playing with it, everything in my apartment is getting connected ;)

FadiJ (author)2015-11-10

Great job. It seems your work is more than just amateurish. It looks professional.

jeanotP1314 (author)FadiJ2015-11-11

Thanks, But still a lot of work to do!

My friends told me the same ^^ I actually plan to use it like any professional device so I had to make it stable and good looking ;)

FadiJ (author)2015-11-10

Great job

What a great idea. And having the possibilty of no monthly fee is wonderful too because costs for many people are just too high. This is also good for not only the aged but many people suffer from illness that causes unstable balance. Great work jeanotP1314

About This Instructable




Bio: Born in the Alps, I love travelling, paragliding, trekking and, of course, designing projects. :) I learned a lot from open source project on the last ... More »
More by jeanotP1314:Virtual Reality on Raspberry Pi with BeYourHero!Healthy, Smart & Natural Air Cleaner with Arduino, WIFI and BlynkTouch Screen Coffee Table DIY With 32" TV and Low Cost CCD Sensor
Add instructable to: