Electron not able to send commands via RS232

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() {

void loop() {
    Serial.println("received: " + recResp());

String recResp() {
    unsigned long tick = millis();
    String buff = "";
    while (Serial1.available() > 0) {
        buff = Serial1.readStringUntil('\n');
    return buff;

void sendCmd(String c) {
    Serial.println("sending command: "+c);

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

sending command: AT

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!

Did you try flipping tx and rx? ~2 to 3 V is correct since that is the electron side and not the RS232 port.

I’m not entirely sure but Serial1 should be on TX and RX pins?


1 Like

Can you also explain what commands you miss on the ublox module?


Yes, I’ve flipped TX and RX into the converter, but get the same result. I’ve checked the RS232 cable I’m using which is a straight-through (not null modem) cable. I believe Serial1 utilizes the TX and RX pins which are the ones I’m using to connect to the TTL-RS232 converter.


The 2-3v is actually measured from the RS232 side, not on the electron side of the converter, which is what concerns me.


It’s not that there are commands missing on the ublox module. It’s that the AR module I have has been modified to use a different GSM protocol. The AT command set is more or less the same.

1 Like

My guess is that you are sending AT (println may or may not send CR). AT commands expect to be terminated with CR. I’d change your serial1.println() to serial.print and append a CR (0x0d).

…though, even without CR, if echo (ATE1) is enabled which it usually is by default, you should still get the AT echoed.

MAX3232 buffers usually only boost to +/-5v.


I’ve tried modifying my code so I append a CR, but still get no response from the AR6220. Here’s the code I used:


I also tried, which also did not work.


In both cases, I unplugged the cable from the AR6220 and shorted pins 2 and 3, to make sure the echo was expected (and it was).

@ralph, you may want to use Serial1.write() instead, as in:

Serial1.write(0x0A);  // may need a CRLF

Doing Serial1.print(0x0D, HEX) will produce the ascii value “x0D”!

Aside from @peekay123’s advice on how to send a real CR (and you do need a real CR (0x0D), not LF (0x0A), I’m guessing that your issue must be either a bad level shifter, or needing to strap flow control on the DE9.

Disconnect it from anything but power, then wire the TX line to 3v3. You should see around -5v from the DE9 side. Next, strap the TX line to 0v. You should see see around +5v from the DE9 side. If you do - or at least see stuff which is both above and below 0v then the charge pump is probably fine… pretty sure a lot of these cheap boards are not real mac3232’s which could account for not hitting the expected values.

The other thing that could be happening is that the AR6220 is not sending you anything because it sees CTS low. The easy workaround for this is to short pins 7 & 8 (on the bottom of the level shifter PCB). This loops the AR6220’s RTS back to its CTS, so it should be happy transmitting to you.

1 Like

@peekay123 @hfiennes

Thanks for the note on Serial1.write(0x0D) I’ve changed the code to include this. I’ve also shorted pins 7 and 8 to trick the AR6220 which unfortunately didn’t fix the problem. When sending “AT”, I still receive nothing back.

I’ve tested the TTL-RS232 converter by tying the TX line to 3v3 and 0v. The result is -6v and 5.5v respectively at the db9 side, so it appears that the level shifter is working properly.

Ok, level shifter is working correctly. I think it must be flow control lines. Short DTR and DSR on the DE9 connector too (pins 4 & 6).

@hfiennes is dead on. You may consider getting a NULL modem adapter which loops all the hardware flow control pins so you don’t have to worry about them. :smile:

Hmm. I’ve shorted pins 4 and 6 together, as well as pins 7 and 8 together (on the bottom of the level shifter PCB), but still do not receive an “OK” in response to “AT” command sent…

According to the AR6220 manual:

The UART1 interface is 2.8 V type, but it is 3 V tolerant.

Also, there’s a section on wiring up using a 4-wire serial interface:

The signals used in this interface are as follows:
 TX
 RX

The signal DTR must be configured at the low level.

The unused UART1 signals and their multiplexed features are not available as soon as UART1 service is used. Similarly, if one or more signal multiplexed with UART1 signals is used, the UART1 service is unavailable.

I’ve tried shorting RTS/CTS (pins 7 and 8) and tying DTR (pin 4) to ground, which doesn’t make a difference.

The more ominous line is that the UART interface is supposed to be 2.8V, which is confusing because the manual specifically says elsewhere to use an RS232 level shifter.

Yeah, that’s pretty ominous. You said you’d been using this with a real PC though - when you say “usb-rs232 adaptor” do you mean one that goes USB to DB9?

I’d check out the voltage levels on the pins when that adaptor is in use as obviously whatever the module is seeing from it, it likes…