Go Down

Topic: Ciao freezes arduino on POST request (Read 82 times) previous topic - next topic

SpikeSource

Hello, I have a problem that I hope someone can help me with.

I'm using the Arduino Uno Wifi with the UnoWiFiDevEd libary to send data to a php script which interfaces with my database. All this is working fine, but when I tell my arduino to send data to my php script, the entire program freezes for about 6 seconds.

I haven't been able to find anything that would explain this behavior, so I hope someone can tell me if this is normal behavior by the library.

Code: [Select]


#include <Wire.h>
#include <UnoWiFiDevEd.h>

int goalpin = 1;
int goalSensor   = 0;

const char* connector = "rest";
const char* server = "*******";
const char* method = "POST";
const char* resource = "*****";


void setup() {
 
Serial.begin(9600);
Ciao.begin();
        pinMode(btnPin, INPUT);
 
}

void loop() {

  goalSensor = analogRead(goalpin);
  if(goalSensor < 15){
    //GOAL
    doRequest(connector, server, resource, method);
    Serial.println("GOAAAAL!");
  } else {
     Serial.println("Waiting");
  }
}

void doRequest(const char* conn, const char* server, const char* command, const char* method){
CiaoData data = Ciao.write(conn, server, command, method);

  Serial.println("DONE SENDING");
  Ciao.println("DONE SENDING");

}


pylon

By default the REST request waits 7s for an answer from the server and returns if it doesn't get one. I guess your PHP part is the problem.

Go Up