You are on page 1of 13

technology workshop craft home food play outside costumes

Emergency Button for 7$, Arduino, WIFI and ESP8266


by jeanotP1314 on November 5, 2015

Table of Contents

Emergency Button for 7$, Arduino, WIFI and ESP8266 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Emergency Button for 7$, Arduino, WIFI and ESP8266 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: How does it work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Part list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Programming your board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4: Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 5: Device Board Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 6: Prototype Board Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 7: Battery Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 8: Covering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 9: How to improve the project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 10: Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

http://www.instructables.com/id/Emergency-Button/
Author:jeanotP1314 author's website
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 few years, i
am very happy to inspire new people with my work now!

Intro: 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.

http://www.instructables.com/id/Emergency-Button/
Image Notes
1. SolidWorks design looks really smooth :)

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

http://www.instructables.com/id/Emergency-Button/
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.

Image Notes
1. Remove the uC to speak directly between the computer and the ESP8266
2. The RX/TX wire seems inverted... but they are not. It's because you are not
talking to the uC

http://www.instructables.com/id/Emergency-Button/
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.

File Downloads

Emergency_Final.zip (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Emergency_Final.zip']

Emergency_Final_Programer.zip (2 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Emergency_Final_Programer.zip']

http://www.instructables.com/id/Emergency-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.

Image Notes
1. Adapt the value of this resistor depending on how bright you want your LED
2. Once the board has been programmed, you don't need RX and TX anymore
3. The button cut the Enable signal and force the device to get out from
deepsleep mode and restart
4. Any LED you want, adapt the color as you like :)

Image Notes
1. First integration test, those pin have to be removed to fit, but they are useful
for programing

http://www.instructables.com/id/Emergency-Button/
Image Notes
1. Some male/female header to be able to charge the battery
2. CMS resistors 1206

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.

Image Notes
1. Very useful 3 pins header, you can easily change the value with a jumper (see
next pictures)
Image Notes
1. Jumper to switch the positions between pull up and pull down

http://www.instructables.com/id/Emergency-Button/
Image Notes
1. Not very clean circuit... but functional!

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!

http://www.instructables.com/id/Emergency-Button/
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. ;)

Image Notes
1. This is not a button, just a design part

http://www.instructables.com/id/Emergency-Button/
Image Notes
1. I had to print a little top for the button to make it easier to press

http://www.instructables.com/id/Emergency-Button/
Image Notes
1. the CAO design didn't have a hole for the LED, i had to make a 3mm hole
manually with a flat top LED
2. the CAO design didn't have a hole for the LED, i had to make a 3mm hole
manually with a flat top LED

File Downloads

Bottom side.STL (552 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Bottom side.STL']

Button.STL (24 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Button.STL']

Top side.STL (1 MB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Top side.STL']
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. :-)

http://www.instructables.com/id/Emergency-Button/
Related Instructables

Wearable heart Use Arduino ESP8266 WiFi wireless logger Get Started with ESP8266 Wifi
beat sensor Due to program relay switch by ESP8266 ESP8266 Using Add on for
ESP8266+Pulse and test EasyIoT NodeMCU v1.0 AT Commands, Arduino Made
sensor by ESP8266 by with Arduino NodeMCU, or Simple by drmpf
yakirmalka anistor IDE by shinteo Arduino (ESP-
12E) by acrobotic

Advertisements

Comments
9 comments Add Comment

mquez says: Nov 6, 2015. 7:26 PM REPLY


Congratulations, this is a very well done instructable. Could you provide more details on the design of the case? Did you buy it somewhere? or is it printed? I
have been looking for something like this to make a similar concept but for tracking my children.

jeanotP1314 says: Nov 7, 2015. 12:49 AM REPLY


Sorry, i forgot to add them. The STL files are now on the Step 8.

Everything has been print on a Ultimaker 3D printer.

mquez says: Nov 7, 2015. 5:45 AM REPLY


Great! Thank you for sharing.

Borya says: Nov 6, 2015. 2:36 PM REPLY


Why everybody removing chip from Uno? It's way more easier just connect RESET pin to GND.

jeanotP1314 says: Nov 6, 2015. 3:16 PM REPLY


That's a good idea, I have been doing it for years and never tried that :s

Bighatgmw says: Nov 6, 2015. 9:29 AM REPLY


This looks fantastic, and I love the reaon behind it. The detail on your steps is great!
I did not see where the emails are generated from - does it trigger a group email from gmail, or are the addresses from smtp2go?
Also, many cellular providers (in the US at least) have the ability to process an email to a text for the receiver - this could greatly increase the response time
(Not waiting for someone to look at emails, but instead getting text immediately) - example is sending to address #PHONENUMBER#@txt.att.net will allow
an ATT user to get an email converted to text.

Overall I think this is spectacular!

http://www.instructables.com/id/Emergency-Button/
jeanotP1314 says: Nov 6, 2015. 10:17 AM REPLY
Hi,

thanks :)

Emails are generated from the ESP8266. On the code you have the function client.println() which send data to the smtp2go website. I send the
authentification to smtp2go and then the Email content and destination address. Then smtp2go send the Email to GMAIL with the specified informations
;)

I was actually considering trying to send text message, your solution could be great!! I ll do some research

tomatoskins says: Nov 6, 2015. 9:03 AM REPLY


I love this! It's so simple and elegant! Major props on your first instructable!

jeanotP1314 says: Nov 6, 2015. 9:12 AM REPLY


Thanks a lot! I hope my explanations in english are clear enough, it's not my first langage... :s

http://www.instructables.com/id/Emergency-Button/

You might also like