Does not send webhook data to firebase

hello, I am doing a project of a weather node in the particle boron, to send the data to firebase I am using this code:

char msg[128]; 
snprintf(msg, sizeof(msg) , 
"wind: %d ° / %d m/h, air: %.1f K, rain: %.3f mm, baro: %.1f hPa, gust: %d m/h, V: %d mV" , 
 sensorReadings.windDegrees ,
 sensorReadings.wind_metersph , 
 sensorReadings.airTempKx10 / 10.0 , 
 sensorReadings.rainmmx1000 / 1000.0 , 
 sensorReadings.barometerhPa , 
 sensorReadings.gust_metersph , 
 sensorReadings.millivolts );
 Particle.publish("sensors", msg, PRIVATE);

I am doing the integration through webhooks, but if the data appears in the particle console but then I get the 405 error and it does not send the data to firebase.

thanks in advance

Have you checked all your data is there in the event?

HTTP 405 means “Method not allowed” so it is essential to also disclose the webhook definition and double check with Firebase which methods they do allow.

BTW, this code looks very familiar as some code I provided to someone a day ago but never heard back from them after that.

1 Like

Hi Roberto,

I do not know what your 405 issue is.
However I wanted to mention that Particle has a handy integration with Google Cloud (and hence can be used with Firebase) and you can find the documentation here:

https://docs.particle.io/tutorials/integrations/google-cloud-platform/

Buena suerte!
Gustavo.

2 Likes

It is the same code that you provided us, first we try to send each data in a particle.publish () but we feel like errors and we implement this one but I think the problem is that we are leaving the default json that comes in the weebhooks integration, you know How would we have to modify it to make it valid? Thanks in advance

If you want to push to Firebase you want to wrap your data into a JSON string.
You can use my code to do that by simply adapting the format string to conform to JSON and then in the webhook you can either pass that directly or “re-code” it into the format your Firebase endpoint expects it.

You can have a look at this

Hi, I already managed to send the data to the database but I have a problem with the pressure, it does not show me anything if I put it% .1f,% .2f,% .3f, etc. only if I put it as% d but I gives two values ​​or 1202399705 or -187242071, I am using sparkfun’s mpl3115a2 sensor, do you have any idea why this happens? Thanks in advance
Example result: unixTime: 1602302723, wind_metersph: 0.0 mh, rain: 0.000 mm, windDegrees: 270 °, air: 293.8 K, humid: 36%, baro: 0.0 hPa, milli: 3876 mV

Yeah It is working! Now we are looking up why barometerhPa is not sending data (0.0) when is %.1f but in %d it is sending a huge value.

Thanks a lot for your help!

There is no space allowed between % and .1f - you must use %f, %.#f (where # stands for the number of decimal places) when you are dealing with floating point datatypes (of which barometerhPa is when you look at the definition of the struct).
You cannot use %d (placeholder for integer types) when you pass in a floating point - the two are fundamentally different in their respective binary encoding.

Also make sure your sensorReadings.barometerhPa is in deed a valid number (e.g. via Serial.println(sensorReadings.barometerhPa). If that also returns 0.0 you may not have read the pressure sensor before using the value.

2 Likes