GSM 900 and dweet.io

Hello everyone! New here... Searched everywhere and cant seems to find any ways to use my GPRS shield with Sim 900 on board, and dweet.io. I am able to text and access the internet via the shield using serial monitor sketch i found on the internet, using AT commands. I have a gps long and lat data that needs to be uploaded using dweeting. I have tried to do it via http and TCP and cant seems to get it to work. Looking around here at some examples and sim 900 manual i have a code that does not seem to work. It compiles fine, uploads just nothing in the serial monitor or dweet.io. Any help would be really appreciated. U guys are my last resort:)
Thank you in advance!!!

#include <SoftwareSerial.h>
SoftwareSerial GSM(10,11);

void printSerialData()
{
 while(GSM.available()!=0)
 Serial.write(GSM.read());
}


void setup()
{
  Serial.begin(9600);  
  
}
void loop()
{
  GSM.println("AT+CGATT?");   
  delay(300); 
  GSM.println("AT+CIPMUX=0");
  delay(300); 
  GSM.println("AT+CIPMODE=0");
  delay(300); 
  GSM.println("AT+CIPSHUT=0");  
  delay(300); 
  GSM.println("AT+SAPBR=3,1,\"APN\",\"fast.t-mobile.com\"");
  delay(1000); 
  GSM.println("AT+CIICR");
  delay(300); 
  GSM.println("AT+CIFSR");
  delay(2000); 
  GSM.println("AT+CIPSPRT=0");
  delay(3000);
  GSM.println("AT+CIPSTART=\"TCP\",\"www.dweet.io\",\"80\"");
  delay(2000); 
  Serial.println();
  GSM.println("AT+CIPSEND");
  delay(4500);
  GSM.print("GET /dweet/for/MYTHINGNAME?Test?");
  delay(500);
  
  printSerialData();
  int x=1;
  int y=2;
  int z=3;
  
  GSM.print("X");   
  GSM.print(x);   
  delay(10);
  printSerialData();

  GSM.print("Y");   /
  GSM.print(y);   
  delay(10);
  printSerialData();
  
  GSM.print("Z");   
  GSM.print(z);   
  delay(10);
  printSerialData();
  
  GSM.print(" HTTP/1.1\r\n");
  delay(500);
  printSerialData();
  
  GSM.print("Host: www.dweet.io\r\n");
  delay(500);
  printSerialData();
  

  GSM.print("Connection: keep-alive"); 
  //GSM.print("Connection: close");         
  GSM.print("\r\n");
  GSM.print("\r\n");
  //GSM.println();
  delay(500);
  printSerialData();

  GSM.println("AT+CIPCLOSE");
  delay(100);
  printSerialData();
  
  GSM.println("AT+CIPSHUT=0");
  delay(100); 
  printSerialData();
  
}

ARD.ino (1.52 KB)

Why do you print serial data while building the GET? You should complete the request, send it and then print. The way you print does not guarantee you printed everything, you probably need a timeout or track the end of the http answer

The two question marks in the GET URL seems weird GET /dweet/for/MYTHINGNAME[color=red]?[/color]Test[color=red]?[/color], what should the full GET url look like? --> Look at Your GET request and test it manually using telnet for example

Thank you for you respond...Will fix the printin lines....
The way dweets work is u call them simply by requesting the following url:
https://dweet.io/dweet/for/my-thing-name?hello=world...Anything after? is text to send as a dweet
I tried using AT commands t call this url, but nothing happenes.....
Thank you...

OK is it http or htttps? Is https how is the crypto/security/identification handled ?

