POST sensor values to Ubidots. How?

Hi and thanks for reading.

I would really like to send data to and get data from the cloud. http://ubidots.com/ is one example. Has anyone been able to POST/GET values to/from the web yet?

Ubidots has an example of how to do this with a LinkIt One Dev board(made by Seeed) which uses the same MediaTek chip, but I have not been able to port the MediaTek libraries over to the RePhone IDE. Above my pay grade. The example is here. http://ubidots.com/docs/devices/linkitone.html.

In the Ubidots example several libraries are used:

#include <LGPS.h> // LinkIt GPS Library
#include <LBattery.h> // Want to be able to read the battery charge level
#include <LGPRS.h> //include the base GPRS library
#include <LGPRSClient.h> //include the ability to Post and Get information using HTTP

LGPRSClient.h and its dependents seems to be key to getting this to work.

Can someone at Seeedstudio please create an example of how to POST and GET data from/to the web? Preferably using Ubidots as a use case.

To me this cloud connectivity should be a core capability of the GSM module and deserves some attention.

Anyone agree?

Thank you

Hi, thanks for mentioning the ubidots.

And to your part: have you ever tested your GPRS connection? I would start with that. My rephone once lost the GSM connection and I had to restart, maybe you encountered a similar problem.
Also, do you program it via Arduino, or the Eclipse? You should try first with a working example. Maybe the example works, but you don’t have internet :slight_smile:

What is this “internet”? It’s not in any of my papyrus scrolls! Perhaps a new tool for fishing in the not yet dead sea?

For my part, I installed the “LinkIt by MediaTek” extension on a non-rephone Arduino IDE. My hope was to transfer(copy/paste) the necessary Mediatek files(libraries and .h files) over to the RePhone for Arduino IDE such that the Rephone could access them.

Long story short. The Ubidots example code wouldn’t compile within the Rephone IDE. I would be glad to document error messages if it would help to achieve the POST/GET functionality.

My hope is that since Seeedstudio developed the LinkIt One dev board, a handful of other GSM shields for Arduino and now the RePhone they may be kind enough to provide an example(with needed files) from within the RePhone for Arduino IDE of how to POST/GET sensor values to/from the internet. This would be great.

A little help getting started would be very much appreciated.

Hi there, here some community examples of Linkit + Ubidots. Hope this helps!

hackster.io/alpha007/temper … ger-767570
hackster.io/AgustinP/loggin … oud-532ba0
hackster.io/alpha007/temper … ger-767570
hackster.io/Laura_Vargas/e- … art-5b7edf
hackster.io/10867/longer-li … ers-f17f13
hackster.io/sarthaksethi/cr … lth-d37116

There are gprs library and post examples for linkit one but how about on rephone how you do it seeedstudio?

@agustin.pelaez Thanks for the examples. Will give them a try. Ubidots is great! And I’d like to get my RePhones working with Ubidots.

The “LPGRSClient.h” and “LGPRS.h” are both #include in those examples. Neither of them are in my RePhone folders or MediaTek LinkIt™ ONE SDK folders. Deprecated? Or not the right file types to be using? Not sure.

I’m on a hunt for them now to see if they work with RePhone or not. Haven’t found them on the MediaTek site or Github.

If anyone one has those files or knows where I can get them please chime in.

Thank you

Update: Found the necessary files used by the Mediatek LinkIt One devices for POST/GET requests. Pasted them into the RePhone IDE folders and the compile errors just won’t quit despite my best efforts. Perhaps my approach is wrong footed.

I’ve been able to use arduinos+2G shields, ardiono+wifi shields, arduino Yuns and Particle Photons with Ubidots, but not with the RePhone module. At least not yet :wink:

Dear Seeedstudio folks. Can you help me out?

Hi there:
I’m joining the petition too; some POST/GET examples would be great, since using sms for uploading data is a bit short for my project.
By the way ¿Is there any posibility to attach a wifi shield or ESP8266 module to the breakout module for WLAN communication?

Thank you very much
David.

So, I have made a bit of progress on Getting values from Ubidots. The code isn’t ideal for a couple of reasons, but it’s a start.
By hard-entering a variable ID and a token into the "#define TEST_URL) line the sketch will GET the variable’s value and print it to the serial console.
Please note that to send the GET(each time) you must have a console window open and send something to Serial. I just hit “enter” and that does the job.

One feature missing here is being able to insert variable_IDs and Tokens as variables. Does anyone know how to accomplish this? Nothing I’ve tried has worked. The #define TEST_URL needs quotes around the URL and when I try inserting variables compile errors result.

Something like this would be ideal. Where VARIABLE_ID and TOKEN are pre-defined strings or whatever type.

String VARIABLE_ID = “1234567890”;
String TOKEN = “abcdefg”;

#define TEST_URL "http://things.ubidots.com/api/v1.6/variables/“VARIABLE_ID”/values?page_size=1&token="TOKEN;

Any thoughts?

Making JSON POSTs is a different story altogether. The author of the Network_HTTPS example sketch would surely make quick work of it :wink: , but it has dogged me for a week :confused: .

Anyway here is what I have so far.

#include <Lhttps.h>


#define TEST_URL "http://things.ubidots.com/api/v1.6/variables/56aba42d7625427198b75b54/values?page_size=1&token=h5g5rSjUeYksa3GFQxiEbI8mrmu3NY"

int value_index = 0;
String response_body,value_string, value;   // We'll use these strings to parse the response from Ubidots

char *buffer;

void setup(void)
{
  Serial.begin(115200);
  while(!Serial.available()); 
  Serial.print("https test.\r\n");
  Serial.flush();
  
  https.get_handle(print_url);
  https.connect(TEST_URL);
}

void loop(void)
{
  
  while(!Serial.available()); 
  Serial.flush();
  
  https.connect(TEST_URL);
   
}

void print_url(char *content, unsigned long len)
{
  
  //Serial.println(content);
  
  response_body = (content);
  
  value_index = response_body.indexOf("\"value\": ");
  
  // Chop the response from that index, until the end of the response string
  value_string = response_body.substring(value_index);
  
  // Get the value that is between the nine (9) characters of "\"-v-a-l-u-e-\"-: " and the next comma
  value = value_string.substring(9, value_string.indexOf(","));
  
  Serial.println(value);
  
 }

Cheers, that was a nice advance!
i’m also looking for a proper way to handle POST and GET JSONs through https; Hope some kind of example comes soon.
Ty vm for your effort!

Best regards,
David.