Serial Communication Problem

Hi All

This is my 1st post, so be easy on me XD

I’m think this is the most appropriate category, however please feel free to move if needed so.

I’m busy with a project where my Uno will send a “command” over the serial port to an attached device that will in turn send out a SMS over the cellular network.

I’ve been battling quite a bit and after some help from the manufacturer of the GSM module I have discovered that the serial port is not communicating as expected.

The command that I’m needing to be send out is as follows *SMSTX:0831231234:This is the message#

The arduino is programmed to output the “command” when a specific pin is active high. Therefore when the button is pressed it will send the above command out over the serial port.

I’ve used the following code to “send” the “command” over the serial port.

Serial.print("*SMSTX:0831231234:This is the message#");

Now while monitoring it over the Arduino software Serial Monitor it works fine and I receive the *SMSTX:0831231234:This is the message# however if I plug the TX/RX pins of the arduino to a RS232 Lever Shifter and in turn plug the DB9 of the Lever Shifter to a serial port (usb to serial adapter) on my laptop and I run SuperTerm serial monitor I get only a couple letters, in random order, from the command line. EG SX, MSX, XT, or similar. Clearly this is why the GSM module it not sending out the SMS as expected. I have confirm that the GSM module is working correctly, as if I send SEND <*SMSTX:0821231234:This is the massage# from the SuperTerm terminal, the unit send out the SMS.

I’ve verified that all baudrates are correct and matching.

Could someone please help.

Thanks in advance

Justin

Can you give a link to that sms-module ? Is it expecting ttl-level signals, or rs232 level (normal, or low voltage). What is the baudrate ? The TX of the Arduino should probably be connected to the RX of the sms-module.

Can you check everything once more: baud rate, no parity, 8 bits. No handshake (not hardware, and not software).

If you send something to the serial monitor, that should be the same as using the TX/RX pins, and via adapter to the computer. Can you try to make that work. Do you have an old PC with a serial port perhaps. Or try a different program.

If everything fails, you could try SoftwareSerial. That emulates a serial port on any pin. That way you can use the serial monitor of the Arduino (with normal RX/TX pins), and send messages to the sms device (with SoftwareSerial) at the same time. The SoftwareSerial is a standard library. http://arduino.cc/hu/Reference/SoftwareSerial

The Rx and Tx lines are also connected to the USB chip on the Arduino, this sometimes causes problems but if you are just transmitting I think it should work. In fact you should see the same data on the IDE serial monitor as the terminal program. Try running both at once to verify that.

Otherwise try all the stuff Krodal said.

Also note that you will probably have to disconnect the level shifter to reprogram the Arduino.


Rob

Thanks for the replies:

Herewith link to the manual for the device, pages 34 - 35 cover the serial.

http://www.gsmcommander.co.za/downloads/GSM_Commander_Manual.pdf

As stated in the manual and confirmed with successful communication between the laptop and GSM module that the setting are as follows:

Baudrate : 38400 (default - and I confirmed its still at 38400) Data Bits : 8 Stop bits : 1 Parity : None Flow-control : None

I've requested the RS232 Levels from the manufacturer, I will advise once received.

Connections checked and confirmed 100 times!

I've run the IDE serial monitor and the Terminal monitor simultaneously, tried everything to get it to read the same but just can't come right!

Could it not be the RS232 Lever Shifter causing a problem?

Thanks Krodal, I will have a look at the Software Serial if I don't start winning soon!

Greynomad, Correct, I do have to disconnect the level shifter to reprogram the arduino, otherwise it fails.

Justin

I've run the IDE serial monitor and the Terminal monitor simultaneously, tried everything to get it to read the same but just can't come right!

So the IDE monitor shows the right stuff and the terminal program doesn't?

If so then it really has to be the level converter.


Rob

According to the document at page 34 : "Signaling levels: RS232". So it does need the higher levels of the original RS232. So first make sure the level converter is working. Can you upload a schematic of the level converter ? The RX of the Arduino is also influenced by its own serial-to-usb-converter. The level converter has to override that.

Correct Graynomad, shows the correct info in the Arduino Serial monitor and incorrect in the terminal program.

