Jump to content
43oh

How to make an HTTP request through SIM900 in MSP430F5529 using Energia software?


Recommended Posts

I am interfacing LM35 and SIM900 using MSP430F5529 board . For this purpose i am using Energia software . As we all know arduino code is compatible in Energia . Hence , I have used the same code that i used in Arduino Uno . The code works fine and i get my thingspeak channel updated with every HTTP request however , when i use Energia , it doesnt show any error , neither does it show/update my thingspeak channel . 

 

I had used Pin 7 and 8 for receiving and transmitting in Arduino . In Msp430 , I have used Pin P3.4 and P3.3 for receiving and transmitting .

 

My Energia code is as follows - 

 

  


  #include <SoftwareSerial.h>
    #include <String.h>
     
    SoftwareSerial mySerial(P3_4, P3_3);
    
    boolean pin2=LOW,pin3=LOW,pin4=LOW,pin5=LOW,pin6=LOW; 
    float temp=0.0;
    
    void setup()
    {
      mySerial.begin(9600);               // the GPRS baud rate   
      Serial.begin(9600);    // the GPRS baud rate 
      pinMode(2,INPUT);
      pinMode(3,INPUT);
      pinMode(4,INPUT);
      pinMode(5,INPUT);  
      pinMode(6,INPUT);  
      delay(1000);
    }
     
    void loop()
    {
          temp=analogRead(A0);
          temp=temp*0.4887;  
          delay(2);          
           Send2Pachube();
       
      if (mySerial.available())
        Serial.write(mySerial.read());
    }
    void Send2Pachube()
    {
      mySerial.println("AT");
      delay(1000);
    
      mySerial.println("AT+CPIN?");
      delay(1000);
    
      mySerial.println("AT+CREG?");
      delay(1000);
    
      mySerial.println("AT+CGATT?");
      delay(1000);
    
      mySerial.println("AT+CIPSHUT");
      delay(1000);
    
      mySerial.println("AT+CIPSTATUS");
      delay(2000);
    
      mySerial.println("AT+CIPMUX=0");
      delay(2000);
     
      ShowSerialData();
     
      mySerial.println("AT+CSTT=\"aircelgprs\"");//start task and setting the APN,
      delay(1000);
     
      ShowSerialData();
     
      mySerial.println("AT+CIICR");//bring up wireless connection
      delay(3000);
     
      ShowSerialData();
     
      mySerial.println("AT+CIFSR");//get local IP adress
      delay(2000);
     
      ShowSerialData();
     
      mySerial.println("AT+CIPSPRT=0");
      delay(3000);
     
      ShowSerialData();
      
      mySerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
      delay(6000);
     
      ShowSerialData();
     
      mySerial.println("AT+CIPSEND");//begin send data to remote server
      delay(4000);
      ShowSerialData();
      
        String str="GET https://api.thingspeak.com/update?api_key=--------C&field1=" + String(temp);
      mySerial.println(str);//begin send data to remote server
      delay(4000);
      ShowSerialData();
    
      mySerial.println((char)26);//sending
      delay(5000);//waitting for reply, important! the time is base on the condition of internet 
      mySerial.println();
     
      ShowSerialData();
     
      mySerial.println("AT+CIPSHUT");//close the connection
      delay(100);
      ShowSerialData();
    } 
    void ShowSerialData()
    {
      while(mySerial.available()!=0)
        Serial.write(mySerial.read());
    }

Link to post
Share on other sites

@@B@tto. When I run this code using Arduino Uno, it sends a Get request to thingspeak website , wherein the data collected by lm35 sensor is stored . The serial monitor doesn't show anything , which is fine because it is not supposed to show anything . However , when I run it using msp430f5529 and energia software , there is nothing in serial monitor and also the data doesn't get updated on thingspeak website .it just keeps running .I have checked my lm35 reading in energia , it is working fine , but the Get request is not being made . My guess is that the serial pins I have used may be wrong or the AT commands may not be correct . Also , I am using pin 3.4 and pin 3.3 for receiving and transmitting in the msp430 board .

Any help will be much appreciated .

Link to post
Share on other sites

@@B@tto. When I run this code using Arduino Uno, it sends a Get request to thingspeak website , wherein the data collected by lm35 sensor is stored . The serial monitor doesn't show anything , which is fine because it is not supposed to show anything . However , when I run it using msp430f5529 and energia software , there is nothing in serial monitor and also the data doesn't get updated on thingspeak website .it just keeps running .I have checked my lm35 reading in energia , it is working fine , but the Get request is not being made . My guess is that the serial pins I have used may be wrong or the AT commands may not be correct . Also , I am using pin 3.4 and pin 3.3 for receiving and transmitting in the msp430 board .

Any help will be much appreciated .

Sorry but you have to see something in your serial monitor as you use the function ShowSerialData(), so after each command you should see the module response in the serial monitor.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...