[SOLVED] WiDo IoT Node Tutorial data not showing up in dashboard

Hi everyone,

I’m new to Ubidots and following the WiDo IoT Node Tutorial. It appears to work with the following monitor read-out:

Connected!
Request DHCP
Trying to connect to Ubidots…
Successfully connected to Ubidots.
Free RAM: 1565
{“value”:381}
Sending Http Request…Done…
Reading Cloud Response…

However nothing shows up in the corresponding variable view on the Ubidots website.

I’ve pasted my code below. I would greatly appreciate any ideas for making it work or at least suggestions for troubleshooting.

Thanks,
James

/***************************************************
* This is an example for the DFRobot Wido - Wifi Integrated IoT lite sensor and control node
* Product Page & More info: http://www.dfrobot.com/index.php?route=product/product&product_id=1159
* Designed specifically to work with the DFRobot Wido products:
*
* The library is forked from Adafruit
*
* Contributed by James
* BSD license, all text above must be included in any redistribution
* Modified by Agustin Pelaez for Ubidots, Inc.
****************************************************/

/*
This example code is used to connect the Ubidots cloud service (Official homepage: http://www.ubidots.com).
 The device required is just:
 1. LM35 low cost temperature sensor or any device you used to upload data
 2. And Wido
 Note: Please don't forget to change the setting below before using!
 1. WLAN_SSID & WlAN_PASS 
 2. API_key
 3. Device ID 
 */
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#define Wido_IRQ   7
#define Wido_VBAT  5
#define Wido_CS    10
#include "utility/debug.h"
Adafruit_CC3000 Wido = Adafruit_CC3000(Wido_CS, Wido_IRQ, Wido_VBAT,SPI_CLOCK_DIVIDER); // you can change this clock speed
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
#define WLAN_SSID       "mywifiname"         // cannot be longer than 32 characters!
#define WLAN_PASS       "mywifipassword"        // For connecting router or AP, don't forget to set the SSID and password here!!
#define TCP_TIMEOUT      3000
#define TOKEN  "mydefaulttoken"  
// Update you Ubidots token
#define VARIABLE_ID   "myvariableid"       // Replace with the id of the variable you wish to stream data to
void setup(){
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));
  /* Initialise the module */
  Serial.println(F("\nInitialising the CC3000 ..."));
  if (!Wido.begin())
  {
    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
    while(1);
  }
  /* Attempt to connect to an access point */
  char *ssid = WLAN_SSID;             /* Max 32 chars */
  Serial.print(F("\nAttempting to connect to ")); 
  Serial.println(ssid);
  /* NOTE: Secure connections are not available in 'Tiny' mode!
   By default connectToAP will retry indefinitely, however you can pass an
   optional maximum number of retries (greater than zero) as the fourth parameter.
   */
  if (!Wido.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  Serial.println(F("Connected!"));
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!Wido.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  
}
uint32_t ip = 0;    // Store Ubidots ip address
float temp = 0;     // Store temporary sensor data for post
Adafruit_CC3000_Client WidoClient;
void loop(){
  static unsigned long RetryMillis = 0;
  static unsigned long uploadtStamp = 0;
  static unsigned long sensortStamp = 0;
  if(!WidoClient.connected() && millis() - RetryMillis > TCP_TIMEOUT){
    // Update the time stamp for reconnecting the ip 
    RetryMillis = millis();
    Serial.println(F("Trying to connect to Ubidots..."));
    // Connect to Ubidots 
    ip = Wido.IP2U32(50,23,124,68);               
    WidoClient = Wido.connectTCP(ip, 80);         
    Serial.println(F("Successfully connected to Ubidots."));
  }
  if(WidoClient.connected() && millis() - uploadtStamp > 1000){
    // If the device is connected to the cloud server, upload the data every 1000ms.
    uploadtStamp = millis();
    // send http data stream to Ubidots
    sendstream2Ubidots(VARIABLE_ID, String(analogRead(0)));  // send the temperature sensor reading from LM35 sensor to server
    /********** Get the http page feedback and print the response ***********/
    unsigned long rTimer = millis();
    Serial.println(F("Reading Cloud Response...\r\n"));
    while (millis() - rTimer < 2000) {
      while (WidoClient.connected() && WidoClient.available()) {
        char c = WidoClient.read();
        Serial.print(c);
      }
    }
    delay(1000);             // Wait for 1s to finish posting the data stream   
    WidoClient.close();      // Close the service connection
    RetryMillis = millis();  // Reset the timer stamp for applying the connection with the service
  }
}
void sendstream2Ubidots(String variable, String value){
  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
  // Variables for storing the length of http package body 
  int length = 0;
  char lengthstr[5];
  String httpBodyPackage = "{\"value\":" + value + "}";
  Serial.println(httpBodyPackage);                       // Debug the http body stream
  //Make an HTTP request to the Ubidots server
  Serial.print(F("Sending Http Request..."));
  WidoClient.fastrprint(F("POST /api/v1.6/variables/"));
  WidoClient.fastrprint(VARIABLE_ID);
  WidoClient.fastrprintln(F("/values HTTP/1.1"));
  WidoClient.fastrprintln(F("Host: things.ubidots.com"));
  WidoClient.fastrprint(F("X-Auth-Token: "));
  WidoClient.fastrprintln(TOKEN);
  WidoClient.fastrprintln(F("Content-Type: application/json"));
  WidoClient.fastrprint(F("Content-Length: "));
  WidoClient.println(String(httpBodyPackage.length()));
  WidoClient.fastrprintln(F(""));
  WidoClient.println(httpBodyPackage);
  Serial.println(F("Done....."));
}

I got it working! All I had to do was install version 1.0.6 of the Arduino IDE instead of the newest version. For anyone else who comes across this problem you can download the older IDE here: https://www.arduino.cc/en/Main/OldSoftwareReleases

@James I’m glad to read that.

If you have other issue in the future i recommend you to read Ubidots documentation:
http://ubidots.com/docs/devices/wido.html

Best regards,
Metavix

hi guys, im new here.
thanks i am facing the same problem before, but i have another issue i just wondering if you guys could help me with the codes,
i am trying to control relay (on/off the actuator) via ubidots using wido, but i cant found any tutorial how to get data from the ubidots.

Please help me asap…

thanks

Hello @michaelrisci
you could see this post http://community.ubidots.com/t/solved-please-help-me-with-the-ubidots-on-off-control-codes-on-wido-board/394/4?u=metavix
There you will find the answer, adding a GET function. if you have problems with that, write us and we’ll help you as soon as possible.

Best regards,
Metavix