I got it to work with this line of code(Thanks to iforce2d on YouTube and his videos. Very informative, it works now that I changed from http:dweet...// to www.dweet..... Now I would like to upload a float variable that is constantly changes, in my WiFi it looked this with a string :

client.print(String("GET /dweet/for/MTTHINGNAME?TEXTENETERHERE") +"&4=" + String(h) +"&5=" + String(t)+ " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");

t and h are floats

Here is the code that is now working dweeting, just need to figure out the variable upload.

#include <SoftwareSerial.h>
SoftwareSerial myGsm(10,11);

void setup()
{
 myGsm.begin(9600);  
 Serial.begin(9600);  
 delay(500);
 
 myGsm.println("AT+CGATT=1");
 delay(200);
 printSerialData();
 
 myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR,connection type is GPRS
 delay(1000);
 printSerialData();
 
 myGsm.println("AT+SAPBR=3,1,\"APN\",\"fast.t-mobile.com\"");//setting the APN,2nd parameter empty works for all networks 
 delay(5000);
 printSerialData();
 
 myGsm.println();
 myGsm.println("AT+SAPBR=1,1");
 delay(10000);
 printSerialData();
 
 myGsm.println("AT+HTTPINIT"); //init the HTTP request
 delay(2000); 
 printSerialData();

 
 
 myGsm.println("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/MYTHINGNAME?7TEXTTOSEND\"");// setting the httppara, 
 //the second parameter is the website from where you want to access data 
 delay(1000);
 printSerialData();
 
 myGsm.println();

// myGsm.println("");
// delay(1000);
// myGsm.println("AT+HTTPTERM");// terminate HTTP service
// printSerialData();

}

void loop()
{
  
  myGsm.println();
  myGsm.println("AT+HTTPACTION=0");//submit the GET request 
 delay(8000);//the delay is important if the return datas are very large, the time required longer.
 printSerialData();
 myGsm.println("AT+HTTPREAD=0,601");// read the data from the website you access
 delay(3000);
 printSerialData();
}


void printSerialData()
{
 while(myGsm.available()!=0)
 Serial.write(myGsm.read());
}

Thank you for all your help in advance....

To send your data the first approach was correct, split the GET command in chunks and don't use the String class. For example if you need to send

GET /dweet/for/MTTHINGNAME?Xyz&4=[color=blue]6789[/color]&5=[color=red]6543[/color] HTTP/1.1\r\n

Where the blue/red parts come from variable values then build the requests in multiple steps, that's more memory efficient than building up a long string holding the query

myGsm.print(F("GET /dweet/for/MTTHINGNAME?Xyz&4="));
myGsm.print([color=blue]variable4[/color]); // the value 6789
myGsm.print(F("&5="));
myGsm.print([color=red]variable5[/color]); // the value 6543
myGsm.print(F(" HTTP/1.1\r\n"));

Note that the code below is a poor construct that will likely not be very efficient/effective

 delay(8000);//the delay is important if the return datas are very large, the time required longer.
 printSerialData();

whatever the size of the data, you can't predict how fast internet will be nor you want the answer to accumulate in a buffer given you have very very limited ram available in your arduino. And your code will become super slow, being totally stuck for many seconds all the time even though the data you need is back. This is the result of a poor way of handling the response without taking into account the asynchronous nature of the data flow. The way this should work is

  • send a command (the GET request)
  • wait for the answer and dynamically parse/extract the relevant data from the flow until end of answer / connection close / a given timeout - whatever arrive first

Thank you!
I am trying now and it does not look like its working, I am certain that I am missing something.
Do u mean to use the get command in my first code? Also, what to use if not string?

Do you think i can somehow modify this to get to work rather then debug my first buggy code?

float x=4;
float y=5;
 
 myGsm.println("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT&X="+ String(x) + "&Y=" +String(y));// setting the httppara, 
 //the second parameter is the website from where you want to access data 
 delay(1000);
 printSerialData();

The result I am getting in dweets is this:

this	"succeeded"
by	"getting"
the	"dweets"
with	
0	
thing	"MYTHING"
created	"2017-07-02T09:27:58.896Z"
content	
TEXTTOSEND	""
X	"x"
Y

Thank you in advance!!!

Something of this sort? Does not work:)
Thank you for you patience i just started to learn c++ and arduino IDE.

int x=6789;
int y=6543;
 myGsm.println("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT");
 
 //myGsm.print(F("GET /dweet/for/MTTHINGNAME?Xyz&4="));
myGsm.print(F("&4="));
myGsm.print(x); // the value 6789
myGsm.print(F("&5="));
myGsm.print(y); // the value 6543
myGsm.print(F(" HTTP/1.1\r\n"));

this won't work

 myGsm.println("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT&X="+ String(x) + "&Y=" +String(y));// setting the httppara,

because the first element won't be automatically transformed into the String class and thus the + operator will fail to be the one you want. Would need to be written as

 myGsm.println(String("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT&X=")+ String(x) + "&Y=" +String(y));// setting the httppara,

the second version with myGsm.println("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT"); does not work because you use println. This adds a "\r\n" at the end of the string for you and you end up with a wrongly structured GET request

try with print, not println

Thank you for your reply.
I Have tried different ways including the last one u suggested and it does not work. This is the only line that worksmyGsm.print("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Mythingname?Test\"")
when i use this line of code Print serial shows that dweet went out but i get nothing at the end...

myGsm.print(String("AT+HTTPPARA=\"URL\",\"www.dweet.io/dweet/for/Smart-Helmet?TEXT&X=")+ String(x) + "&Y=" +String(y));
T+CGATT=1

OK
AT+SAPBR=3,1,"CONTYPE","GPRS"

OK
AT+SAPBR=3,1,"APN","fast.t-mobile.com"

OK

AT+SAPBR=1,1

ERROR
AT+HTTPINIT

ERROR
AT+HTTPPARA="URL","www.dweet.io/dweet/for/Smart-Helmet?TEXT&X=1

AT+HTTPACTION=0

ERROR
AT+HTTPREAD=0,601