Here is the Level Shifter :

https://www.sparkfun.com/products/449

And the schematic :

http://www.sparkfun.com/datasheets/Prototyping/RS232-Shifter-SMD.pdf

Still awaiting for reply from the manufacturer regarding RS232 levels.

Well, that might be the problem. The level shifter receives a the higher level correctly. But it transmit only a 5V level, it does not create the higher levels for output. You need a board with the MAX232, that's what everyone is using.

As usual Sparkfun is full of sh1t

convert RS232 to TTL and vice versa

Wrong guys, since when was 0-5v anything like RS-232 levels. I know it often works and people have fudged it for years, but you can't make the above claim on a product.

They do have a clever trick with the diode and cap, but really, just use the right chip.


Rob

Though it might be the Level Shifter :blush:

I'll pop to my local electronics store and pick up a MAX232 and nesecary parts to breadboard a test circuit this evening.

Thanks for the input!

Thinking about it, the USB to Serial adapter must have a MAX232 or similar to be able to drive the GSM module directly at "true" RRS232 levels then?

..based on the manual they talk about rs232 levels, and they describe the connection to the classic db9 rs232 socket. That indicates rs232 levels (log1=-3V and less, log0=3V and more). The sparkfun shifter shall work if that is true (I used that design with diode and cap 30y ago - in order to work properly it requires -3V or less on the GSM's TX pin in idle). If the sparkfun shifter does not work, the rs232 on the GSM module might have not got the logic levels as assumed. The best way to handle that is to measure the Tx level (against GND) on the GSM's module db9-socket with a voltmeter (do not send any data). You have to read -3V or less at the TX pin in idle. PS: it happens the hw makers are talking about rs232, but using the ttl/cmos voltage levels.. as for them the rs232 means "the serial" only.. (ie. ~0Volt for rs232_log1 and +3 to +5V for rs232_log0, many notebooks accept(ed) that easily/happily) :) :)

Hi All

Ok, so now I’m even more confused… Tried the MAX232 and still nothing!

**** To recap my findings! ****

When the Arduino send on its Serial the IDE displays the correct info every time.

Voltage on TX wire from MAX232 = -7.5V (to GSM module)

Voltage on Pin2 (TX) of the DB9 from the GSM module -7V (to MAX232)

I’ve tried running off ext power source to remove possible problem from USB interface, doesn’t help.

If I use my USB Serial Adaptor to monitor the output from the Arduino (after the Level Shifter or MAX232) depending on which program I’m running I get conflicting results. With SuperTerm terminal I get rubbish, but if I use Hyperterminal I get the correct data.

  • Both using the same USB Serial Adapter.
  • Both running the same Com (set on com1 where the adapter to)
  • Both running same settings, 38400, 8, N, 1.

If I use SuperTerm to send the command ( SEND <*SMSTX:0821231234:message#> to the GSM module, it works and the GSM module sends the message.

It appear the GSM module is “seeing” the same as SuperTerm?

Thx

Justin

..there is always a lot of mess with serial :)

  • Both running same settings, 38400, 8, N, 1. There is a lot of other settings too, however - check all of them..

Just a screen shot of the 2 programms, one was run after the other, without any hardware change!

..what does it mean (super term in red): COM1 is currently in use by another application? Running two terminals in parallel on the same COM is not good.. .. CR and LF handling? .. hw/xon/xoff/none flow control? .. transmit delays ..

Drum roll please................

And tonight the STUPID Person Award goes tooo.........LightSA.....me!!!

I'm really feeling so STUPID right now! you couldn't even imagine!

After being told to to confirm wiring and triple checking it I still made a school boy error! If I could, I would really kick myself now!

The error come in by making the cable for the GSM module, I used a male plug so I could plug it in directly to the level shifter, and elimating the serial connection cable, which means I had the TX to TX and RX to RX......

I would just like to thank everyone for their assistance and patience with helping me!

Still can't believe what I did!

Hi Pito

It was a warning has I had tried to connect it to the port before I had disconnected the other terminal.

But as stated I've found my error!

.. as I said tackling the serial is always a mess. Fortunately we must not deal with fixed line modems anymore :) :) :)