elementzonline / SIM800_MQTT

Visit our blog/website for more information
http://www.elementzonline.com
GNU General Public License v3.0
170 stars 96 forks source link

Doesn't work if the Serial ports are changed #5

Closed solankigithub closed 4 years ago

solankigithub commented 8 years ago

Hi, First of all, a wonderful job for creating such library. Issue: When i look into the source, "Serial" (Hardware Serial) has been used to communicate with the SIM800 modem and mySerial has been used to print the output.

I am using MEGA, where i need to use "Serial1" to communicate with SIM800 and "Serial" to print the output. So i replaced the occurrence of "Serial" with "Serial1" and "mySerial" with "Serial". I didn't change any other code. The library is not working anymore.. Can you please help to make it little flexible with respect to choosing the serial ports.

ramonpasato19 commented 5 years ago

Hola alguien q me ayude con q pines se une un arduino mega y el sim900, para q funcione el codigo, en el monitor serie se queda en "++AT"

shadababe04 commented 5 years ago

Hi I change the Serial to mySerial n use the 2,3 as Rx Tx in Arduino Uno with SIM800, but still didn't get any response after sending connect request, am not getting any response Here is my serial terminal output. can u please help me to solve this issue..?

AT+CIPSTATUS

12:15:12.218 -> OK 12:15:12.218 -> 12:15:12.218 -> STATE: IP INITIAL 12:15:12.265 -> AT+CSTT="WWW"

12:15:12.265 -> OK AT+CIPSTATUS

12:15:12.343 -> OK 12:15:12.343 -> 12:15:12.343 -> STATE: IP START STATE: IP GPRSACT 12:15:29.406 -> AT+CIFSR

12:15:29.406 -> 100.115.165.214 12:15:29.453 -> AT+CIPSTATUS

12:15:29.499 -> OK 12:15:29.499 -> 12:15:29.499 -> STATE: IP STATUS 12:15:29.499 -> AT+CIPSTART="TCP","broker.hivemq.com","1883"

12:15:29.640 -> OK

12:15:30.515 -> CONNECT 12:15:30.515 -> MQTT.TCP_Flag = True

shadababe04 commented 5 years ago

any help???

shadababe04 commented 5 years ago

Same issue !! not working.. got stuck at MQTT.MessageFlag = true; any solution ?

i change the sim its working now

agozie commented 5 years ago

For all those getting stuck at MQTT.MessageFlag = true when using software serial, ESP8266 or other platforms, change GSM_MQTT::processing in GSM_MQTT.cpp to


void GSM_MQTT::processing(void)
{
 if (TCP_Flag == false)
  {
    MQTT_Flag = false;
    _tcpInit();
  }
  _ping();

  //**************new code*****************
  unsigned long t = millis();
  //add long waitPeriod = 0; somewhere at the beginning of the file
  if (t - waitPeriod > 1000L) 
  {
    waitPeriod = t;
    serialEvent(); //call serialEvent every second
  }
  //*****************************************

}
MuhammedImdaad commented 3 years ago

code works perfectly fine!!!!!!!!!!!!!!!!!!