OK

AT+HTTPACTION=0

OK
AT+HTTPREAD=0,601

OK

+HTTPACTION:0,603,0

AT+HTTPACTION=0

OK

+HTTPACTION:0,200,194
AT+HTTPREAD=0,601

+HTTPREAD:194
{"this":"succeeded","by":"d
AT+HTTPACTION=0

OK

+HTTPACTION:0,200,194
AT+HTTPREAD=0,601

+HTTPREAD:194
{"this":"succeeded","by":"d
AT+HTTPACTION=0

OK
AT+HTTPREAD=0,601

OK

+HTTPACTION:0,601,0

AT+HTTPACTION=0

OK
AT+HTTPREAD=0,601

OK

AT+HTTPACTION=0

OK

+HTTPACTION:0,604,0

+HTTPACTION:0AT+HTTPREAD=0,601

OK

AT+HTTPACTION=0

OK
AT+HTTPREAD=0,601

OK

AT+HTTPACTION=0

OK

+HTTPACTION:0,604,0
AT+HTTPREAD=0,601

OK

AT+HTTPACTION=0

OK

+HTTPACTION:0,604,0

+HTTPACTION:0AT+HTTPREAD=0,601

+HTTPREAD:194
{"this":"succeeded","by":"d

I believe its a syntax problem, i looked around tried severasl diffrent ways and still nothing.
Any Ideas?
Thank you....!

You have config errors in your AT commands even before that as AT+SAPBR=1,1 fails as well as your AT+HTTPINIT

Do you need user name and pwd for your APN? Explore AT+CSTT

If I were you I'd write a small program letting you enter the commands from the serial console and explore manually exactly what AT sequences need to be sent for a GET request. Once you have this working reliably then this is what you do in your program

I have done via AT commands only, found a code that does it. Some errors are produced due to the fact that parameters of the given command were already set. After the restart of the sim 900 it went thru without errors. Just APN needed no pass or user name, when i run just at commands I do see assigned IP adders. With just at commands it works just fine, but there is no way to test it with a variable.. I am going to explore CSTT command.
It dweets fine as long as i dont try to input any variables in the code...

Thank you very much....

Very exited, got this stupid thing to work! The problem was that we were missing http//: from the get setup. Syntax error as i suspected.

Here is a final working code for dweet.io, gsm shield sim 900 and arduino mega 25... Hope this will help someone, it took me a full week to get this to do what it suppose to do:)

#include <SoftwareSerial.h>
SoftwareSerial myGsm(10, 11);

void setup()
{
  myGsm.begin(9600);
  Serial.begin(9600);

  Serial.println("Connection");
  delay(2000);
  Serial.println("Complete!...");
  myGsm.flush();
  Serial.flush();


  // Cheking to see if gprs is attached
  myGsm.println("AT+CGATT?");
  delay(1000);
  PrintSerialData();

  // Check signal strength
  myGsm.println("AT+CSQ ");
  delay(1000);
  PrintSerialData();

  // Set connection type to GPRS
  myGsm.println("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
  delay(2000);
  PrintSerialData();

  // Set the APN
  myGsm.println("AT+SAPBR=3,1,\"APN\",\"fast.t-mobile.com\"");
  delay(2000);
  PrintSerialData();

  // Enable GPRS
  myGsm.println("AT+SAPBR=1,1");
  delay(10000);
  PrintSerialData();

  // Check to see if connection is correct and get your IP address
  myGsm.println("AT+SAPBR=2,1");
  delay(2000);
  PrintSerialData();

}


void loop()
{

  float x=10;
  float y=11;
   // Start http service
   myGsm.println("AT+HTTPINIT");
   delay(2000); 
   PrintSerialData();

   // Set value
   
   myGsm.println(String("AT+HTTPPARA=\"URL\",\"http://www.dweet.io/dweet/for/MYthingname?lat="+ String(x)+"&lon="+ String(y)+"\""));
   delay(4000);
   PrintSerialData();

   // set http action type 0 = GET
   myGsm.println("AT+HTTPACTION=0");
   delay(6000);
   PrintSerialData();

   // read server response
   myGsm.println("AT+HTTPREAD"); 
   delay(1000);
   PrintSerialData();

   //myGsm.println("");
   myGsm.println("AT+HTTPTERM");
   PrintSerialData();
   delay(300);

   myGsm.println("");
   delay(10000);
}

void PrintSerialData()
{
  while(myGsm.available()!=0)
  {
    Serial.write(myGsm.read());
  }
}

The code needs cleaning but it works:)
Thank you J M L for all your help, I would never figure this one out without u sir.

great news! congrats on solving this

I was reading through your posts. I was wondering if anyone here would know how to dweet.io my current IP address. When I send it in the POST it is 10 numbers which are right. Thanks in advance.