1
votes

I am designing a device to control temperature and send sms if it's too high or too low. I am using arduino, DHT22 sensor and DFrobot Gravity UART A6 (GSM module). The sensor works just fine, but I am keep having problems with GSM, as it stopped responding. Here's the code that I am using, it's a standard code example from the DFRobot:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10);  // TX-Pin11, RX-Pin10
void updateSerial()
{
delay(2000);
while (Serial.available()) {
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available()) {
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}

void loop()
{
mySerial.println("AT");          //Once the handshake test is successful, it will back to OK
updateSerial();

mySerial.println("AT+CSQ");      //Signal quality test, value range is 0-31, 31 is the best
updateSerial();

mySerial.println("AT+CCID");    //Read SIM information to confirm whether the SIM is plugged
updateSerial();

mySerial.println("AT+CREG?");    //Check whether it has registered in the network
updateSerial();

mySerial.println("AT+SNFS=0");  //Adjust to earphone mode(AT+SNFS=1 is microphone mode)
updateSerial();

mySerial.println("AT+CRSL=2");  //Adjust volume, volume range is 0-15, maximum:15
updateSerial();

while(1)
{
if(mySerial.available())
{
Serial.write(mySerial.read());   //Forward what Software Serial received to Serial Port
if(Serial.available())
{
  mySerial.write(Serial.read());  //Forward what Serial received to Software Serial Port
}
}
}
}

In the result, I keep getting "???". And I don't know what to do anymore. I checked the signal today with oscyloskope, everything should work. Please help :)

1

1 Answers

0
votes

Your code is fine; considering you are using the example provides by the manufacturer of the modem that shouldn't be a surprise.

The next most likely explanation is something wrong with your wiring. So make sure TX on the modem goes to pin 11 on your board and RX goes to pin 10.

You are not the first encountering this issue.