Hi David,
Thanks for your help. I shouldn’t be anywhere near the 4000 dots and the same code used to work on the education account.
Here is the output with debug set to true (below that is the relevant code)- It appears as it’s getting a 403 that the user can’t create a new variable, but the variable and device exist? Do I need to have something else set up on the Ubidots side now that it’s on a stem account instead of the old education account? I get the same 403 whether I use the variable name or id. The .get works fine:
Looping…
GET /api/v1.6/devices/Argon1/Light/lv HTTP/1.1
Host: industrial.api.ubidots.com
User-Agent: UbidotsParticle/3.2
X-Auth-Token:
Content-Type: application/json
Server’s response:
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 25 Mar 2021 12:40:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Allow: GET, HEAD, OPTIONS
Vary: Origin, Cookie
5
400.0
0
Value: 400.00
POST /api/v1.6/devices/ HTTP/1.1
Host: industrial.api.ubidots.com
User-Agent: UbidotsParticle/3.2
X-Auth-Token:
Connection: close
Content-Type: application/json
Content-Length: 119
{“light”:{“value”:1046,“context”: {“lat”:“37.772999”,“lng”:"-6.234500",“weather-status”:“sunny”,“time”:“11:51:00 pm”}}}
waiting for server answer …
Ubidots’ Server response:
HTTP/1.1 403 Forbidden
Server: nginx
Date: Thu, 25 Mar 2021 12:35:37 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Allow: GET, POST, HEAD, OPTIONS
Vary: Origin, Cookie
8d
{“light”: [{“errors”: {“error”: {“code”: 403001, “message”: “The user has not permissions to create a new variable.”}}, “status_code”: 403}]}
0
Values sent by device.
Here’s the relevant sending code:
double light = TSL2561.readVisibleLux();
float latitude = 37.773;
float longitude = -6.2345;
/* Reserves memory to store context key values, add as much as you need */
char* str_lat = (char*) malloc(sizeof(char)*10);
char* str_lng = (char*) malloc(sizeof(char)*10);
sprintf(str_lat,"%f",latitude);
sprintf(str_lng,"%f",longitude);
/* adds conext key-value pairs */
ubidots.addContext("lat",str_lat);
ubidots.addContext("lng",str_lng);
ubidots.addContext("weather-status","sunny");
ubidots.addContext("time","11:51:00 pm");
//reserve memory to store context array -
//minimally enough for number of characters in string + 1
char* context = (char*)malloc(sizeof(char)*90);
//build context with coordinates
ubidots.getContext(context);
//can have one add for each variable you want to send
ubidots.add("light",light,context); //I've also replaced "light" with the variable id with same results
bool bufferSent = false;
bufferSent = ubidots.send();
if (bufferSent) {
Serial.println("Values sent by device");
}
/* free up memory */
free(str_lat);
free(str_lng);
free(context);
delay(5000);