Medicine alarm (Internet Of Things) (Unfinished)

This blog post is for the IOT (Internet of Things) workshop -course in the Haaga-Helia university of applied sciences.

Introduction

This week I took part in a Internet of Things workshop that was arranged by Tero Karvinen and Haaga-Helia university of applied sciences. The primary focus of the course was to learn the basics of IOT development and build our very own ”Thing”.

My colleague Lassi Koivusalo and I decided to build a small device that alarms if you have not taken your medicines for the day. The point of this device is to help elder people with diseases in their day-to-day lives and to inform their relatives by email if they have not taken their pills that day.

Part 1:”The Thing”

When we first started building the device we had no idea what we were doing us neither of us had any experience in building an IOT device so it all new to us. And as neither of us was a programmer it took us quite some time to get our heads around the whole thing. But we noticed rather fast that C++ is rather similar to Java so we were able to get our heads around it.

So first off we collected the components we thought we would need in this project. They are listed below:

Components

Arduino Duemilanove (with ATMEGA328 processor)
FSR402 (Force Sensitive Resistor)
1 x Red Led
1 x Green Led
1 x 10k ohm resistor
2 x 220 ohm resistor
Empty Ice-Cream box

After we had those we started testing with simple setups such getting a led blink etc.

Part 2: Writing the code

As I have mentioned above neither of us is a programmer so this was the hardest part for us. But eventually we were able to code enough code to make the ”thing” do what we wanted. Here you can see the entire code and after that I am going to separate and explain what each part does.

SOURCESCapture

 if (fsrReading < 10) {
 digitalWrite(greenPin, HIGH);
 digitalWrite(redPin, LOW);
 x = 1;
 Serial.print("GET http://139.162.200.127/add/Abe3YZJB95U/?x=");
 Serial.println(x);
 delay(1000);

If the there is not any pressure applied to the sensor the green led stays on and the program sends a constant stream of ones to the domain meaning that everything is ok.

 } else if (fsrReading > 10) {
 digitalWrite(greenPin, LOW);
 digitalWrite(redPin, HIGH);
 x = 2;
 Serial.print("GET http://139.162.200.127/add/Abe3YZJB95U/?x=");
 Serial.println(x);
 delay(1000);

Here there is pressure applied to the lid of the device so it turns off the green led and turns on the red led. Also the program sends a constant stream of twos to the domain telling that you have not taken your pills that day. At this point the software is not meant to send an email to the relatives.

 if ((unsigned long)(currentMillis - previousMillis) >= interval) {
 for (int i = 0; i < 25; i++) {
 digitalWrite(redPin, HIGH);
 delay(100);
 digitalWrite(redPin, LOW);
 delay(100);
 
 }
 previousMillis = millis();
 }

Here if there is still pressure on lid after ten seconds (this can be changed, we set it for ten seconds because of testing purposes) of the meds being on it the red led starts blinking fast. At this point the software is supposed to send an email to the relatives telling that the person has not taken their pills that day.

As a connector to the domain we used code provided to us by Kimmo and Tero Karvinen. The code can be found here. Download the BotBookAPI  server code v.1.04 and the file can be found inside botbookespy ->botbookesp.py.

Unfortunately we were not able to set up the email because we both ran out of time and did not have the know how how to actually do it. But we are actually planning on continuing this project because it is rather interesting to build this stuff and we want to finish what we started.

Part 3: The hardware

Setting up the hardware was far more enjoyable compared to programming. Below you can see some pictures of the actual setup


Sources

http://iot.botbook.com
http://terokarvinen.com/2017/create-interent-of-things-for-8-eur-esp8266-12e-and-arduino

Advertisements

Vastaa

Täytä tietosi alle tai klikkaa kuvaketta kirjautuaksesi sisään:

WordPress.com-logo

Olet kommentoimassa WordPress.com -tilin nimissä. Log Out / Muuta )

Twitter-kuva

Olet kommentoimassa Twitter -tilin nimissä. Log Out / Muuta )

Facebook-kuva

Olet kommentoimassa Facebook -tilin nimissä. Log Out / Muuta )

Google+ photo

Olet kommentoimassa Google+ -tilin nimissä. Log Out / Muuta )

Muodostetaan yhteyttä palveluun %s