Hello Particle forum,
First posting to the forum but have been lurking for some time.
Been using a Boron to send data to Ubidots without any problems. Added a relay to the Boron and there seems to be an issue. Tried using only the Ubidots sample code and have the same problem.
No events logged until the first time I send a control command to the Boron and then the events log fills with this:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Tue, 13 Apr 2021 14:51:25 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
access-control-allow-origin: *
{“code”:400001,“message”:“The payload sent is not a valid json document.”}
The control works as desired but the events keep rolling in.
Which brings up a question, is every event considered a billable “data operation”?
The following code is copied from Ubidots “Create Ubidots Webhook to Particle to Control Things” doc.
// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>
int led = D7;
float control = 0;
int i = 0;
void setup() {
Serial.begin(115200);
// Subscribe to the integration response event
Particle.subscribe("UbidotsWebhook", myHandler);
pinMode(led, OUTPUT);
}
float setControl(float value) {
if (value == 1) {
return 1;
}
return 0;
}
void myHandler(const char *event, const char *data) {
// Handle the integration response
i++;
Serial.println(i);
Serial.print(event);
Serial.print(", data: ");
if (data) {
Serial.println(data);
control = setControl(atof(data));
} else {
Serial.println("NULL");
}
}
void loop() {
if (control == 1) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}
Searched the forum for a while and didn’t see a similar issue. Any ideas where to go from here?
Thank You,
John