All sofware serial libraries return junk chars?


I am trying to communicate to a Connectone miniWifi module which uses Serial TTL at 3.3v. I use the mosfet arrangement for level shifting as described by mem see The wifi module is powered by regulated 3.3v …

It does work using my usb-to-ttl converter as sold by seeedstudio] through the fet arrangement via Hyperterminal. The serial converter was set to 5v for this test.

However when I use the arduino (Duemilanove 0012 on XP) with any of the software serial libraries incl AFsoft and NewSoft it just returns funny looking characters like ó etc? Also it does not return the same characters twice after using the same command twice? All the obvious hardware problems I’ve found here on the forum I’ve checked incl. common ground etc. Anyone got an idea what might cause this, I am totally stumped :-[

EDIT: Test code used for newsoftserial7 …

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);

void setup()  

  // set the data rate for the NewSoftSerial port

void loop()                     // run over and over again

  if (mySerial.available()) {
  if (Serial.available()) {

Could it be simply the ‘Serial.print((char);’ statement converting incorrectly?

Are you sure your wifi module is using 9600 baud?

I do believe so, is does work with hyperterminal at 9600.

Hyperterminal settings are 9600, 8 Bits, stop bits 1, flowcontrol none .. if that helps? BTW mem, thanks for posting the schematic for the 5v/3.3v signal conversion, a great solution!

EDIT: From the programmers manual for this module

iChip supports auto baud rate detection for the following baud rates: 2400, 4800, 9600, 19200, 38400, 57600, and 115200.

Page 1-4

You may want to try lower (or higher) baud rates to see if the auto baud reate detection is the problem.

Thanks mem, I'll try that. I also found a command to fix the baud rate and commit the setting to nonvolatile memory so I'll try that from Hyperterminal also.

Right, I ran hyperterminal to the wifi module and fixed the baud rate to 9600. It certainly seems to have improved the situation but there is still some junk coming through:




PÕ¥í ýÊþ

ADC value = 52



þÿ+i ?½=-5)Rþ¢ý¥IÿP1NCBPQ?value = 51


The 'I/OK' and 'ADC value = 52' is expected, the rest I have no idea .. :-?

I wonder if the baud rate produced by SoftSerial is not quite right. Do you have an oscilloscope? Or perhaps you could try the Arduino hardware serial connected through pins 0 and 1 to the wifi.

I only have access to a tech's scope here at work, will bring it in tomorrow. What must I look for on the scope?

I suppose it would be a problem to run the usb to arduino while using the hardware pins for comms on the wifi module though?

Maybe setup a softserial connection through the the usb-serial ttl to the computer to monitor output? Additionally if this also fails it may also point to a fault in my softserial somewhere..

Run a test sketch that sends a character with a known bit pattern, for example the character U is 01010101 in ascii. Measure the pulse times, they should be 104 microseconds at 9600.

If you wanted to try the Arduino hardware serial, try connecting through a ttl converter or you could try connecting pins 0 and 1 to the wifi.

Your level shifter may not be producing a clean (enough) square wave and that might be throwing off the bit timing in NewSoftSerial (or AFSoftSerial). Both use the pin change interrupt to start the bit timing. If the waveform is not very square, then the boundaries that determine low vs. high will be shifted in time.

Since you're going to look at the the timing on a scope, also confirm that the serial signal coming out of your level shifter is a clean square wave.

Thanks mem/etracer, I will try to get some scope time today … :slight_smile:

Last night I connected the wifi module on the arduino hardware serial pins and connected newsoftserial via my external usb-ttl-serial converter back to hyperterminal in order to get the wifi module feedback back to the pc.

Of course it all worked perfectly :-?

Not an ideal scenario though since I would prefer to use the arduino built-in usb connection for debugging purposes…

If the wave is not generated 100% square what are my alternatives to the two mosfets? Different pull-up resistor values (I’ve tried 3k3 and 10k) perhaps or …

One thing to try: on the wifi TX → arduino RX connection, remove the mosfet circuit and don’t use anything. Driving a 5V input with 3.3V will not destroy anything. 3.3V is kind of marginal for reliability, but lots of folks seem to do it without trouble.

A more extreme solution: use two MAX3232 devices, one on the wifi module to convert to/from RS232 levels, and another on the 5V arduino. The MAX3232 is like the MAX232, except it can run on 3V (MAX232 is 5V only). I only say “extreme” because it’ll require two MAX3232s, plus about 10 capacitors to do it this way.

There are other level converting ICs that will bridge the two with a single IC, but I haven’t used any of those myself.


I did not get any time to get onto the scope today but I did remove the mosfet from the wifi tx line, however the results are similar:





ID722p01 13.7.2008




:( I'll try the scope tomorrow hopefully... I did also notice my arduino power led dimly lighting up when power is applied to the wifi module, before the arduino is powered up - is this normal?

I wrote you a small novel and the system threw away my message because of a hyperlink... bummer...

Check that your supply has enough juice to power the entire circuit and doesn't introduce a lot of ripple under load. Those "wall warts" can do funny things under load. Is your supply regulated?

I'm betting the voltage coming out of the WiFi Tx is not 3.3V, but something marginal like 2.7V that may or may not be enough to switch the Arduino's input.

The other thing to check is if the Tx/Rx line is perhaps too close to the WiFi antenna.

Google "Soundcard Oscilloscope" for some ideas for a cheap scope... 9600 baud should be visible at 44kHz sampling - at least to see a pattern.

Here’s a ton of suggestions for 3.3V to 5V shifting…

Thanks for the link Realiser and sorry to hear about the wasted effort. Computers really can be painful sometimes .. :( Yeah it's time to get some kind of scope solution going. I've wanted to post the question of which scope to get but from what I've seen on other forums it may be a rather personal matter. ;)

The 3.3v is from a walwart regulated down by a lm315t .. but now that you mention it, it does occur to me that it's the one part of the circuit I have not rebuilt yet. I'll quickly rip it apart and rebuild with new components just in case ..

I use this circuit [0] to connect the RX pin on MiniWifiSocket. I can connect without problem of power the mini socket wfi and the arduino.

@JakesSA Did you resolve the problem with the junk character?


Hi Robertor

Not working as yet, I've rebuilt the power supply and the whole circuit and still junky chars are coming through.

I'll give that circuit a try thanks!! I assume the TX pin on the wifi module just goes straight to the RX on the Arduino?

Also, did you use a software serial library to connect to the wifi module?

this is the circuit that i have used. I hope that it were clear. I’m not electronic, so i don’t know too much the language :wink:
I know that “electrically” it is working, because the wifi module answer to a ping and i can browse the admin page.
I have not configured yet the posibility to access via wifi the arduino, so i have not rsolve the problem with the serial conection. I was thinking to use the code that you post to make some test. Do you have an another idea?
When you use the code that you post, how do you send the commands? Because, when i connect the wifi module to the arduino using the TX and RX pins, it give me this problem.
Do you have a msn account, we could chat by there.

From what I can tell Robertor you use hardware serial to connect which also works fine for me. The problem lies in using the softwareserial libraries to connect…

I am almost ready to buy an oscilloscope and will have more feedback then.