ubidots / ubidots-arduino-gprs

MIT License
9 stars 10 forks source link

Get value not working #11

Closed tusharvb19 closed 8 years ago

tusharvb19 commented 8 years ago

The get value code seems having some bug!!! I tried the version 1 but it was giving constant value 1 or 1.0 and now version 2 is not getting output after SAPBR=1,1

Metavix commented 8 years ago

@tusharvb19 hello! Could you post here all of the Serial monitor. Thanks It will be help me to help you

tusharvb19 commented 8 years ago

Now i am getting this at serial monitor...

Response of GPRS:

Response of GPRS: AT OK

Response of GPRS: AT+CSQ +CSQ: 17,0

OK

Response of GPRS: AT+CGATT? +CGATT: 1

OK

Response of GPRS: AT+SAPBR=3,1,"CONTYPE","GPRS" OK

Response of GPRS: AT+SAPBR=3,1,"APN","www" OK

Response of GPRS: AT+SAPBR=3,1,"USER","" OK

Response of GPRS: AT+SAPBR=3,1,"PWD","" OK

Response of GPRS: AT+SAPBR=1,1 OK

Response of GPRS: AT+SAPBR=2,1 +SAPBR: 1,1,"10.136.192.121"

OK

Response of GPRS: AT+CIPMUX=0 OK

Response of GPRS: AT+CIPSTART="TCP","translate.ubidots.com","9010" OK

CONNECT OK

Response of GPRS: AT+CIPSEND=104

Response of GPRS: GPRS/2.0|LV|1ppM5HWgmeSlIgEMdTpeoU06P0LppV|Your_data_source_identifier_here:57947bb8762542115059db66|end SEND OK ER|Data Source not found GPRS/2.0|LV|1ppM5HWgmeSlIgEMdTpeoU06P0LppV|Your_data_source_identifier_here:57947bb8762542115059db66|end SEND OK ER|Data Source not found Response of GPRS: AT+CIPCLOSE CLOSE OK

Response of GPRS: AT+CIPSHUT SHUT OK 0.00 0.00

tusharvb19 commented 8 years ago

After replacing the Your_data_source_identifier_here with my data source label giving the same output!!! I am not getting the GET request.

tusharvb19 commented 8 years ago

Also while trying TCP i got the following response and again unsuccessful performing GET!!!

AT+CIPSTART="tcp","things.ubidots.com","80"

OK

CONNECT OK AT+CIPSEND GET /api/v1.6/variables/57947bb8762542115059db66 /values?token=1ppM5HWgmeSlIgEMdTpeoU06P0LppV &page_size=1 HTTP/1.1 Host: things.ubidots.com 

SEND OK

302 Found
Metavix commented 8 years ago

@tusharvb19 Nice i know where is the problem of your code of the first comment. Please paste here your code to change the lines with the error and do it work's! I'm talking about the code of this Serial response:

  Response of GPRS:
  AT+CIPSEND=104

  Response of GPRS:
  GPRS/2.0|LV|1ppM5HWgmeSlIgEMdTpeoU06P0LppV|Your_data_source_identifier_here:57947bb87  62542115059db66|end
  SEND OK
  ER|Data Source not found
    GPRS/2.0|LV|1ppM5HWgmeSlIgEMdTpeoU06P0LppV|Your_data_source_identifier_here:57947bb8762542115059db66|end
  SEND OK
  ER|Data Source not found
  Response of GPRS:
  AT+CIPCLOSE
  CLOSE OK
  Response of GPRS:
  AT+CIPSHUT
  SHUT OK
  0.00
  0.00
tusharvb19 commented 8 years ago

This is my code-

include

include

define APN "www"

define USER "" // If your apn doesnt have username just put ""

define PASS "" // If your apn doesnt have password just put ""

define TOKEN "1ppM5HWgmeSlIgEMdTpeoU06P0LppV" // Replace it with your Ubidots token

define DATA_SOURCE_IDENTIFIER "mds"

define VARIABLE_IDENTIFIER "temperature"

Ubidots client(TOKEN);

SoftwareSerial gprs = SoftwareSerial(2,3); SoftwareSerial *GPRSSerial = &gprs;

void setup() { Serial.begin(115200); GPRSSerial->begin(19200); if (! client.init(*GPRSSerial)) { Serial.println(F("Couldn't find FONA")); while (1); } while (!client.setApn(APN,USER,PASS)); }

void loop() { float value = client.getValueWithDatasource(DATA_SOURCE_IDENTIFIER, VARIABLE_IDENTIFIER); Serial.println(value); delay(1000); Serial.println(value); }

Metavix commented 8 years ago

@tusharvb19 Your data source identifier is mds? This is a variable identifier and data source identifier: screenshot from 2016-08-18 15-48-09 screenshot from 2016-08-18 15-48-13

tusharvb19 commented 8 years ago

I have inputted the same...Data source identifier-source label and variable label but still it is not working!!! The code is now giving output as error authorising credentials... The another tcp raw code(direct AT commands) gives me output as "302 Found"

Metavix commented 8 years ago

Hello @tusharvb19 sorry, my last response was wrong, it isn't with labels, it is with data source tag and variable tag:

screenshot from 2016-08-19 08-22-16 screenshot from 2016-08-19 08-22-08

Really sorry i was wrong. If you put a tag to your data source named "mds" and tag to a variable "temperature" and uses the next code it will work:

#include <UbidotsArduinoGPRS.h>
#include <SoftwareSerial.h> 
//Serial Relay - Arduino will patch a 
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART 

#define APN "www" 
#define USER "" // If your apn doesnt have username just put ""
#define PASS "" // If your apn doesnt have password just put ""
#define TOKEN "1ppM5HWgmeSlIgEMdTpeoU06P0LppV" // Replace it with your Ubidots token
#define DATA_SOURCE_IDENTIFIER "mds"
#define VARIABLE_IDENTIFIER "temperature"

Ubidots client(TOKEN);  

void setup() {
  Serial.begin(115200);
  GPRSSerial->begin(19200);
  if (! client.init(*GPRSSerial)) {
    Serial.println(F("Couldn't find FONA"));
    while (1);
  }
  while (!client.setApn(APN,USER,PASS));
}

void loop() {
  float value = client.getValueWithDatasource(DATA_SOURCE_IDENTIFIER, VARIABLE_IDENTIFIER));
  Serial.println(value);
  delay(1000);
  Serial.println(value);
}
tusharvb19 commented 8 years ago

Finally got that working!!! Thank you very much... really thanx..

Metavix commented 8 years ago

@tusharvb19 no problem. Thank to you and sorry again for my wrong answeer the first time.