Introduction: 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
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)
- 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
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.
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 :
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
1 Person Made This Project!
- skjha2k made it!