Project goals
- Send data over GSM to firebase
- Fast sampling - need to send 16 bytes every half second to firebase
- Send data using GET or POST to server with PHP script, that redirect data to firebase
Problems -- Extremely low data rate!
- Using standard GET or POST request from client(arduino) side, is impossible to achieve second (2) project goal.
To send data correctly I need to close connection with server, so next data package unfortunately waits(2-6 seconds) for establishing a new connection.
Is this quite nonsense? I'm using ArduinoHttpClient library.
My actual Nonsense Connection and fully useless, but works
while(1){
http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server
//next instruction take over 5 second to establish new connection :(
http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server, whyyy?
}
Data are send once per 2 - 6 seconds, this is not even funny. NEED to send data every 0.5 seconds!
So I decided to create super solution, which not works :C
while(1){
http.post("/test.php","application/x-www-form-urlencoded","data=0");
delay(xxx);
//no connection closing, no wasting time for establishing new one :)
}
Just tell my why this connection is not "Keep-Alive", also used with
http.sendHeader("Connection: Keep-Alive"); or http.connectionKeepAlive();
//First run
http.post(blabla);// returns value: 0 & data are logged into firebase
//Second run
http.post(blabla);// returns value: -2 & data are not logged in firebase
my test.php file
<?php
require_once 'firebaseLib.php';
$url = 'https://czujniki-aa5ca.firebaseio.com/';
// --- Use your token from Firebase here
$token = ':-CCCCCCCCCCCCCCCCCCCCCCC';
$arduino_data_post = $_POST['data'];
$firebasePath = '/';
$fb = new fireBase($url, $token);
$response = $fb->push($firebasePath, $arduino_data_post);
sleep(2);