Introduction: Emergency Button for 7$, Arduino, WIFI and ESP8266
Hi,
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
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 :
- FTDI basic board and a 3.3V power supply (min 500 mA)
or
- 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 :
- 3.3V regulator
- Male Header (angle or straight)
- Female Header
- Capacitor 10uF and few resistors
- Proto board
- Battery connector
Step 3: 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
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
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
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.
Attachments
Step 7: 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
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
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. :-)

First Prize in the
Wearable Tech Contest
68 Comments
Question 3 years ago on Step 10
how can you buy this?
Question 3 years ago on Introduction
I cannot view the video. Is there another way to view or another link to follow? I would love to build this wearable! Many thanks!
3 years ago
Hi, i am new to this. What if I want use SMS instead of sending email? Much Thanks
Question 4 years ago on Step 3
Is there any way I can convince you to build and preprogram 3 of those for me to the point where we just have to add our Wifi and Email Information and ship them? 2 of my friends and I were looking for something exactly like that because we have little kids (under 4) at home and want to have something easy they can use to alert us if our spouses have emergencies at home without triggering the whole gamut of emergency services and/or expensive subscriptions. Only we wouldn't need armbands but just something we can mount on a wall with a big fat red button. We are willing to pay a reasonable premium for the effort of building and programming it.
5 years ago
wow this so cool, i have a simple idea , maybe you can help me, i have some wemos d1 and led and a tablet or android device, i would like for it to be able to push a button and do 2 things (1) send a notification to tablet or Android over wifi (same network)
(2) charge the led light to 1 set color
6 years ago
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 :)
Reply 5 years ago
Thanks for the advice! I will buy few MCP1700 to run some test ^^
6 years ago
Can you plz look at this
https://www.instructables.com/community/security-s...
small help thanks
6 years ago
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
Reply 6 years ago
Hi,
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.
Reply 6 years ago
i fix some wires...what about this diagram ....this diagram is when flashing the ESP ..it 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 !!!!! ???
Reply 6 years ago
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
http://www.theairboard.cc/wp-content/uploads/2015/...
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...
6 years ago
getting error:
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
Sending From
535 Incorrect authentication data
Reply 6 years ago
Hi,
I have the same problem. Can you fix it?
Reply 6 years ago
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?
6 years ago
Hi Jeano,
getting error:
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
Sending From
535 Incorrect authentication data
7 years ago
nice...good explanation and clarity is awesome...
Reply 6 years ago
Thanks ^^
7 years ago
Hi. Nice project :
what is : EHLO 176.189.221.155
??
thank you :)
Reply 7 years ago
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...