
In this tutorial we will see how to send the temperature value of the DTH11 sensor to the smarthpone via bluetooth.
This is why we are going to create two programs: a mobile application with App Inventor for the smartphone and a program for the Arduino board.
wire connections
Here is the program that allows you to connect the Arduino board to the smartphone and send a message containing the temperature value measured by the DHT11 sensor via bluetooth.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <SoftwareSerial.h> #include <dht11.h> #define DHT11PIN 4 // broche DATA -> broche 4 dht11 DHT11; SoftwareSerial hc06(2,3); void setup(){ hc06.begin(9600); } void loop(){ DHT11.read(DHT11PIN); delay(1000); hc06.print((float)DHT11.temperature); //sends the temperature value to the smartphone } |
We will create a mobile application named ‘temperature_arduino’ with App Inventor which allows you to receive a message from the Arduino board.
We propose to create the design of the application, with the following visual:
To program the application, App Inventor offers us to use the Blocks space, which allows you to create a program in the form of a block diagram. Very easy to use but requiring a little programming logic.
Here is the program of the application created in the Blocks area of the Inventor App: