How To Communicate Flutter And Arduino Using Firebase

Murat Gun
3 min readAug 16, 2021

--

Today, it is very popular to use IoT devices and mobile applications together. There are many methods and packages developed to provide this communication. The method that I will tell you about today is the simplest and most convenient for me.

Photo by Will Porada on Unsplash

First of all, we should talk about communication. The concept of communication here covers the communication of Flutter application and Arduino module with the help of Firebase real time database service. Simple arduinos basically don’t have an ethernet module so it would be easier to use an ESP8266 module or a device directly like NodeMCU or ESP32 for this.

Let’s move explanation step by step.

1- First of all, we should create a Firebase project. In this “https://firebase.google.com/” address you can see “Get started” button. After clicking(or tapping) you will see “Add project” button. Click it and enter your project name(My project name is flutter-arduino). In next step, Firebase will ask you to dou you want to use Google Analitcs. Google Analitics is a so good tool to controle your projects but we don’t need in this project so we can disable it. Now you created your Firebase project.

2- Now, you should be in Firebase Console and our next step is configuring real time database. After select Real Time Database, create a database. Select best loation for you and finish creating process. In security rules you should select “test mode”. If don’t select it you can’t communicate application and device.

3- We can start arduino part. In the Arduino part, the operations we need to do that as follows;

Connecting the device to the internet
Creating an http client and sending GET, POST, PUT, DELETE requests to Firebase realtime database server easily with this client.

In my example, I will create a basic Blink Application using Flutter.

Now, we can upload our data to Firebase Real Time Database and ve can change it easily. Let’s code arduino side.

4- In Arduino side, we should listen Firebase database to take blink value so we will GET request to Firebase Real Time Database regularly.

Finally, we can see our application is working or not. Let’s look.

--

--