Author Topic: problem with reciving answer from sim800  (Read 1168 times)

0 Members and 1 Guest are viewing this topic.

Offline ُSTP.AsghariTopic starter

  • Newbie
  • Posts: 7
  • Country: ir
problem with reciving answer from sim800
« on: January 17, 2024, 02:31:51 pm »
When I give the AT command to the module. The module should give me the answer AT\r\nOK\r\n but to my surprise it gives the answer AT\r\r\nOOK\r\n. I understood this problem by getting the answer from the code below. While if I delete the wrong lines from the code below, the module does not respond.
Code: [Select]
Send_AT();
    do
    {
      buffer=get_char();
    }while(buffer!='A');
   
     
buffer=get_char();
if(buffer=='T')
                   {
                       buffer=get_char();
       if(buffer=='\r')
                          {
                             buffer=get_char();
                             if(buffer=='\r')
                                  {                             
                                      buffer=get_char();
                                      if(buffer=='\n')
                                              {
                                                  buffer=get_char();
                                                   if(buffer=='O')
                                                           {
                                                                 if(buffer=='O')
                                                                    {
                                                                           buffer=get_char();
                                                                           if(buffer=='K')
                                                                                {
                                                                                     buffer=get_char();
                                                                                     if(buffer=='\r')
                                                                                           {                                                                                             
                                                                                             buffer=get_char();
                                                                                             if(buffer=='\n')
                                                                                                    {                                                                                   
                                                                                                                   for(i=0;i<5;i++)
                                                                                                                    {
                                                                                                                            HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_SET);
                                                                                                                            HAL_Delay(500);       
                                                                                                                            HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_RESET);
                                                                                                                            HAL_Delay(500); 
                                                                                                                    }
                                                                                                    }
                                                                                           }
                                                                                }
                                                                    }
                                                           }
                                              }
                                  }                       
                          }       
                   }
 

Offline Scrts

  • Frequent Contributor
  • **
  • Posts: 803
  • Country: lt
Re: problem with reciving answer from sim800
« Reply #1 on: January 17, 2024, 05:06:41 pm »
What do you see as a response when you hook up USB-UART adapter to your PC? Your code seems to be messy. Receive the full command from the module to the buffer and then parse the data.
 

Offline bookaboo

  • Frequent Contributor
  • **
  • Posts: 810
  • Country: ie
Re: problem with reciving answer from sim800
« Reply #2 on: January 17, 2024, 07:11:36 pm »
You need to forget the Simcom module for a while. Sharpen your embedded skills first
IoT modules are a world of pain, even if you have embedded experience.

Write, or find, a proper uart receive handler function.
Test it with an FTDI cable, or even loop a uart tx back from your processor.


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->