📜 ⬆️ ⬇️

TEETH based on Intel Edison will find a way to motivate you to brush your teeth and send a report to the cloud

It would be great if someone or something helped us to do daily, well, maybe not particularly entertaining, but important activities. Such as brushing your teeth. For example, such a device to encourage us, help monitor our progress and was very easy to use.

Tell me, do you always brush your teeth for 2 minutes?


')
In this DIY project, we will remake the usual, purchased in the store stand for toothbrushes into modern household appliances of the Internet of things.

The Intel Edison board has a small size and the necessary computing power to teach healthy habits - the proper use of a toothbrush and toothpaste.

I'm sure you already have the knowledge you need to develop for Intel Edison. Since this board contains built-in Wi-Fi and uses node.js to work with its hardware, you can program in JavaScript. This means that most web developers can use the Intel Edison board to quickly start programming for the Internet of things.

The steps described below show how to add switches, a screen, and sensors to remake any toothbrush holder in TEETH (Timer Encouraging Everyone To Health - the Timer Encouraging Everyone to a Healthy Lifestyle). The source shows how a fairly simple node.js project manages these components and connects to the Internet to use cloud analytics and send mail.

Using TEETH - Smart Timer for Toothbrush


First, remove your brush from the holder. This will prepare a timer that will wait when you start brushing your teeth. Then a two-minute countdown will begin, and the LCD screen will show you words of approval. Two minutes is the brushing time recommended by the American Dentist Association. The screen will change colors and captions until you finish. Do not worry if you brush your teeth with your eyes closed, a beep will sound at the beginning and at the end of the procedure. The timer will stop when you put the brush back on or when you turn off the light when leaving the bathroom. After that, the stand will save your timer data in the cloud. If you reach the goal, it will send an email with congratulations. Then you can go to the cloud and see the progress for each brush in the stand. You can keep track of these IoT data to encourage healthy habits of all households.

Shopping and Planning


Estimated project time: 2-3 hours.
Price: 75-100 dollars.

Details used in the project




Materials:


Instruments:


Steps


1. Stand preparation


I chose a bamboo toothbrush holder, so it was enough for me to simply cut the holes needed to install the components and place the wires so that they could not be seen from the front. The tools you need depend on the material of the stand. Well, or you can make a stand yourself.

Installing the LCD screen on the front wall


Cut a piece on top large enough to fit the entire LCD screen. Then cut a smaller hole in this piece for the screen itself. Glue the resulting part back into the stand.



In addition, you can simply screw all the components outside. It depends on your sense of beauty. But no matter how you do it, the main thing to remember is that the wires from your screen can reach the Intel Edison board, which will be attached at the back.

Add a button to the bottom of the stand


Any sensor that can detect the presence of a brush will do. I chose a button with a lever, instead of some kind of IR sensor, to minimize consumption. However, the toothbrush weighs only 15 grams, so you need a sensitive enough sensor.

Since the switch is small enough, I added a plate so that the toothbrush could be left anywhere on the stand. I cut a plate from the plastic partition from the toolbox (it seems to me that I always have more of them than I need, so I just took one of them). Solder the wires to the switch. One wire to a common pin (ground) and one to a normally closed.



Due to the fact that pressing the back of the button does not trigger, I set the button so that its back was actually inside the wall of the stand. As with the LCD screen, make sure the wires reach the main board. I drilled holes in the back of the stand, so the wires are mostly not visible.

Adding light sensor front and rear tweeters


Prepare the light sensor and the squeaker by soldering the connecting wires of sufficient length to reach the back wall where the main board will be located. I drilled a hole in the front, sufficient for the light sensor. Its front location allows you to accurately respond to lighting in the room. Behind me, I cut a bigger hole for a tweeter. Such an arrangement will minimize the appearance of the stand and make a loud sound in the morning.



Protect sensitive electronics from water


