Have noticed gobbledegook being printed at beginning of first line of print... simple example shown below.......
void setup() {
Serial.begin(9600);
char sdata[] = "asdfghjkl";
int ax = 20;
int ay = 40;
prtout(sdata,ax,ay);
}
void loop() {
}
void prtout(char *data, int px, int py){
Serial.println();
Serial.println(px);
Serial.println(py);
Serial.write(data,strlen(data));
}
....which results in....
20:14:41.658 -> ! Pt0bcbbb %q ) !@:
20:14:41.819 -> 20
20:14:41.819 -> 40
20:14:41.819 -> asdfghjkl
The Serial monitor is set to 9600.
Any answers?
Welcome to the forum
You started a topic in the Uncategorised category of the forum
Your topic has been moved to a relevant category
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination
https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
Your code works OK for me. It prints what I would expect
Which Arduino board are you using ?
What prints if you reset the board after uploading the code ?
Try adding delay(500)
after Serial.begin(9600)
. On some boards you need to allow some time for USBSerial to get connected.
Using an ESP-WROOM-32 board
I tried delay(500) an delay(1000); but still see the junk.
What I do notice is that the junk prints followed by a delay then followed by the real data.
Seems to suggest something to do with the begin() statement.
I suspect that what you are seeing is the standard output from the ESP32 that occurs when it is booted up but it is not output at 9600 baud
If you set the baud rate of the sketch and Serial monitor to 115200 it will probably look something like this if you reset the board after uploading the code
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
20
40
asdfghjkl
Definitely something to do with the Begin() statement. I put in a 5 sec delay - junk printed immediately, followed by 5 sec wait then real data printed. Odd.
Yes, exactly right. I didn't know that the ESP standard was 115200.
Thanks for your help.
Problem solved - UKHeliBob answered, all to do with Serial output rate, should be 115200 on ESP32.... I was using 9600.
Thanks for your reply.
For my part I use 115200 on all Arduinos
racine0202:
9600
That's the baud rate from the 80's. I don't know why it's in every Arduino example like that.
system
Closed
July 4, 2024, 9:12pm
13
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.