Particle publish variable to dashbooard no longer working since switching to STEM from education

Hi, I’m using the example for Particle devices to publish a variable to the dashboard. When I was using the education account, it worked fine. Now that I’ve migrated to the STEM account, it no longer works. With the education account the server parameter UBI_EDUCATIONAL was available, which is no longer an option, so I’m just using: Ubidots ubidots(TOKEN, UBI_HTTP); When I do ubidots.send(); it returns true as being successful, but the dashboard and/or variable is not being updated?

The get function works fine. I just can’t find the variable values that I send.

Hi @bfrench,

Can you please enable the library’s debug messages so we can see the response from our server in the Serial monitor? You can activate those messages by putting the below line in your setup() function

ubidots.setDebug(true);

Once you do this, please take a screenshot of the serial monitor and paste here so I can have a look to the server’s whole response.

In the meantime, I recommend having a look to the below article that shows the limitation of STEM accounts. Maybe, the issue is that you hit the daily Dots quota, which is 4,000 Dots.

–David

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);

You are getting a 403 response code, which means that the token that you are using does not have permission to ingest data to your Ubidots account or the target device. If you are using a device token, please make sure yourself that the token has permissions to send data, as explained in this article.

If you are not using a device token, please make sure to use an account token:

All the best

Thanks for your reply. When I use the account token, it creates a new device and variable. If I use the device token to update the existing device’s existing variable (which is what I was doing), I get the 403.

Per the article you reference: Device tokens cannot be used to create, edit or delete devices or variables., it appears as though “edit” a variable includes updating/publishing it’s value.

Thanks again for your help. It clears up what was going on.