Tags: , , , ,

One interesting branch of robotics is making existing objects smarter which helps in our everyday life. This domain is known as domotics (especially for home) and IoT (Internet of Things)

Here is a small domotic project that consists in measuring your home temperature and collect the data on your smartphone. It is a simple project in which we use Bluetooth module, serial communication with a way to deal with multidata and a smartphone Android application made withh App Inventor 2.

 

Material

  • Smartphone
  • Arduino UNO
  • 5V Battery
  • Temperature sensor LM35
  • Bluetooth module HC-06

 

Wiring

home temperature measurement schematic

N.B.: The module displayed in Fritzing is a HC-05 but it has the same pinout as HC-06.

 

Code

We search the datasheet of the sensor LM35 to find the temperature range and the conversion rule between voltage and temperature. To be able to convert the measured voltage into a physical value. Once the temperature is measured it is sent to the smartphone via the Bluetooth module. To deal with multi-data, the data are concatenated into a String with a separator which make it easier to decipher.

 

#include <SoftwareSerial.h>                          
SoftwareSerial HC06(2,3); 

// Constants
#define DELAY 1000 // Delay between two measurements in ms

// Parameters
const int sensorPin = A0; // Pin connected to sensor

// Variables
float voltage, temperature;

void setup(void) {
  Serial.begin(9600);
  HC06.begin(9600);
}

void loop(void) {
  voltage= analogRead(sensorPin) * (5.0 / 1023.0); // Convert digital value to voltage
  temperature=100*voltage; // conversion from V to °C
  
  Serial.print("Sensor reading = ");
  Serial.println(temperature); // the temperature reading

  // Send voltage and temperature value to app
  HC06.print(voltage);
  HC06.print("x");
  HC06.print(temperature);
  
  delay(DELAY);  
}

 

Home Measurement App

We created a simple application using App inventor 2.The data from the Arduino is sent as a text to the Android application. To obtain the values from the sensor, the text need to be split according to the separator “x”. The resulting list items are then displayed in the corresponding labels.

android app inventor 2 for home measurementapp inventor 2 home measurement scratch

 

The Bluetooth module must be stored in the list of Bluetooth devices in your phone. The Bluetooth module HC-05 or HC-06 should paired once before using the app.

 

If you want more information on this project or if you think of one related project that should be on this site, do not hesitate to leave a comment or to send us a message.

 

Source

Learn how to read sensor value

Communicate with HC-06 Bluetooth module

Create an Android App using App inventor 2