TryEngineering Hands-on Activity
Mickey House
Our project called Mickey House is basically for tracking and taking care of small pets remotely when the owner is away. It is a smart house project designed for small pets which is mainly based on having the temperature and water level information of the smart house which your small animal would be living in.
The system designed for this smart house would be showing the values of the temperature and the water level in the house. If everything is normal with the house, if the temperature is okay and there is enough water in the house, it will not be sending you any notifications. However, if there would be an emergency case, lack of water, sudden changes in the values or abnormalities with the values, then the smart house would be sending you warning notifications via Twitter. This notification would be giving you a chance to have control and track the situation of your pet and also maybe to have the information about your pet’s health situation then you would be able to help them before it suffers from hunger or any unconvincing situation.
The system of the smart house is automatic. The buttons, which have been replaced on the automatic controller, would provide users the ability to run the system easily. With these buttons on the automatic controller for controlling the situation in the smart house, would give you the ability to recover the lack of ideal temperature, food and water for your small animal with only one easy click. For refilling the water in the smart house, which would be so important for your animal’s health care and to keep its main life functions, all you need to do is to click the button to refill the water. Also, another main thing that your animal needs to maintain its healthy life functions, would be the animal’s food. So that you would be able to refill its food also from the buttons on the automatic controller and make the feeding easy with having the enough food your animal needs for one week. These automatic features can be also done manually by the owner of the pet.
Topic Areas
- Wireless
- Internet of Things (IoT)
Age Range of Students
- 14-18 years
Objective of the Activity
Traffic management, smart grids, environmental monitoring, smart buildings and smart homes, smart cities, supply chain management, and industrial, agricultural, and commercial management are some examples of IoT applications. The number of usages in such applications are expected to be grown in the future. Further, similar and/or enhanced applications are expected to be developed. Along this line, it is a fact that the number of IoT applications in almost every area of our lives will keep growing. These applications would mostly require wireless communication. Thus, the fibering or similar requirements would be eliminated. With this project, we both show the use of WiFi technology, which is one of the technologies that can be used here and show the design of a simple IoT system to students.
The main objective of this project is to improve the sense of responsibility for children. Even the kids would be away from their pets, the project would aid the challenges of being apart and taking care of them. This would help kids to improve the responsibility feeling towards their pets rather than leaving the pet to another adult to be taken care of. This project also aims to be an easy tool to solve the problem of leaving small pets alone and hungry.
Here, we tell students about what will be required for this project and how they can do it, with alternatives. In this way, we plan to give students both a start and a future direction on this subject. In this way, we aim to shed light on future projects and inspire students.
Resources/Materials Required
The materials listed below can be used to complete the project. However, it should be noted that these materials are not required but rather can be used as alternatives to design this project. Also, it is most welcome to have different sensors to enhance the project with the creativity of the students.
- A computer
- 2 x Arduino Uno
- ESP8266
- DHT11 Temperature and Humidity sensor
- Water Level Sensor
- 4 x Button
- 2 x SG90 Micro Servo
- 4 x 2.5V Bulb
- 2 x 5V Fan
- Thinkspeak Website
Instructions
The instructions are given for students to follow the project steps. Here note that the steps could be better explained with photos by showing the connection of the sensors, Arduinos, etc.. However, the photos could not be uploaded to this page.
In the project, we will be using ESP8266. It is a low-cost Micro Controller with TCP/IP stack. We will need to keep it updated through the project. The instructions for the update of ESP8266 module, the communication with AT commands. Also, the usage of using Thingspeak Website and designing a simple web interface will be given below with the related codes. In light of these information, students will be able to make the system by themselves.
ESP8266 Update:
In this project, we are using WiFi protocol 802.11 b/g/n, and we are sending commands to Esp8266 via Heyes codes (AT commends). Before we use the module, we should update it because every new version makes the module more stable and to be able to use some new properties (For example, if you did not update, you can not use your Esp8266 SoftAP+Station mode). We are also updating the esp8266 to program via AT commands (Hayes command set).
For the update, we will use ESP8266Flasher(opensource program). First of all, we need to do is to connect our Arduino card with our product named ESP8266 Economic Serial Transceiver Module. Then, we need to find current version and download it. After making the settings, connect your Arduino card with your USB cable and connect your computer and remove the GND cable for the ESP module once, then make sure that the port on the first page of the application is selected correctly then press the big button and you will see the update of your ESP.
Communication with AT Commands:
After we update our ESP8266. We can communicate ESP8266 with Arduino serial port. We should put ESP8266 to communication mode (connection): The important thing is that we should connect ESP module’s Tx to Arduino’s Tx pin and ESP module’s Rx to Arduino’s Rx because now we are trying to communicate ESP. We will send data from computer (Arduino’s serial port)
First, we have to arrange the baud rate of serial port to 115200 (because it is default bound rate for ESP8266 that we update). Then, we find IP for the Web server.
Find Ip For Web Server:
We will find the ESP module’s IP via Arduino’s serial port (normally we can use any serial monitor but Arduino serial port is quite convenient). First, we should arrange baud rate. The ESP module’s baud rate is 115000. Thus, we should open serial at this baud rate. Here is the AT commands.
- AT //We check that connection is ok or not
- AT+CWMODE=1 // Put Wi-Fi Mode STA
- AT+CWLAP // shows every Wi-Fi
- AT+CWJAP=”AndroidAP”,”bbmq0248″ // we connect this Wi-Fi
- AT+CIFSR // Get IP Address
So, now we know that how to find IP and we can use this IP when we want to connect our web server in the future.
Thingspeak Website:
ThingSpeak is a free web service that allows you to collect and store sensor data in the cloud and develop Internet of Things applications. Sensor data can be sent to ThingSpeak from Arduino, Raspberry, BeagleBone Black, and other hardware.
How Can You Use ThingSpeak for Tweeting Feature:
Firstly, you need to create an account. After you create an acount, you click on the Apps button then ThingTweet.
Code For Tweet Feature:
\\Code for the tweeting feature and showing tempeture degree and water level
#define network_name “Mehmet”
#define network_pass “mehmet123”
#define IP “184.106.153.149”
#include “DHT.h”
#define DHTPIN 2 // what pin we’re connected to#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);float vater;
void setup()
{
Serial.begin(115200); //We are opening Serialport.Serial.println(“AT”);
//We check to see if the ESP module has been connected.delay(3000);
//We are waiting for 3 seconds to communicate with ESP.if(Serial.find(“OK”)){
// If we can connect to the Esp module,
//the module is returning with the “OK” command as a response for the “AT” command.
Serial.println(“AT+CWMODE=1”);
//The esp module brings our WiFi mode to STA format.
//With this mode, our module will be able to connect to other networks.
delay(2000);
String con=String(“AT+CWJAP=\””)+network_name+”\”,\””+network_pass+”\””;
Serial.println(con);
dht.begin();
delay(5000);
}
}void loop(){
float vater= analogRead(A0);
float degree = dht.readTemperature();
Serial.println(degree);
Serial.println(vater);if(degree > 30){
hot_function();
}
if(degree < 10){
cold_function();
}
if(vater < 150){
send_vater();
}
//wait 1 minute for 1 minute updatedelay(60000);
}
void hot_function(){
Serial.println(String(“AT+CIPSTART=\”TCP\”,\””) + IP + “\”,80″);
// We use this code to connect to the thingspeak.
// With AT + CIPSTART command, we want to allow to connect to server.
// TCP shows the connection type we will do here.
//80 will show the port to connect
delay(1500);
String tweet = “POST /apps/thingtweet/1/statuses/update HTTP/1.1\n”;
tweet+=”Host: api.thingspeak.com\n”;
tweet+=”con: close\n”;
tweet+=”Content-Type: application/x-www-form-urlencoded\n”;
tweet+=”Content-Length:76+++++++++\r\n\r\napi_key=”;
tweet+=String(“NNOR3U1JWTR9CR4P”);
// We write here the Twitter API KEY from ThingSpeak.
tweet+=String(“&status=”);
tweet+=String(“To hot!! Your Mickey Mouse needs your help!!”);
// We write the tweet we want to send here.Serial.print(“AT+CIPSEND=”);
//We use this command when we send data.
//With this command we have to tell you
//how many characters we will send first.
delay(100);
Serial.println(tweet.length());if(Serial.find(“>”)){
// If we can communicate with the server and
//send the command length, the ESP module returns to us with a “>” sign.
// arduino sees the “>” sign and
//sends the temperature data to the thingspeak with the esp module.
Serial.println(tweet);
Serial.println(“AT+CIPCLOSE=0”);
delay(100);}
else{
Serial.println(“AT+CIPCLOSE=0”);
}
}void cold_function(){
Serial.println(String(“AT+CIPSTART=\”TCP\”,\””) + IP + “\”,80″);
// We use this code to connect to the thingspeak.
// With AT + CIPSTART command, we want to allow to connect to server.
// TCP shows the con type we will do here.
//80 will show the port to connect
delay(1500);
String tweet = “POST /apps/thingtweet/1/statuses/update HTTP/1.1\n”;
tweet+=”Host: api.thingspeak.com\n”;
tweet+=”con: close\n”;
tweet+=”Content-Type: application/x-www-form-urlencoded\n”;
tweet+=”Content-Length:77\r\n\r\napi_key=”;
tweet+=String(“NNOR3U1JWTR9CR4P”);
// We write here the Twitter API KEY from ThingSpeak.tweet+=String(“&status=”);
tweet+=String(“To cold!! Your Mickey Mouse needs your help!!”);
// We write the tweet we want to send here.Serial.print(“AT+CIPSEND=”);
//We use this command when we send data.
//With this command we have to tell you how many characters
//we will send first.
delay(100);
Serial.println(tweet.length());if(Serial.find(“>”)){
// If we can communicate with the server and
//send the command length, the ESP module returns to us with a “>” sign.
// arduino sees the “>” sign and sends the temperature data
//to the thingspeak with the esp module.
Serial.println(tweet);
Serial.println(“AT+CIPCLOSE=0”);
delay(100);}
else{
Serial.println(“AT+CIPCLOSE=0”);
}
}void send_vater(){
Serial.println(String(“AT+CIPSTART=\”TCP\”,\””) + IP + “\”,80″);
// We use this code to connect to the thingspeak
// With AT + CIPSTART command, we want to allow to connect to server.
// TCP shows the con type we will do here.
//80 will show the port to connect
delay(1500);
String tweet = “POST /apps/thingtweet/1/statuses/update HTTP/1.1\n”;
tweet+=”Host: api.thingspeak.com\n”;
tweet+=”con: close\n”;
tweet+=”Content-Type: application/x-www-form-urlencoded\n”;
tweet+=”Content-Length:87\r\n\r\napi_key=”;
tweet+=String(“NNOR3U1JWTR9CR4P”);
// We write here the Twitter API KEY from ThingSpeak.
tweet+=String(“&status=”);
tweet+=String(“Mickey is thirsty!! Your Mickey Mouse needs your help!!”);
// We write the tweet we want to send here.Serial.print(“AT+CIPSEND=”);
//We use this command when we send data.
//With this command we have to tell you
//how many characters we will send first.
delay(100);
Serial.println(tweet.length());if(Serial.find(“>”)){
// If we can communicate with the server and send the command length,
//the ESP module returns to us with a “>” sign.
//arduino sees the “>” sign and
//sends the temperature data to the thingspeak
//with the esp module.
Serial.println(tweet);
Serial.println(“AT+CIPCLOSE=0”);
delay(100);}
else{
Serial.println(“AT+CIPCLOSE=0”);
}
}Full Code For Controlling The System:
\\Code for controlling the System with Buttons
#include <Servo.h>
Servo waterservo;
// create servo object to control a servo
Servo foodservo;
// create servo object to control a servo
int waterpin = 2;
// We defined the 2-way pin as the water input
int foodpin = 4;
//We defined the 4-way pin as the food input
int waterbuttoncondition = 0;
//Whether the button is pressed or not, our variable for water button is 0.
int foodbuttoncondition = 0;
//Whether the button is pressed or not, our variable for food button is 0.
void setup() {
Serial.begin(9600);
Serial.println(“DHTxx test!”);
waterservo.attach(9);
// attaches the water servo on pin 9 to the servo object
foodservo.attach(11);
// attaches the food servo on pin 11 to the servo object
pinMode(foodpin, INPUT); // set our food pin as input
pinMode(waterpin, INPUT); //set our water pin as input
}
void loop(){
waterbuttoncondition = digitalRead(waterpin);
//we assign the state of the water button to the waterButtonCondition variable
if (waterbuttoncondition == HIGH) {
// if the button is pressed, it comes to 5V from the button
waterservo.write(60);
}
if (waterbuttoncondition == LOW) {
// if not pressed
waterservo.write(180);
}
foodbuttoncondition = digitalRead(foodpin); /
//we assign the state of the food button to the foodButtonCondition variable
if (foodbuttoncondition == HIGH) {
// if the button is pressed, it comes to 5V from the button
foodservo.write(90);
}
if (foodbuttoncondition == LOW){
// if not pressed
foodservo.write(150);
}
}Acknowledgements
Thanks to the IEEE Communications Society (ComSoc) and its members who created this hands-on activity.