Introduction: Connecting Arduino to Firebase to Send & Receive Data

About: Passionate about electronics parts and tutorials. We're your go-to source for high-quality components and expert guidance. Join us on our journey of exploration and innovation in the world of electronics.

In this tutorial, you will learn how to upload and download data to/from a Firebase database with Arduino UNO and ESP8266 module.

Storing data (like sensors data) to a database that can be accessed from anywhere by the internet may be very useful. Firebase makes storing and retrieving data easy.

What You Will Learn:

  • How to make a database in Firebase
  • How to upload (download) data to (from) Firebase
  • How to use ESP8266 as a connection between Arduino and Firebase

Step 1: What Is Firebase?

Firebase is a mobile and web application development platform developed by Firebase, Inc. in 2011, then acquired by Google in 2014. As of October 2018, the Firebase platform has 18 products which are used by 1.5 million apps. 

Firebase provides multiple services as following:

  • Firebase Analytics which is a free application measurement solution providing insight into app usage and user engagement.

  • Firebase Cloud Messaging (FCM) which is a cross-platform solution for messages and notifications for Android, iOS, and web applications, which is cost-free as of 2016.

  • Firebase Auth which is a service that can authenticate users using only client-side code. It supports social login providers Facebook, GitHub, Twitter and Google (and Google Play Games). Moreover, it includes a user management system whereby developers can enable user authentication with email and password login stored with Firebase.

Step 2: Required Materials

Hardware Components

Arduino UNO R3 *1

ESP8266-12N WiFi Module *1

Software Apps

Arduino IDE

Step 3: Connecting Arduino to Firebase

First, you should create an account in Firebase. It’s quite easy to create an account; Go to “firebase.google.com”, click on Console, sign in by your Google account, and thenmake a new project. After creating a new project, add a name and enable the test mode. You can add some value manually in the realtime database part. You can get JSON form of your data by adding “.json” at the end of the database URL. Watch this step video for more information.

You can read or transfer data from your database by Arduino and ESP8266. You need a Host name and an Auth key of your firebase project. Then, you should add the Firebase Arduino library and upload the code. If it’s the first time you are using an Arduino board, just follow these steps:

Go to  www.arduino.cc/en/Main/Software and download the Arduino software compatible with your OS. Install the IDE software as instructed.

  1. Run the Arduino IDE and clear the text editor and copy the following code in the text editor.
  2. Choose the board in: tools > boards, and select your Arduino Board.
  3. Connect the Arduino to your PC and set the COM port in tools > port.
  4. Press the Upload (Arrow sign) button.
  5. You’re all set!

Step 4: Circuit

Step 5: Code

Necessary Files & Downloads

Download this file and check other examples of connecting Arduino to Firebase

Step 6: What’s Next?

  • Make a real-time connection between two Arduino based systems
  • Add other Google services to your Arduino projects.