Google Firebase with webhooks tutorial

I followed the tutorial and of course struggled getting the Particle CLI installed on this new Mac.

Once I got Particle CLI working I was able to create the WebHook:

{
    "event": "Environment Read",
    "url": "hsdfgsdfgsdfgsdfgsdfgsdfg.com/environmentdata/data.json",
    "requestType": "POST",
    "query": {
        "auth": "rfdgsdfgsdfgsdfgsdfgsdfgsdfgsdfgsdfg"
    },
    "json": {
        "Temperature": "{{temp}}",
        "Humididty": "{{humidity}}",
        "Voltage": "{{voltage}}",
        "Device": "{{device}}",
        "ts": "{{PARTICLE_PUBLISHED_AT}}"
    },
    "mydevices": true,
    "noDefaults": true
}

Which gives me this in the database:

Makes me wonder why the data didn’t go into the right fields. You’ll notice the empty strings.

Cheers,

Hey @rickkas7,

We were wondering if this tutorial is only for the real-time database or if it also works for the new Cloud Firestore. We followed the tutorial, and we managed to send data to the real-time database, but we have not figured out how to send data to the Cloud Firestore.

We want to use the Firestore because it seems it has better sorting and searching capabilities than the real-time database.

Thanks for the help!

1 Like

Why the getHandler() event is not inside void loop() ?

What are you refering to?
An event would never be anywhere but “come” from outside.
If you mean a function call, where do you see the getHandler() call?
There are lots of posts in this thread that don’t contain any code whatsoever, so if you could quote the post you are refering to answering would be much easier.

I tried to publish values to Firebase integration but only time field is updated else every other data field in firebase is blank.
I created the webhook as shown below
{
“event”: “Send Data”,
“url”: “https://xxxxxxxxxxxxxxxx.firebaseio.com/Senddata/data.json”,
“requestType”: “PUT”,
“query”: {
“auth”: “your auth token”
},
“json”: {
“Temperature”: “{{temp}}”,
“Humidity”: “{{humidity}}”,
“Voltage”: “{{voltage}}”,
“Device”: “{{device}}”,
“ts”: “{{PARTICLE_PUBLISHED_AT}}”
},
“mydevices”: true,
“noDefaults”: true
}

Test data:
Send Data
“{“Temperature”:31,“Humidity”:85,“Voltage”:3}”

Result
hook-response/Send Data/0
{“Device”:"",“Humidity”:"",“Temperature”:"",“Voltage”:"",“ts”:“2019-08-11T06:24:16.427Z”}

The part in {{ }} must match the keys in the JSON data you send from the device or test data.

In other words:

  • {{temp}} should be {{Temperature}}
  • {{humidty}} should be {{Humidity}}
  • {{voltage}} should be {{Voltage}}
  • {{device}} isn’t in the JSON data. Did you mean {{PARTICLE_DEVICE_ID}}
1 Like

Thank You I understood my mistake, now its working fine.

Is there a way to read a list of data like stock prices from Google Sheets(after publishing the sheet then converting into json format using gsx2json) and display on I2C 16 x 2 lcd display.
Would you please write a demo code for me or make a tutorial on this.:thinking::thinking::pleading_face::pleading_face:

Guys, how do I send data like name and id to firebase using webhook?

String name = "Mira";
String serial = "3B D4 DD 0D";

void sendInfo()
{
      char data[256];
      snprintf(data, sizeof(data), "{\"Name\": %s, \"Serial\": %s}" , name.c_str(), serial.c_str());
      Particle.publish("FirebaseRFID", data, PRIVATE);  //Store data to firebase
}

I can see the event in particle console, but nothing from webhook.
I guess the format is wrong, but don’t know the right way to write them…

Have you read through the thread and followed the steps shown?

yes, I can send the string converted from integer like temperature value etc (like example below), but cannot if the data is already in string.

   snprintf(data, sizeof(data), "{\"temp\":%.2f, \"Air Index\":%.2f, \"humid\":%.2f}" , t, airNo, h);
   Particle.publish("Firebase", data, PRIVATE); 

If it’s a string the JSON should warp it in double quotes.