Categories
TUTORIALS

Sending Serial Monitor Data to Google Firebase with an ESP8266-01

Overview:

You’ll program the ESP8266-01 board to send data from your serial monitor to a Firebase Realtime data base.

The highlevel steps are:

  1. Create a Firebase Realtime Database
  2. Wire your circuit
  3. Program your ESP8266
  4. Connect your data stream to a web or mobile app

Why Firebase?

Sending sensed data to Firebase allows you to connect with web and mobile apps, and gives you access to Google Analytics. It also offers a lot of flexibility in terms of what you can do with the data—exporting to BigQuery, running machine learning analyses, etc.

Why ESP8266-01?

It’s cheap! A better option for more elaborate sensing projects is the ESP8266-12E. In fact, this kind of Wifi development board would work as a standalone (you wouldn’t need a separate Arduino board).

Parts needed:

  • Elegoo Uno R3
  • ESP8266-01
  • F-M and M-M wires
  • Breadboard
  • USB cable
  • 100k Ohm resistor (optional)

Step 1: Create the Firebase Realtime database

This is where the data you send from the ESP8266 will live, and can be pulled from to populate a web or mobile app.

  1. Create a Firebase Account
    • Click Add project and create a Realtime Database

2. Use test mode as a Security rule

3. Go to Project Overview, Project Settings, Service Accounts, Database secrets, and copy your Database and Secret key. Save these to use in your sketch later on.

Step 2: Wire your Circuit

  1. Watch this tutorial on how to correctly wire the ESP8266. Below is the diagram as well as pictures of the boards.

2. Double check that the Arduino ground is wired to reset. This make sure you’re programming the ESP8266 and not the Arduino. NOTE: the ESP8266 uses the 3.3V pin, not the 5V pin.

Step 3: Program your ESP8266

  1. Download Arduino IDE if you haven’t already.
  2. Install the ESP8266 Board to Arduino IDE (reminder, you’re programming the ESP, not the Arduino board).
    • File -> Preferences
    • Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into the Additional Board Manager URLs field.
  • After that open Boards Manager from Tools > Board menu and install esp8266 platform.
  • Select ESP8266 board from Tools > Board menu after installation.

3. Add the Firebase library.

  • Download it from this link.
  • Open Sketch > include library > add.ZIP library and add ZIP library to Arduino IDE.
  • After that go to Sketch > Include Library Verify that the library you just added available in the list.

4. Add the ArduinoJson Library.

  • Go to Tools -> Manage Libraries.
  • Install ArduinoJson version 5.13.5 library.

5. Add the code below into a sketch. Replace the Firebase and Wifi credentials with your own.

6. Double check that you’ve:

  • Selected the ESP8266 board from Tools > Board
  • Selected the correct port from Tools > Port Menu

7. Upload your code to the ESP8266 and inevitably troubleshoot.

  • If you’re getting something like “error: espcomm_upload_mem failed”, watch this video.
  • If you’re getting gibberish in your serial monitor, check that the baud rate is 9600.
  • If you’re seeing “setting /number failed:” in your serial monitor, watch this video.

You should see this at the bottom of your sketch when it uploads:

And you should see this in your Serial Monitor (Tools > Serial Monitor):

8. Check out your data in your Firebase database!

Step 4: Connect your data to a web or mobile app

References:
Google Firebase & ESP8266 Complete Guide – Sending/Receiving Data from ESP8266 & Firebase

Connecting ESP8266 to Firebase to Send & Receive Data

ESP8266 DHT11/DHT22 Temperature and Humidity Web Server with Arduino IDE

Easy Way to Program an ESP8266

ESP8266 Pin Reference

How to fix esp8266 error upload message arduino

[SOLVED]Setting/number failed problem || Google firebase || firebase

Leave a Reply

Your email address will not be published. Required fields are marked *