[SOLVED] Unable to post data with stm32 L152re

hi, i am trying to send data using stm32 l152 board and gsm800 module but its not working. On gsm module internet gets activated but data is not being sent to ubidots.
I tried adding delay but then nothing is displayed on the monitor.

code:

#include "mbed.h"

Serial Serial6(PC_10, PC_11);
Serial pc(USBTX, USBRX); 

void ShowSerialData()
{
  
    if(Serial6.readable())
    {
      pc.putc(Serial6.getc());
      
      }
    if (pc.readable())
    {
        Serial6.putc(pc.getc());
           } 
    
    }

int main()
{
    Serial6.baud(9600);
    pc.baud(9600);
    
    Serial6.puts("AT\r");
    ShowSerialData();
    
    Serial6.puts("AT+CGATT=1\r");
    ShowSerialData();
        
    Serial6.puts("AT+CSTT=\"www\"\r");
    ShowSerialData();
       
    Serial6.puts("AT+CIICR\r");
    ShowSerialData();
    
    Serial6.puts("AT+CIFSR\r");
    ShowSerialData();

    Serial6.puts("AT+CIPSPRT=0\r");
    ShowSerialData();
    
    Serial6.puts("AT+CIPSTART=\"tcp\",\"things.ubidots.com\",\"80\"\r");
    ShowSerialData();
    
    Serial6.puts("AT+CIPSEND\r");
    ShowSerialData();
    
    Serial6.puts("POST /api/v1.6/collections\r");
    ShowSerialData();
    
    Serial6.puts("/values HTTP/1.1\r");
    ShowSerialData();
    
    Serial6.puts("Content-Type: application/json\r");
    ShowSerialData();
    
    Serial6.puts("Content-Length: 75\r");
    ShowSerialData();
    
    Serial6.puts("X-Auth-Token:QLh2wKPuem2U39JXwMDTlXkkmgkGT3\r");
    ShowSerialData();
    
    Serial6.puts("Host:things.ubidots.com\r");
    ShowSerialData();
    
    Serial6.puts("variable: 58a301db76254267f49cb565 , value: 10 \r");
    ShowSerialData();
    
    Serial6.putc(26);
    ShowSerialData();
    
    Serial6.puts("AT+CIPCLOSE\r");
    ShowSerialData();
    
    while (1)
    {
        ShowSerialData();
        //send_data();
        }
    
    }

Hello @ayush,

At the moment we don’t support this board because we don’t have one to make the test and replay your issue.

On the following link you’ll find all the boards that we support.

Regards,
Maria C.

Hi @mariahernandez , thanks for responding . I successfully posted the value by making some changes in the code

Hello @ayush,

Would you post your solution? It will be great for future implementations at community.

Regards

if the below code doesnt work, try adjusting delay according to your board or reset the board a few times after burning the code.

#include "mbed.h"

Serial Serial6(PC_10, PC_11);
Serial pc(USBTX, USBRX); 

void ShowSerialData()
{
  
    if(Serial6.readable())
    {
      pc.putc(Serial6.getc());
      }
    if (pc.readable())
    {
        Serial6.putc(pc.getc());
           }
           
    /*if (Serial6.readable())
    { 
    char c, buffer1[128];
    int i=0;
    c=Serial6.getc();
    buffer1[i]=c;
    i++;
    pc.printf(buffer1);
    }*/
    }
    
void init_setup()
{   Serial6.puts("AT\r\n");
    ShowSerialData();
    
    Serial6.puts("AT+CGATT=1\r\n");
    ShowSerialData();
    wait(0.5);
    
    Serial6.puts("AT+CSTT=\"www\"\r\n");
    ShowSerialData();
    wait(1);
       
    Serial6.puts("AT+CIICR\r\n");
    ShowSerialData();
    wait(1);
    
    Serial6.puts("AT+CIFSR\r\n");
    ShowSerialData();
    }

int main()
{
    Serial6.baud(19200);
    pc.baud(19200);
    
    init_setup();
    
    Serial6.puts("AT+CIPSPRT=0\r\n");
    ShowSerialData();
   // wait(3);
    
    Serial6.puts("AT+CIPSTART=\"tcp\",\"things.ubidots.com\",\"80\"\r\n");
    ShowSerialData();
    wait(3);
    
    Serial6.puts("AT+CIPSEND\r\n");
    ShowSerialData();
    wait(0.3);   
        
    Serial6.puts("POST /api/v1.6/variables/58a301db76254267f49cb565/values HTTP/1.1\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("X-Auth-Token: QLh2wKPuem2U39JXwMDTlXkkmgkGT3\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("Host: things.ubidots.com\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("Connection: close\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("Content-Type: application/json\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("Content-Length: 12\r\n");
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("\r\n");
    ShowSerialData();
    
    Serial6.puts("{\"value\":17}\r\n");
    ShowSerialData();
    //wait(0.1);
        
    Serial6.putc(26);
    ShowSerialData();
    //wait(0.1);
    
    Serial6.puts("AT+CIPCLOSE\r\n");
    ShowSerialData();
    
    while (1)
    {
        ShowSerialData();
        //send_data();
        }
    
    }


Thank you very much @ayush.

All the best