Since the device will undoubtedly fall in a humid environment, it is necessary to take precautions to the connections. Use silicone or some other sealant to cover unprotected electronics and wires. I used quite a lot of sealant for the back of the LCD screen. But make sure that you do not cover the switch itself so that it can work well.



Connection of components to the mainboard


The first time I created this project, I used a prototype board to test my board and connections. You can do this before you take the final steps.



Use the following circuit for connecting components to pins on the circuit board.



Most of the elements are connected directly, but I had to add a 10 k buckling resistor to reduce the noise of the buttons and get rid of the false trigger.

Note per. - You have four ways to connect buttons. But depending on their connection, you may have to change the source code, since it is configured to appear "0" when you press the button:


The photoresistor is connected according to this scheme:


Add an Intel Edison processor module to the main PCB. The iron part of your project is almost finished. Soon we will add a battery. At the moment your project should look something like this.



2. Preparation of Intel Edison Board and Cloud Service


The launch of the Intel Edison board is described on the Intel IoT website. To connect the computer to the board, follow the instructions http://intel.com/Edison/getstarted

Wi-Fi setup


Since our project uses Wi-Fi to connect to the cloud and send mail, it will be necessary to connect the board with a Wi-Fi router. This is fairly easy to do using the configure_edison utility, which is already on the Intel Edison board. More information can be obtained from intel.com/Edison/getstarted

Setting up an IoT Analytics account


This project uses the Intel IoT Developer Kit Cloud-based Analytics to store data in the cloud. You can set up an account at https://dashboard.us.enableiot.com/v1/ui/auth#/login

Add components to the cloud


After you register your Intel Edison board with IoT Analytics, you must prepare a cloud for your data by creating special components. Create one component for each toothbrush. The names you give to the components will be the names that appear in the report. Follow the instructions for creating components https://software.intel.com/en-us/intel-iot-developer-kit-cloud-based-analytics-user-guide

Registering Components on the Intel Edison Board


When components are created in the IoT Analytics dashboard, you need to register them on the board. The names that you use in this step will be used in the source code that sends data to the cloud. Here is a link to similar instructions for registering components on the board https://software.intel.com/en-us/intel-iot-developer-kit-cloud-based-analytics-user-guide

Running Intel Agent on Intel Edison Board


Intel Edison Board uses the built-in service to interact with the cloud. This service must be running for the program to connect and send data. After you follow the instructions at the link above, you can test that the board can connect to the cloud and send data to your components.

3. Intel Edison Board Programming


Well, since the hardware and services are ready, it's time to load the source code TEETH

Connecting to the board from Intel XDK IoT Edition


The Intel XDK IoT Edition development environment allows you to build Node.js projects on the board. It comes with a bunch of sample projects. Documentation is available here https://software.intel.com/en-us/html5/documentation/getting-started-with-intel-xdk-iot-edition

Download program


Download or clone the source from GitHub. Files have the structure of a small node.js project https://github.com/ncarver/TEETH


SMTP service setup


At the beginning of the main.js file, several constants are defined. You can change them to match your home environment and your preferences. At a minimum, you need to change the values ​​for MAIL.user, MAIL.pass, and MAIL.brushTo. These properties determine how the SMTP mail server connects to the Internet and where to send the letters to TEETH



Use of registered analytic component names


Use the names you registered in the IoT Analytics control panel in the constants section, METRICS.brushComponent. This is an array of all components used in your project. I have it consists of two elements.



More, more toothbrushes


If you have built a stand for more than two brushes, you will need to change the section of constants to match this code. The code uses an array of structures with brush-specific values. Add additional array elements for each brush, such constants as: METRICS.brushComponent, MAIL. brushTo.PINS.brushSwitch, SCREEN_MSG.brushName, TIME.brushPreptime, and TIME.brushGoaltime.

4. Parsing the source code


Although it was possible to split the project into several files by modules, it seems to me that it will be easier if everything is in the same main.js file. This project does not require a lot of code, so additional files can only complicate understanding.

