I am creating a slot sensor, using photoresistor. The goal is to send the photoresistor value, via analog read, pin A0 to my web server, so I can stored it in my database.
void loop() {
int sensorvalue = analogRead(A0);// LightValue, read from sensor pin A0
data = "sensorValue=" + (sensorvalue);
//there is a car parked
if(sensorvalue >=1000){
if(flagstatus == false){
if (client.connect(server, 80)){
Serial.println("Connected to Host Server");
client.println("POST /dataPost.php/HTTP/1.1");
client.print("Host:");
client.println(server);
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
I've been trying to send mock data via postman, and it works like a charm, so I can eliminate my server side from the equation. Been guessing using : or = on sensorvalue=analogread(a0) or sensorvalue:analogread(a0). Or I made mistake on the code? I don't know much in Arduino, and this issue kinda frustrate me.
the Image just for confirmation only, of course I installed the protoboard correctly.
Connect to SSID: Adamar
IP Address: 192.168.1.14
Connect to server...
Connected with network---------
Connected to Host Server
sensorvalue:1007
There is still a car parked
sensorvalue:1007
There is still a car parked
sensorvalue:1008
I manage to get this result from my serial monitor, so I think there is no wrong reading from my setup.

POST /dataPost.php/HTTP/1.1, could you please be more elaborate? – Briant Stevanus Jul 29 '19 at 19:57POST /dataPost.php HTTP/1.1– Majenko Jul 29 '19 at 19:59client.connect("the******tem.com", 80)){ client.println("POST /dataPost.php HTTP/1.1"); client.println("Host: the******tem.com"); client.println("Content-Type: application/x-www-form-urlencoded"); client.print("Content-Length: "); client.println(data.length()); client.println(); client.print(data); client.stop();already double check with http request format. Any idea about this?
– Briant Stevanus Jul 29 '19 at 21:43It confuse me, since we still can see sensor value from serial monitor.
I would like to update this issue, it may be because of server hosting fault. I can manage to store data via
– Briant Stevanus Jul 30 '19 at 18:36GETalthough I understand it is not the best practice.