[SOLVED] Ubidots didn't received data from arduino uno


#1

Hi,
Im using arduino uno and espresso lite v2.0 as my wifi module and i connected them like this https://tutorial.cytron.io/wp-content/uploads/2017/02/13.png.

And here is the code that i used to upload
UbidotsSaveValue.ino (1.4 KB)

and the Serial output showed like thisCapture

but then when i open my ubidots dashboard, nothing is showing up.
anyone know what is the problem?
thanks!


#2

Dear @kelvinswee94,

As I can noted in your code, you are using the “Ubidots Arduino Library”, and the library is deprecated since months ago; you can refer to the README of the library to see the note.

To start with your Arduino UNO + Espresso lite v2.0 I recommend you take a look of the examples provided in this page, especific the HTTP client example. Once you are able to get the HTTP client example works, modify the request of the example to the Ubidots Server, for more information see the Ubidots REST API Reference.

All the best,
Maria C.


#3

Hi @mariahernandez
thanks for the advice, i have try using the code below and try to send the data to ubidots:

#include <CytronWiFiShield.h>
#include <CytronWiFiClient.h>
#include <SoftwareSerial.h>

const char* ssid = “alexoi ASUS”;
const char* pass = “ooi888168”;

const char* host = “things.ubidots.com”;
const int httpPort = 80;

void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
if(!wifi.begin(2, 3))
Serial.println(F(“Error talking to shield”));
Serial.println(F(“Start wifi connection”));
if(!wifi.connectAP(ssid, pass))
Serial.println(F(“Error connecting to WiFi”));
Serial.print(F("Connected to: "));Serial.println(wifi.SSID());
Serial.print(F("IP address: "));Serial.println(wifi.localIP());

ESP8266Client client;
Serial.print("Connecting to “);
Serial.println(host);
if (client.connect(host, httpPort))
{
Serial.println(“connected to server”);
// Make a HTTP request:
String url = " /api/v1.6/devices/traffic_data/?token=A1E-Gu5oibBAWNLraQA3Vg5AScC3WCkr3n”;
String value = “{“yes”: 31.2}”;
Serial.print("requesting URL: ");
client.print(String("POST “) + url + " HTTP/1.1\r\n” +
"Host: " + “things.ubidots.com” + “\r\n” +
“Content-Type: application/json\r\n” +
“Connection: close\r\n\r\n” +
value + “\r\n”);
}

Serial.println(“request sent”);
client.stop();
}

void loop() {
}

and the Serial.Monitor output is as belowCapture

the http request is not showing in the serial monitor and the data is not uploaded to ubidots,what code should i add on it?
thanks


#4

Dear @kelvinswee94,

As I can noted the request built is the right one, and regrettably I don’t have the module at the office to try to reproduce the behavior.

I review the library used in the examples provided in the page, which is “ESPert”, and I found an MQTT example too. In order of this, please follow this example and adapt it to your needs. Reference to the Ubidots MQTT documentation for more detail.

All the best,
Maria C.