1

Hello Good Day to Everyone. I have a project where I need to send DHT11 sensor data to a Firebase database using both Arduino UNO and Esp8266 esp-01 wifi module. Both of them must work together to send the data.

Connection

Arduino Code:

#include <dht.h>

dht DHT;

#define DHT11_PIN 7


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

}

void loop() {
 // put your main code here, to run repeatedly:
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature);
Serial.print("Humidity = ");
Serial.println(DHT.humidity);
delay(1000);

}

My arduino code is working fine. Now comes the part where I need to program the ESP8266 which I am really confused how to pass the data to the wifi module and send it to firebase. I tried to code some and this is my

ESP8266 Code:

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

#define FIREBASE_HOST "test.firebaseio.com"
#define FIREBASE_AUTH "authcode"

#define WIFI_SSID "mywifi"
#define WIFI_PASSWORD "12345"

#define DHTTYPE DHT11
#define DHTPIN  7

DHT dht(DHTPIN, DHTTYPE);
float temp_f;
unsigned long previousMillis = 0;       
const long interval = 2300; 


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

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
 Serial.println();
 Serial.print("connected: ");
 Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

 }

void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
delay(50);
Firebase.setFloat("temp",t);
Firebase.setFloat("hum",h);
delay(1000);   
}

I don't want my esp8266 to go stand alone. I wanted the data to come from the arduino but somehow I don't know how to receive the data from the arduino in the esp8266.

I hope someone can enlighten me.. thank you

3
  • Have you solve the problem? Im also having this problem,can share it?
    – Tsu Han
    Commented Oct 30, 2017 at 10:50
  • did you find a solution iam waiting for one also ?
    – Mai Ehab
    Commented Nov 9, 2017 at 19:01
  • Dump the Arduino Uno and just program the ESP8266.
    – Avamander
    Commented Oct 26, 2018 at 11:11

1 Answer 1

1

First of all, FirebaseArduino.h library is for ESP8266 itself and not for Arduino UNO. The code you have written will not work as you are giving instructions like Firebase.setFloat("temp",t); to UNO. It will not compile. What you should do is set ESP8266-01 as your primary board and let the UNO transmit the data by software serial. ESP8266-01 will capture that data and transmit it over the Internet. YOU CAN'T USE FirebaseArduino.h FOR ARDUINO UNO! It is for the ESP8266. All YouTube videos will show you how to code for NodeMCU esp8266-12E. Do that for ESP-01 and communicate with Arduino for data (converting data calculated to string will help to reduce problems). Get data in form of string from UNO and transmit it using ESP-01!

If you want I can share all video list that I found useful!

Not the answer you're looking for? Browse other questions tagged or ask your own question.