1. Go to “firebase.google.com”
2. If you have Gmail id then you don’t need to Sign Up for firebase, if you don’t have a Gmail id then Sign Up for one and then you can go to next step.
3. At the right top corner go to “Go to Console”
4. Click on “Add project”
5. Input your Project Name.
6. Accept the terms and condition, create project and click on “Continue”
7. Go to Settings Icon (Gear Icon) and click on “Project Settings”
8. Now click on “Service Accounts”
9. You can see two options “Firebase admin SDK” and “Database Secrets”
10. Click on “Database Secrets”
11. Scroll on your project name and “Show” option appears at right side of your project
12. Click on “Show” and now you can see secret key created for your project
13. Copy the secret key and save it to notepad. This is your “FIREBASE_AUTH” string which we have written in Arduino program above.
14. Now go to “Database” on left control bar and click on it
15. Scroll down and click on “Create Database”
16. Choose “Start in test mode” and click on “Enable”
17. Now just above the database you can see
18. Just copy “your_project_name.firebaseio.com” without any slash and https and save it again to notepad just you had saved for secret key
19. This is your “FIREBASE_HOST” string which we have written in Arduino program above
Now put “FIREBASE_HOST” and “FIREBASE_AUTH” in Arduino program and upload the sketch. And we are done with setting up both sections. Complete Arduino Program is given at the end.
BOM: –
1. NodeMcu
2. neopixel
Software:-
1. Arduino IDE
2. Firebase service
Interfacing
Source code:-
Explaination: –
1) Include FirebaseESP8266 library from include library function of arduino and WIFI Library. Neopixel is used to change the color of the LED.
- #include “FirebaseESP8266.h”
- #include <ESP8266WiFi.h>
- #include <Adafruit_Sensor.h>
2) Setup wifi connection withbthe help of connectWifi()
- void connectWifi() {
- // Let us connect to WiFi
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(“.”);
- }
- Serial.println(“…….”);
- Serial.println(“WiFi Connected….IP Address:”);
- Serial.println(WiFi.localIP());
- }
3) Setup function
- Firebase.begin(“XXXXXXXXXXXXXXXXXXX “XXXXXXXXXXXXXXXXXXXXXXXXXX”);
Use your firebase host and Auth token to connect with firebase
4) Loop function will Check the LED value status and call the setLedColor function.
- if (Firebase.getInt(firebaseData, “/red”)) {
- if (firebaseData.dataType() == “int”) {
- int val = firebaseData.intData();
- if (val != redValue) {
- redValue = val;
- setLedColor();
- }
5) The setLedColor function will set the color of the neopixel accordingly
- void setLedColor() {
- for (int i=0; i < NUM_LEDS; i++)
- leds.setPixelColor(i, leds.Color(redValue, greenValue, blueValue));
- leds.show();
- }
If you are still facing issue regarding this topic Feel free to Ask Doubts in the Comment Box Below and Don’t Forget to Follow us on 👍 Social Networks😉
Trackbacks/Pingbacks