I have tried the Ubidots serial Library (telemetry and logger) with Arduino UNO finally i got success. My values are showing up on Ubidots dashboard. But the problem is 2 variables values are showing but if i send 3rd variable it doesn’t show up what is the exact problem? Am i sending wrong logger command? here is my code:
#include<SoftwareSerial.h>
SoftwareSerial wifi(2,3);
/****************************************
* Define Constants
****************************************/
namespace {
const char * USER_AGENT = "UbidotsESP8266"; // Assgin the user agent
const char * VERSION = "1.0"; // Assign the version
const char * METHOD = "POST"; // Set the method
const char * TOKEN = "xxxxxxxxxxxxxx"; // Assign your Ubidots TOKEN
const char * DEVICE_NAME = "xxxxxxxx"; // Assign the desire device name
const char * DEVICE_LABEL = "xxxxxxx"; // Assign the device label
const char * VARIABLE_LABEL_1 = "temperature"; // Assign the variable label
const char * VARIABLE_LABEL_2 = "heart-rate"; // Assign the variable label
const char * VARIABLE_LABEL_3 = "blood-pressure"; // Assign the variable label
}
char command[700]; // command
char telemetry_unit[100]; // response of the telemetry unit
/* Space to store values to send */
char str_sensor1[10];
char str_sensor2[10];
char str_sensor3[10];
/****************************************
* Main Functions
****************************************/
void setup() {
Serial.begin(115200);
wifi.begin(115200);
}
void loop() {
/* Analog reading */
float sensor1 = 316.00;
float sensor2 = 225.25;
float sensor3 = 234.33;
/* 4 is mininum width, 2 is precision; float value is copied onto str_sensor*/
dtostrf(sensor1, 4, 2, str_sensor1);
dtostrf(sensor2, 4, 2, str_sensor2);
dtostrf(sensor3, 4, 2, str_sensor3);
/* Building the logger command */
sprintf(command, "init#");
sprintf(command, "%s%s/%s|%s|%s|", command, USER_AGENT, VERSION, METHOD, TOKEN);
sprintf(command, "%s%s:%s=>", command, DEVICE_NAME, DEVICE_LABEL);
sprintf(command, "%s%s:%s", command, VARIABLE_LABEL_1, str_sensor1);
sprintf(command, "%s,%s:%s", command, VARIABLE_LABEL_2, str_sensor2); // uncomment this line to send sensor 2 values
sprintf(command, "%s,%s:%s", command, VARIABLE_LABEL_3, str_sensor3);
sprintf(command, "%s|end#final", command);
/* Prints the command sent */
//Serial.println(command);// uncomment this line to print the command
/* Sends the command to the telemetry unit */
wifi.print(command);
/* Reading the telemetry unit */
int i = 0;
while (wifi.available() > 0) {
telemetry_unit[i++] = (char)wifi.read();
}
Serial.println(telemetry_unit);
i = 0;
delay(5000);
}`
Please also check my logger command