[SOLVED] Please help me with the ubidots on/off control codes on WiDo board

hello everyone, i am totally new to this kind of stuff and about to learning.
i have followed the WiDo IoT Tutorial and able to send a single moisture sensor data variable, but i don’t know the syntax how to control relay (on/off the actuator) from Ubidots.

I am bout to make an automatic irrigation system with soil moisture sensor, when sensor detect dry soil, the water pump is on. Ubidots is for monitoring. For emergency situation i want to make on/off control for the water pump.

Please Help me…

Hi @michaelrisci to be able to turn your pump on/off you need to create a Ubidots control variable and read it from your device by making a GET request.

Right now our WiDo tutorial doesn’t have a GET example, will forward your request to other members in the community to see if someone has built one. It should be as simple as changing the function below to a GET request, and parsing the response:

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

thanks for the reply
i have changing it, but this is what i got :

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

HTTP/1.1 404 NOT FOUND
Server: nginx
Date: Thu, 09 Jun 2016 07:23:10 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS

17
{“detail”: “Not found”}
0

Trying to connect to Ubidots…
Successfully connected to Ubidots.
Free RAM: 1623
{“value”:265}
Sending Http Request…

here is my codeitnoj.ino (3.2 KB)

honestly i dont really understand. and i am slow, so please bare with me.

@michaelrisci
Could you try change this part of your code:

//Make an HTTP request to the Ubidots server
      Serial.print(F("Sending Http Request..."));
      WidoClient.fastrprint(F("GET /api/v1.6/variables/"));
      WidoClient.fastrprint(VARIABLE_ID);
      WidoClient.fastrprint(F("/values/?page_size=1&token="));
      WidoClient.fastrprint(TOKEN);
      WidoClient.fastrprintln(F(" HTTP/1.1"));
      WidoClient.fastrprintln(F("Content-Type: application/json"));
      WidoClient.fastrprint(F("Host: things.ubidots.com"));
      WidoClient.fastrprint("Host: things.ubidots.com");
      Serial.println(F("Done....."));

for this:


//Make an HTTP request to the Ubidots server
      Serial.print(F("Sending Http Request..."));
      WidoClient.fastrprint(F("GET /api/v1.6/variables/"));
      WidoClient.fastrprint(VARIABLE_ID);
      WidoClient.fastrprint(F("/values/?page_size=1&token="));
      WidoClient.fastrprint(TOKEN);
      WidoClient.fastrprintln(F(" HTTP/1.1"));
      WidoClient.fastrprintln(F("Content-Type: application/json"));
      WidoClient.fastrprintln(F("Host: things.ubidots.com"));
      WidoClient.fastrprintln(F("Connection: close"));
      WidoClient.fastrprintln();
      Serial.println(F("Done....."));