Page 1 of 1

how to connect to google firebase by editting this code?

PostPosted: Wed Dec 28, 2022 2:54 am
Code: Select all#include <ESP8266WiFi.h>;

#include <WiFiClient.h>;

#include <ThingSpeak.h>;

const char* ssid = "Wifi_Project"; //Your Network SSID

const char* password = "1111aaaa"; //Your Network Password

WiFiClient client;

unsigned long myChannelNumber =   1947152; //Your Channel Number (Without Brackets)

const char * myWriteAPIKey = "QA02MFMGFJVIDBZR"; //Your Write API Key

#include <SoftwareSerial.h>
SoftwareSerial SMESerial (D6, D7);
int xVal, yVal, zVal;
float xtotal,ytotal,ztotal,xprice,yprice,zprice;

void setup() {
    WiFi.begin(ssid, password);


void loop() {
  if (SMESerial.available()<1)  return;
  char R=SMESerial.read();
  int data=SMESerial.parseInt();
  if (R == 'x')
  xVal = data;
  xtotal = xVal + xtotal;   
  xprice = xtotal*0.1;
  Serial.print("X = ");
  ThingSpeak.setField(1, xtotal);
  ThingSpeak.setField(2, xprice);

  if (R == 'y')
  yVal = data;
  ytotal = yVal + ytotal;   
  yprice = ytotal*0.1;
  Serial.print("Y = ");
  ThingSpeak.setField(3, ytotal);
  ThingSpeak.setField(4, yprice);

    if (R == 'z')
  zVal = data;
  ztotal = zVal + ztotal;   
  zprice = ztotal*0.1;
  Serial.print("Z = ");
  ThingSpeak.setField(5, ztotal);
  ThingSpeak.setField(6, zprice);

  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);


I've made a power monitoring system by using 3 slave nodemcu to collect current reading using ACS712 and send it to master nodemcu. The master nodemcu should send data to phone to view the data through a mobile application. I used Thingspeak at first to view data of the power consumption but i want to use google firebase to view the power consumption easier for my application view. Any help?

Re: how to connect to google firebase by editting this code?

PostPosted: Wed Jan 18, 2023 8:02 am
by rooppoorali
You have to install the <FirebaseESP8266.h> library.