Go Down

Topic: Lots of Squares on the Serial Readout (Read 3933 times) previous topic - next topic

165677106

My code is very simple as a receiver and rebroadcaster for 802.15.4 protocol.

 void setup(){
 }
  void loop(){
   char c = Serial.read();
   Serial.print(c);
 }

We have a more complicated transmitter and we had communication working before but now whenever we connect them my serial output used to write square (characters) really really fast until it crashed.  I reinstalled arduino and now it writes the squares slower but it doesn't write the correct information.

Any ideas as to what squares in the serial means?

AWOL

It usually means your bit rates aren't matched.
You haven't shown the initialisation of the Serial object.

165677106

Can you give me a sample of the initialisation?

The baud rate of the COM port and the transmitter are the same

AWOL

Quote
Can you give me a sample of the initialisation?


Code: [Select]
Serial.begin (Your_Bit_Rate_here);

165677106

error: expected constructor, destructor, or type conversion before '.' token

165677106

fixed that.  Hat it outside of setup

AlphaBeta

#6
Sep 02, 2009, 03:29 pm Last Edit: Sep 02, 2009, 03:30 pm by AlphaBeta Reason: 1
Code: [Select]

void setup(){
 Serial.begin (Your_Bit_Rate_Here);
}

:)
[edit]Missed you by 15 seconds.
Nothing better than solving the problems yourself :][/edit]

165677106

the serial isn't squares anymore.   It's writing fast again and now it's ├┐

AWOL

Quote
Hat it outside of setup


I don't think you can do that.

165677106

well I put a delay(1000) after setting up the serial and now it writes to multiple lines and it's receiving the same information that the transmitter is printing.

Do you know why this worked?

Grumpy_Mike

Quote
void loop(){
  char c = Serial.read();
  Serial.print(c);
}


The problem is that you are not waiting for there to be anything in the serial input buffer, so you are just extracting rubbish. These are being printed as odd characters. Look up the use of serialAvailable();

jabber

Try using a serial terminal that shows hex & ascii to see what data is being received

Go Up