0

I am writing code for ESP8266 which connects SIMCom 76xx to get data using HTTP. That's my code:

SoftwareSerial gsm(14, 12); // RX, TX
void setup() {

   Serial.begin(115200);     //Serial of ESP
   gsm.begin(115200);        //SIMCom's serial, configured by SoftwareSerial
   /* orther code/*
}

void loop {
  String http_str = "AT+HTTPPARA=\"URL\",\"http://api.openweathermap.org/data/2.5/weather?xxxxxxxx\"\r\n";
  /* xxxxxx is longitude, latitude and apikey */
  sendD("AT+HTTPINIT\r\n", 4000, DEBUG);  
  sendD(http_str, 6000, DEBUG);
  sendD("AT+HTTPACTION=0\r\n", 5000, DEBUG);
  sendD("AT+HTTPTERM\r\n", 3000, DEBUG);
}

String sendD(String command, const int timeout, boolean debug)
{
  /* It helps me to send AT command to SIMCom (gsm serial) and read information from gsm serial to display on serial monitor */
}

My code have problem at sendD(http_str, 6000, DEBUG) <=> (AT+HTTPPARA). When I open Serial monitor, I see ⸮⸮⸮⸮. Example:

AT+HTTPPARA="URL","http://api.openw⸮

AT+HTTPPARA="URL","http://api.openw⸮athermap.org"

I want to send a code to gsm and display it on the monitor as:

AT+HTTPPARA="URL","http://api.openweathermap.org/data/2.5/weather?xxxxxxxxxx"

It works correctly because I tested in the software "AT Command Test"

`⸮⸮⸮⸮ causes my code to have a URL error. How should I solve it? Thank you!

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Cao Minh
  • 1
  • 1
  • use lower baud rate – Juraj Sep 01 '22 at 05:25
  • 1
    If there is any problem that cause it, it is in your sendD() function that you didn't shown us. SIMCOM module has auto-baudrate detection, you need to send one or two "AT" and wait to see if you get back "OK" to sync the baud rate before you sending any command. – hcheung Sep 02 '22 at 01:32
  • 1
    BTW, You can't just straightaway to establish a data connection, you need to check weather the module has registered to the network yet (and it could take a few seconds), your setup() obviously didn't do that. – hcheung Sep 02 '22 at 01:35

0 Answers0