I’m trying to get my electron to send AT commands to a Sierra Wireless AirPrime module (AR6220) over serial UART, but am having a hard time getting it to work correctly. I’m doing this to access a couple of features on the AR6220 module that aren’t available on the cellular modem in the electron.
I have purchased a MAX3232-based TTL-RS232 converter from here: https://potentiallabs.com/cart/rs232-ttl-convertor?search=rs232, and wired the tx, rx, vcc, and gnd pins from the electron to the tx, rx, vcc, and gnd pins on the converter. When I try sending the “AT” command through to the AirPrime module, I receive nothing back from the module. Here’s the code that I’m running:
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
sendCmd("AT");
pause(2000);
Serial.println("received: " + recResp());
pause(1000);
}
String recResp() {
unsigned long tick = millis();
String buff = "";
while (Serial1.available() > 0) {
pause(5);
buff = Serial1.readStringUntil('\n');
}
return buff;
}
void sendCmd(String c) {
Serial.println("sending command: "+c);
Serial1.println(c);
pause(500);
}
void pause(int t) {
unsigned long tick = millis();
while (millis() - tick < t) {}
}
This is what I get when I run the code on the electron:
sending command: AT
received:
sending command: AT
received:
I know the RS232 port on the AR6220 works properly. When I use an USB-RS232 adapter and send “AT” from my laptop (via putty) to the AR6220, I get back an “OK”.
Just to make sure things are wired properly, I unplugged the RS232 cable from the AR6220, shorted pins 2 and 3 on the cable (after the TTL-RS232 converter) and ran the code above on the electron. I get the echo as expected:
sending command: AT
received: AT
One thing I noticed, is with the code running on the electron and the cable unplugged, I’m measuring ~2-3v between pin 3 (tx) and pin 5 (gnd) on the cable. Shouldn’t this be closer to 10v for the RS232? I’m not sure if I’ve wired the TTL-RS232 converter correctly or if there is an error in the code, or something else that’s going on.
TIA for any suggestions!