Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

No AT command return from SIM 7020G to Pololu A-Star 328PB

I’m trying to use a Pololu A-Star 328PB to control a SIM7020G NB-IOT module. I’ve used the SIM 7020 standalone using a Sparkfun FTDI serial to USB converter to issue AT commands to the module with success. The wiring diagram for that is as follows:

SIM 7020G → Sparkfun FTDI
TX → RX
RX → TX
GND → GND

I’ve moved on to try and control the SIM module with the Pololu board. I chose this specific Pololu board because the ATMEGA 328PB has 2 USART so I could have one used for serial monitor debugging and the other used for communication with the SIM module. The wiring diagram for this is as follows:

SIM 7020G → Pololu Board
TX → RX
RX → TX

The Pololu board is connected/powered via the Sparkfun FTDI serial to USB converter board and in both instances described above the SIM module is powered by 2 18650 batteries.
The code I am using to try and communicate from the SIM board to the Pololu board and then output to the serial monitor is below.

void setup() {
  Serial.begin(57600);
  Serial1.begin(57600);
}

void loop() {
  Serial1.println("AT");
  Serial1.flush();
  while (!Serial1.available());
  char payload = Serial1.read();
  Serial.println(payload);
  Serial.flush();
  delay(2500);
}

The output on the serial monitor has been an odd mix of the initial “AT” command then just outputting “A”, rather than the expected “OK” output that should be present when “AT” is input to the SIM module.

I bought two of the same SIM modules and have tried both of them as well as another of the same Pololu boards with this code and wiring setup with identical results. I’ve double checked that the installed version of the Pololu boards package is version 4.0.2 which contains a USART fix implemented in version 4.0.1. I’ve also verified that USART0 and USART1 work independently of one another.

Hello.

Can you tell us which particular A-Star 328PB you are using? Posting some pictures of your setup that show all of your connections would also be helpful.

Can you also confirm whether you have a ground connection between your SIM 7020G and the A-Star? (You listed a ground connection between the SIM 7020G and Sparkfun FTDI breakout, but then did not list one with the A-Star.) If you do not, then you will need to add that.

It also seems like your program is not outputting everything in the buffer, so if there is more than one byte it won’t print until the next loop through your code. This could cause some confusion when debugging, so you might want to add a while loop to print everything in the buffer before looping back around. That would look something like this:

void loop() {
  Serial1.println("AT");
  Serial1.flush();
  while (!Serial1.available());   #wait for something in the buffer
  
  while(Serial1.available()){    #print everything in the buffer
    char payload = Serial1.read();
    Serial.print(payload);
  }
  Serial.println();
  delay(2500);
}

- Patrick

I’m using the 3.3V/8 MHz version. I added the common ground between the SIM module and the A-Star as well as modified my code to what you suggested and I’m getting behavior more closer to what I think should be expected. I’m not sure if the “AT” before and after the “OK” response is something that can be remedied.

Here’s a picture of my setup as well:

I am glad to see that you are making progress! The repeating behavior would be consistent with your SIM7020G having some kind of echo setting, so you might try looking into if there is some command you can use to disable that.

- Patrick

I’ll do some digging around in the AT command manual and see if I can find something like that. Thanks for your advice, it is very much appreciated!