Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase

Components & Supplies

Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
Arduino UNO
×2
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
ESP8266 ESP-01
×2
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
DHT11 Temperature & Humidity Sensor (3‑pin)
×1
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
DFRobot I2C 16x2 LCD Display
×1
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
Breadboard (generic)
×2
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
Male/Female Jumper Wires
×1

Apps & Online Services

Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
Arduino IDE
Transfer Temperature & Humidity Data Between Two Arduinos Using Firebase
Google Firebase

Project Overview

In this IoT tutorial, you’ll read temperature and humidity from a DHT11 sensor on one Arduino UNO, push the values to Firebase via an ESP8266, and then pull those readings back on a second Arduino UNO to display them on an I2C LCD. This hands‑on example demonstrates serial communication, Wi‑Fi networking, and cloud data storage—all essential skills for modern embedded developers.

Step 1 – Understand the Role of Each Board

The UNO serves as the sensor interface while the ESP8266 acts as the Wi‑Fi gateway. They communicate over the serial port; the ESP8266 never connects directly to the internet, only the Wi‑Fi module does. Keep the code separate for each board to avoid confusion.

Step 2 – Connect the LCD to the UNO

Use I2C for simplicity and reduced pin usage. The 20x4 LCD example in the DFRobot module works out of the box. If you’re using a 20x4 display, update the constructor to LiquidCrystal_I2C lcd(0x3F, 20, 4);.

Step 3 – Wire the DHT11 to the Second UNO

Follow the official Arduino DHT11 tutorial for wiring and library installation. The sensor requires only a single data pin (A0 in our example).

Step 4 – Set Up the ESP8266 with Firebase

Configure Wi‑Fi credentials and Firebase project details in the sketch. The Firebase Realtime Database provides a simple JSON tree where the ESP8266 writes temperature and humidity nodes. For beginners, the tutorial video covers each step in detail.

Step 5 – Master Serial Communication

When transmitting data over serial, output only the required string. Any additional debugging prints can break the protocol. In our implementation, the sensor UNO sends a comma‑separated string (e.g., 25.3,60.1) to the ESP8266, which parses and forwards each value to Firebase.

Step 6 – Upload and Test

Upload the sensor sketch to the first UNO, the sensor‑ESP8266 sketch to the first ESP8266, and the LCD‑ESP8266 sketch to the second ESP8266. Verify that the LCD updates with fresh readings every few seconds. Always disconnect the Arduino USB cable before unplugging any jumper wires to prevent accidental shorts.

Common Pitfalls & Fixes

Code Snippets

lcd_arduino.ino (Arduino)

#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x3F, 20, 4);
String sensorData;

void setup() {
  Serial.begin(9600);
  lcd.begin(20, 4);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0); lcd.print("Temperature: ");
  lcd.setCursor(18, 0); lcd.print("C");
  lcd.setCursor(0, 1); lcd.print("Humidity: ");
  lcd.setCursor(15, 1); lcd.print("%");
}

void loop() {
  if (Serial.available()) {
    sensorData = Serial.readString();
    String temp = sensorData.substring(0, sensorData.indexOf(','));
    String hum  = sensorData.substring(sensorData.indexOf(',') + 1);
    lcd.clear();
    lcd.setCursor(13, 0); lcd.print(temp);
    lcd.setCursor(10, 1); lcd.print(hum);
  }
  delay(2000);
}

lcd_esp8266.ino (ESP8266)

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

#define FIREBASE_HOST "YOUR_FIREBASE_LINK"
#define FIREBASE_AUTH "YOUR_FIREBASE_TOKEN"
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"

void setup() {
  Serial.begin(9600);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

void loop() {
  String temp = Firebase.getString("temperature");
  String hum  = Firebase.getString("humidity");
  Serial.flush();
  Serial.print(temp + "," + hum);
  delay(2000);
}

sensor_arduino.ino (Arduino)

#include <SoftwareSerial.h>
#include <dht.h>
#define DHT_PIN A0

DHT dht;

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

void loop() {
  dht.read11(DHT_PIN);
  String data = String(dht.temperature) + "," + String(dht.humidity);
  Serial.flush();
  Serial.print(data);
  delay(2000);
}

sensor_esp8266.ino (ESP8266)

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

#define FIREBASE_HOST "YOUR_FIREBASE_LINK"
#define FIREBASE_AUTH "YOUR_FIREBASE_TOKEN"
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"

void setup() {
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  Serial.begin(9600);
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

void loop() {
  if (Serial.available()) {
    String payload = Serial.readString();
    int comma = payload.indexOf(',');
    String temp = payload.substring(0, comma);
    String hum  = payload.substring(comma + 1);
    Firebase.setString("temperature", temp);
    Firebase.setString("humidity", hum);
    if (Firebase.failed()) {
      Serial.println("Failed to write to Firebase");
    }
  }
  delay(2000);
}

Manufacturing process

  1. Stream Real‑Time Temperature Data from a ppDAQC Pi‑Plate to InitialState with a Headless Raspberry Pi
  2. Seamless LED Brightness Control Using Bolt IoT and Arduino UNO
  3. Build a PHP‑Based Web Interface to Control Your Arduino Uno
  4. Upload Arduino Sensor Data to MySQL via PHPMyAdmin: Step‑by‑Step Guide
  5. Capacitive Touch LED Switch with Arduino UNO – Easy DIY Project
  6. Building an IoT Device with ESP8266‑01 and Arduino Nano: A Complete Guide
  7. Programming the ATmega8 Microcontroller with Arduino IDE – Step‑by‑Step Guide
  8. Seamless MKR1000 to Google Sheets: Upload Sensor Data Over WiFi
  9. Build an Amazon Echo‑Style Smart Speaker with Arduino and 1Sheeld
  10. Seamless CMMS Migration: Expert Guidelines for Data Transfer