Required Libraries


Since we have a node.js project, additional modules are used to interact with hardware, the analytics daemon, and mail.

constants


This is the only section in which you need to edit something. Change these constant values ​​to change the color of messages on the screen, the text of letters and time intervals.

timers


For simplicity, all timers are stored as global objects. This allows you to always have access to timers when calling methods from setTimeout and setInterval.

Logger


The Logger class displays messages to the console, using the traditional approach to reduce errors, warnings, and information.

Sensors


Using the Sensors class, you will see how easy it is to work with I / O pins. The state of the switches under the toothbrushes and the value of the photoresistor are read in this class.

Buzzer


Most of the code in the Buzzer class is needed to play a chirping sound and is used when starting and stopping the timer.

Screen


The Screen class is responsible for all commands to the LCD screen. He has two responsibilities - to show text messages and change the color of the backlight.

Mailer


The Mailer class uses nodemailer to send mail using SMTP. It contains error checking if it is impossible to send a letter.

Metrics


The Metrics class uses a local socket on the board to send analytic data to the iotkit-agent daemon. If a connection error occurs, an error message is sent to the console.

Teeth


This is the main class containing all the logic of the project. Teeth calls the Sensors class to monitor buttons and lights, the Buzzer class to play sound, the Screen class to display messages, the Mailer class to send mail, the Metrics class to update the IoT Dashboard. If you want to change the capabilities of your device, you need to update this code.

5. We are testing


Spend some time testing the board and the brush stand while they are connected to the computer. This is the easiest way, as you can see the console output.

Check sensors and display


Use the Install / Build button in Intel XDK IoT Edition to download the source code to the board and run NPM to build the node project. Click the Run button to start TEETH

Test the stand using a toothbrush for each button on the stand. You should see the LCD turn on and you can monitor the console output. Also the beeper should beep and the timer should turn off if you close the light sensor.

Mail check


Let the timer count to the end to send the letter. Depending on your services, you should receive an email in your inbox in a few minutes.

View Analytics


Use all the toothbrushes on your stand to test each button. Log in to the control panel to make sure that you see all the configured components.

6. Add power


Finally you are ready to disconnect the Intel Edison board from your computer and place the brush holder on the sink in the bathroom as a standalone IoT device.

Battery connection


Use a battery with a USB connector to power the board. I was given such a conference. It is designed to charge a cell phone, but it works great in this project. I left its USB port available for charging.



Final step


Remember that our project works in a humid environment. Take all precautions to protect the battery and the board as well as other sensitive electronics. This is a picture of my final device.



Moving on


In this project, we have just begun to take advantage of the use of wireless Internet and cloud data on the Intel Edison platform. The source code can be easily modified to use other technologies. Maybe you want to send a tweet instead of a letter. Or you want to use another cloud service instead of IoT Analytics, for example, Xively. Even the sound of starting and stopping the timer can be replaced with your favorite mp3 file, which will be sent to the speaker. You can quickly make these changes by simply replacing one module with another that you want to use.

But this clever brush holder can be made even smarter. For example, as home systems Nest. Now the data is only transferred outside to the cloud, but taking this data as input to the timer, it will become a learning tool. For example, if you never clean a full two minutes, the timer will set a shorter target, and will increase it little by little with each success. And instead of using fixed time intervals, a sensor that responds to the external sound of brushing your teeth can adapt to your habits. But even without any additions, this is a big project to bring IoT to a rather important room in your home. Think it might be the first part of the “Bathroom 2.0” movement.

about the author


Nathan Carver came to the IoT area by a winding road. Starting as a clown at Ringling Brothers, he is now vice president of engineering at Crisp Media, a mobile advertising company where he works with web and big data technologies. Previous work included launching a professional services department, setting up a software company, playing music on a saw ( “Singer and Saw” ), and sailing along the Hudson River. He lives in New York. His other projects are available on Github .

Source: https://habr.com/ru/post/260565/


All Articles