devdibyo

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

8 posts in this topic

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());
    }

Share this post


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 .

Share this post


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.

Share this post


Link to post
Share on other sites

@@Fmilburn. I have tried as you suggested .the code uploads successfully ,however there is no output . The thingspeak account doesn't get updated .

Share this post


Link to post
Share on other sites

Hello guys , thanks for the suggestions above but I think I have figured out the error. I think there is a voltage mismatch .msp430f5529 gives a 3.3V output which isn't sufficient for the sim900A to work . So how can I translate that to 5V ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now