Hearing aids

ALMA! Check your battery!

In which we make a MaxBotix sonar speak properly over a serial connection.

Recently I hooked up a MaxBotix MB1220 XL sonar to an FTDI breakout board to do some experimenting, and I ran in to an issue I had discovered before but thought was an artifact of the processor I was using.  You see, previously (a couple years ago) I had connected a MB1220 to a Fez Panda II and discovered a wonderful stream of gibberish flowing from my brand new sonar.  At first I assumed I had connected it improperly.  There are only three wires that need to be connected to make the sonar transmit over the serial port - power, ground, and TX - but just maybe I had accidentally hooked up to the analog voltage instead of TX.

No dice.

All connections secure? Check.
Are we using 5 volts? Check.
Is the processor 5 volt tolerant? Check.
Is the TX from the sonar connected to the RX of the processor? Check.
9600 baud 8N1? Check.

Still no luck.

Still just gibberish.

At some point while reading about TTL versus RS232 serial connections it occurred to me that perhaps

... the Pin 5 output delivers asynchronous serial with an RS232 format, except voltages are 0-Vcc.

could mean the levels were inverted rather than being out of range.  In other words, what my processor thought was high the sonar thought was low and vice versa.

Not having a hex inverter (or even a single inverter) handy, I flipped through some old notes about logic gates and found a simple inverter made from a couple of resistors and a transistor, parts I had on hand.

Below is what I threw together on a breadboard.

R1 = 1K
R2 = 10K
Q1 is a generic NPN transistor out of a pack from Radio Shack.

With this in place, R121 flashed across my LCD display.


Flash forward two years, and we are back to me hooking up the MB1220 to an FTDI breakout board.  The breakout board was set to 5v.  The sonar was being powered by 5v from the breakout board.  Putty was up and set for a serial connection with 9600 baud 8N1.

The result?


I then wired up the above circuit on a breadboard, connected the sonar and the breakout board, and presto, the range information I expected to see.

If like me, you connect a MaxBotix sonar to a processor, FTDI chip, or anything else over serial and find gibberish, you probably should invert the signal with something like the circuit above… or stick to their I2C line.