Go Down

Topic: Send data to Firebase database by POST (Read 2269 times) previous topic - next topic

llwhit

I am using the Arduino YUN to send data information to Firebase via wifi. I can retrieve information from my database (Using the httpclientConsole example in arduino) but I am having a hard time sending data to it. I tried running this code as well and replacing the proper URL: https://forum.arduino.cc/index.php?topic=474536.0
Here is the code that I got from the Firebase references that I'm trying to get to work:

#include <Process.h>
#include <Bridge.h>
#include <Console.h>
void setup()
{
  Bridge.begin();   // Initialize the Bridge
   Console.begin();  // initialize Console communication
  while(!Console);
 
}

void loop()
{
 
  // Simulate Get Sensor value
  int sensor = random(10, 20);
 
  Process p;
 
//I put the proper project name which is the name of my database
 p.runShellCommand("curl -X POST -d '{"user_id"  : "jack", "text" : "Ahoy!"}'  'https://[My project name].firebaseio.com/.json' ");

Console.println(sensor);
  while(p.running());
  delay(500);               
 
  }





This is where I got the code: https://firebase.google.com/docs/reference/rest/database/

sonnyyu

#1
Apr 25, 2018, 10:57 pm Last Edit: Apr 25, 2018, 10:58 pm by sonnyyu
Default Yun OS is missing root certificates for firmware size constraint.


Two work arround:

1.  Use "-k" switch to make insecure connection.

Code: [Select]
curl -k -X POST -d '{"user_id"  : "jack", "text" : "Ahoy!"}'  'https://[My project name].firebaseio.com/.json'

-k, --insecure

(TLS) By default, every SSL connection curl makes is verified to be secure. This option allows curl to proceed and operate even for server connections otherwise considered insecure.


2. Adding root certificates through opkg
You can use opkg to install the certificates from the major CA

Code: [Select]
opkg  update
opkg install ca-certificates



Go Up