Instead, what I should be getting is something like.
WRAP THOR AI (2.3.0 build 79)
Copyright (c) 2003-2007 Bluegiga Technologies Inc.
READY.
I have trying to debug this for hours. I've made sure that the baud rate is at 115200 (which is the default UART settings of the WT32), as well as tied CTS to GND since I am not using hardware flow control. I've tried with different baud rates, but I am still getting garbage.
My example code is shown below.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);// RX, TX
int resetpin = 13;
long time;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
mySerial.begin(115200);
pinMode(resetpin, OUTPUT);
Serial.println("Starting Up!");
digitalWrite(resetpin, LOW);
delay(200);
digitalWrite(resetpin, HIGH);
delay(200);
digitalWrite(resetpin, LOW);
delay(200);
}
void loop() // run over and over
{
// time = millis();
if (mySerial.available())
Serial.write((char)mySerial.read());
if (Serial.available())
mySerial.write((char)Serial.read());
are you using the serial monitor? I just finished a project for work where I was using an attiny85 with the internal clock and software serial, and no matter how slow I set the com port speed I would get garbage >75% of the time
flipping over to minicom, cutecom, or putty I never saw it happen, and went about life at 9600 baud (though I should be able to do much faster even with an uncalibrated internal oscillator, its only 3 bytes at a time in my case, so no biggie)
the stupid thing is now sitting in a test fixture happily humming along at 9600, but if I use the serial monitor ... bam garbage. Seems that there is something overly tight in that part of the application.
The mention of PuTTY set me thinking.... and apologies if this is what the other post was already saying...
Perhaps you could, perhaps it would be worth trying...
Cut the Arduino out of the picture altogether for the moment. "Talk" to your serial device directly from a PC with PuTTY or similar... see if it will "behave" then. Maybe there's nothing wrong with your Arduino or program... but rather a fault in what you are connecting to?
Another thing to look at... are the bits in the data stream inverted? A "gotcha" which arises, and gives garbled output. If the output your program gets is consistent, or somewhat so, this could be what's going on.
For more on PuTTY....
(There are also notes about other serial comms issues there.)
Yes I am using the serial monitor of the Arduino IDE to monitor the "software serial" that is connected to the WT32. Unfortunately I don't have a way to directly connect the COM port to the WT32 device :/, but is what you are trying to say is that although I see garbage on the serial monitor, I can still send valid commands even if I don't read them correctly?
@tkbyd
I've just tried inverting the signal, but I still get garbage.
Is there a way that I can just use the Arduino's default UART serial instead of software serial?
I guess the thing I am confused about is that when I use "Serial.begin(115200)", I am just opening a serial channel between the computer IDE and the arduino right?
So for example, if I want to read something from the WT32,
But when I do serial.println, doesn't that just mean I am writing out what I am reading ONTO the WT32 as well? Is there a way that I can just use the arduino as a way to solely monitor the TX and RX pins?
I guess the thing I am confused about is that when I use "Serial.begin(115200)", I am just opening a serial channel between the computer IDE and the arduino right?
No. You are opening a connection to the serial port. Some application on the PC needs to open the other end. The Serial Monitor is one such application. The IDE is not.
But when I do serial.println, doesn't that just mean I am writing out what I am reading ONTO the WT32 as well?
Yes.
Is there a way that I can just use the arduino as a way to solely monitor the TX and RX pins?
Sure. Plug the BT into some other pins. The hardware uart can not be used for two separate purposes.
So you are saying that the purpose of the Tx/Rx on the arduino is only for communication between the computer and the arduino? Unless I use software serial, I can't use the serial monitor to communicate with a device connected to the arduino?
So you are saying that the purpose of the Tx/Rx on the arduino is only for communication between the computer and the arduino? Unless I use software serial, I can't use the serial monitor to communicate with a device connected to the arduino?
No, I didn't say that. I said that the hardware serial port (or a software serial port) can be used to talk to ONE other device. That device can be the BT device OR the PC. It can't be both.
I use hardware serial to talk to a RFID reader. You can even plug something into pin 0 (Rx) and receive from (say) a GPS, and still send debugging stuff out of pin 1 (Tx) to the computer. They would have to be at the same baud rate though.
Thank you for your recommendation, I now got the ready message from the unit.
The only thing I changed, was to NOT CONNECT the Tx of the arduino.
Here is the basic code
int resetpin = 13;
long time;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
pinMode(resetpin, OUTPUT);
Serial.println("Starting Up!");
digitalWrite(resetpin, LOW);
delay(200);
digitalWrite(resetpin, HIGH);
delay(200);
digitalWrite(resetpin, LOW);
delay(200);
}
void loop() // run over and over
{
// time = millis();
if (Serial.available())
{
Serial.write(Serial.read());
}
}
The results I got is
Starting Up!
WRAP THOR AI (4.0.0 build 317)
Copyright (c) 2003-2010 Bluegiga Technologies Inc.
READY.
It seems that the software serial is a bit buggy, because it should communicate similarly. I guess I will either keep trying to debug the software serial or code using the built in UART blindedly.
Is there anyone who might have any suggestions as to why it only works with the hardware serial, as opposed to the software serial?
I feel like it might be because of the WT32's high default baud rate of 115200.
Software serial, by its nature, is more likely to drop characters than hardware serial. At 115200 baud you are getting a character every 86.8 uS. That's not a heap of time over. You can do a bit in that time ... not a lot.