I'm working on a project that reads vibration on a building using an accelerometer and displaying it's data on a web server. The plan is to read 10 samples/second from the accelerometer and send that data every 5 seconds to a web server using arduino yun.
So there would be 10(samples/sec) x 5(seconds) x 3(3 axis - x,y,z) = 150 data points that will be sent to the webserver, I tried this with the client.get() command but it cannot send that much data to a web server, I also tried POST request but i've had trouble with the sending it multiple times since it needs to have a delay.
What are the other options that I can do in order to achieve this? Any suggestion would help and please if you think my question is bad or not stated properly don't report me, I'm still new here in stack exchange. Any help/suggestion is much appreciated
Arduino Code for POST request
#include <Bridge.h>
#include <HttpClient.h>
#include <YunClient.h>
//IPAddress server(192,168,1,200);
byte php_server[] = {192,168,1,9};
YunClient client;
String data = "", datax="", datay="", dataz="";
unsigned long ts_0 = 0, tr_0 = 0, t_read = 100;
int counter=0;
void setup() {
// put your setup code here, to run once:
Bridge.begin();
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if((millis()-tr_0>=t_read)) {
if(counter<49) {
counter++;
}
else if(counter == 49) {
//Serial.print("sent");
String dat = "0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12,0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12, 0.24,1.24,4.56,8.97,3.15,7.23,9.34,0.12,6.21,8.12";
send_to_ws(dat);
Serial.println(dat);
counter = 0;
}
tr_0=millis();
}
}
void send_to_ws(String data) {
if(client.connect(php_server, 80)) {
Serial.println("Connected");
client.println("POST /arduino/add.php HTTP/1.1");
client.print("Content-Length:");
client.println(data.length());
Serial.println(data.length());
Serial.println(data);
client.println("Connection: Close");
client.println("Host:192.168.1.9");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println();
client.println(data);
} else {
Serial.println("Connection error");
}
}
Serial monitor output when running this sketch, It prints it in the serial monitor but only blank data is being pushed in the database of the server