I propose to measure ambient temperature and humidity with DHT11 connected to Arduino Uno and send the data to my smartphone via Bluetooth using the HC-05 board. The app is programmed with App Inventor. The same app allows me to send an on-off command to turn the LED_BUILTIN on the Arduino board on or off.

20220407 LED e DHT11 schema 

 20220407 LED e DHT11 mobile

 

I think to program the acquisition, data processing and visualization interface as shown below.
20220407 LED e DHT11 app

#include <SoftwareSerial.h>
#include <DHT.h>
#define intervallo 2000  // intervallo per il millis

DHT dht(4, DHT11);
SoftwareSerial Bluetooth(2, 3); // RX, TX

char Incoming_value = 0;    // LED On = 1 / Off = 0
unsigned long tempo = 0;    // tempo precedente per il millis
String temperatura, umidita; // valore acquisito dal DHT11 dopo casting

void setup() 
{
  Serial.begin(9600);    // seriale USB     
  pinMode(13, OUTPUT);      //LED BuilT In
  dht.begin();  
  Bluetooth.begin(9600); // set the data rate for the SoftwareSerial port
}

void loop()
{
  // gestione dati  
  
   if ((millis()-tempo)>intervallo)
  {
  temperatura = String(dht.readTemperature());
  Bluetooth.print(temperatura); // invia al Bluetooth
  Serial.print("temperatura: ");
  Serial.print(temperatura);

  Bluetooth.print("-");   // invia al Bluetooth come discriminante
  
  umidita = String(dht.readHumidity());
  Bluetooth.print(umidita); // invia al Bluetooth
  Serial.print(" - umidità: ");
  Serial.println(umidita);
  
  tempo = millis();
  }
  
  // gestione LED On/Off
  if(Bluetooth.available() > 0)  
  {
    Incoming_value = Bluetooth.read();      
    Bluetooth.print("\n");        
    if(Incoming_value == '1')             
      digitalWrite(13, HIGH);  
    else if(Incoming_value == '0')       
      digitalWrite(13, LOW);   
  }                            
} 

Here you can download the material to develop the application: PDF step by step , Arduino sketch, App Inventor AIA.

Advertising

Advertising

Advertising