Thank you so much for these videos! I struggled so much trying to send serial data via hc-05 bluetooth module connection and this helped me immensely. I tried quite a few other tutorials but none of them broke down serial communication the way yours did. Very well done and very much appreciated!
Parts 1 & 2 have cleared up hours of head scratching after trying to read tutorials on sending data via serial in Stackoverflow and Arduino forums. I come from a JavaScript background, but the devil is in some of the minor details which go unexplained in a lot of forums out there (probably because prior knowledge of arduino programming and concepts is assumed). Those minor details given here made it much easier to understand code elsewhere that had me flummoxed. Thank you; you've earned my sub.
The best tutorial ever. I have watched a bunch of other videos, they all just throw codes at me without really get to understand the fundamentals. This video explained every bit of the code "bit by bit". Definately filled all the questions marks I had previously!
Very good tutorial, and helped me get started on Serial for sure. I did find one thing that might need to be tweaked. Every loop if you exceed the MAX_MESSAGE_SIZE you will lose 1 char out of the buffer. This is because we call Serial.read() before checking the max length of the array. There are many ways to solve this, I ended up doing the check for the max message size before a serial read to prevent losing one position out of the buffer. Using the identical else to clean up anre print the buffer, so I didn't read an extra byte from the buffer. Thanks again for the great content!
Thanks for another great tutorial, Michael. I was following closely but expected line 26 to have an OR || rather than an AND &&: 26 If (inByte != ‘ ’ && (message_pos < MAX_MESSAGE_LENGTH - 1)) I thought would be, 26 If (inByte != ‘ ’ || (message_pos < MAX_MESSAGE_LENGTH - 1)) If I have spotted an error, then it is all thanks to having completed your course. But if I have misunderstood I wonder if you could set me right? Many thanks.
Hi, thanks However, my doubts are not yet satisfied I still wonder if arduino mega has different buffers for the different serial ports Also, there are plenty of tutorials how to send ASCII characters with serial communication, and my goal, is really understand if i can take the incoming bytes as such, instead to deal with ASCII; most of all, thinking in communication between arduinos instead a PC. For example, an arduino controlling a maschine, with instructions that another one can get from internet via wifi , or any sensor arrangement, or a arduino that controlls others that operate maschines, etc. Arduino is a excellent device to control real world equipment, that allows us to not have to depend on specific control devices already made, that mostly are not the exactly what we need, or are too expensive, or does not fit our needs in implementation Sadly, seems that arduino is used almost as a toy, instead of the real capabilities it offers Just a thought Again , thanks
@programmingelectronics I suppose they should go just outside the while loop and inside the void loop. That way you can reset them to default in each loop. Leaving them inside the while loop the pos is always 0 and the message always changes. I can't understand if it works properly.
@@periklisdrakousis6537 The variable is set as static, and so it is only initialized once (then that initialization is skipped over after that), which is why it works like it does.
i'm sorry but, i'm confused. static char message[12] consists of 11 characters and a NULL character when you typed "sub sandwich" = 12 characters, where is the NULL character?
Thanks for the great tutorial series. Is there a way we could put a reset in the program when serial communication between master & slave (Simplex) could not sync. I have a master that sends multiple bytes Ex. "A" contains int val of 2, B has 5, C has7 value and so on. When I power up both master & slave at the same time it all syncs fine. But when you power up one after the other it does not sync even after waiting. When you press reset of slave, one or several times it syncs. I'm using Arduino mega for both master & slave using Serial 2 port. Is there a way to put a software reset when it does not sync for say about 2 seconds. I'm using arduinoJson to serialize & deserialize. I think it's also useful to have a reset when the serial wire was accidentally disconnected. Thanks you.
thanks or serial communication class, i tried to implement that i got following message extern int atoi(const char *__s) __ATTR_PURE__; initializing argument 1 of 'int atoi(const char*)'. now i do not know what is the solution to that. please give some hint , THANKS ^~~~
Is anyone testing this with the Arduino sketch editor? I copied the code in and tinkered in the serial monitor with No line editing, newline, carriage return, Both NL & CR and none of them parse the data into neatly organized output. It doesn't work for me. Bummer.
bro in this code .how to make if condition .eg a charecter is sented to serial monitor (‘A’).the charecter is after sent i want print (serial.println(“enter”) you understand this? please help 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
Great question! When you use the read function, it clears the serial receive buffer - so depending on the timing you need, you could send a couple, then read a couple, and work through the 6k ints that way... of course, it might depend on what you're doing with the ints when they arrive...
Using the same code, if I type a random word and type Enter then the serial monitor displayed the same word I typed in, but on the next line, it gave a zero, is it because the atoi() function doesn't work, or what gets stored in the variable number, when assigned with atoi(message)?
Ahh a real tuturial. Not this garbage where a guy with a mobile phone-microphone talks and shows the full code for a few seconds and then shows the outro. Make more of this kind of tutorials.
@@programmingelectronics I think topic on proper use of PWM, interrupts, multiple serials(once I was programming rfid,fingerprint,gps and gsm and I was getting trouble on which serial initialize first later on I managed to rearrange properly but I didn't know why arrangement of which serial matter), and serial plotter as well Thanks
one of the best tutorials ive ever seen...The format, content, even the voice is cool ...Thank you
Thank you!
Thank you so much for these videos! I struggled so much trying to send serial data via hc-05 bluetooth module connection and this helped me immensely. I tried quite a few other tutorials but none of them broke down serial communication the way yours did. Very well done and very much appreciated!
Awesome to hear Dave! This stuff can be confusing sometimes, so seeing a couple walk throughs never hurts. Best of luck on your project!
Parts 1 & 2 have cleared up hours of head scratching after trying to read tutorials on sending data via serial in Stackoverflow and Arduino forums. I come from a JavaScript background, but the devil is in some of the minor details which go unexplained in a lot of forums out there (probably because prior knowledge of arduino programming and concepts is assumed).
Those minor details given here made it much easier to understand code elsewhere that had me flummoxed. Thank you; you've earned my sub.
So glad it helped! I hope you enjoy using Arduino!
The best tutorial ever. I have watched a bunch of other videos, they all just throw codes at me without really get to understand the fundamentals. This video explained every bit of the code "bit by bit". Definately filled all the questions marks I had previously!
Thanks so much for the note! Much appreciated!
It's impossible not to subscribe after this smooth tutorial
Thanks!
Very good tutorial, and helped me get started on Serial for sure. I did find one thing that might need to be tweaked. Every loop if you exceed the MAX_MESSAGE_SIZE you will lose 1 char out of the buffer. This is because we call Serial.read() before checking the max length of the array. There are many ways to solve this, I ended up doing the check for the max message size before a serial read to prevent losing one position out of the buffer. Using the identical else to clean up anre print the buffer, so I didn't read an extra byte from the buffer. Thanks again for the great content!
I'm having trouble understanding Serial Communication. This is a life saver! Thankyou!
Glad it helped!!
Dude, you are a wicked good teacher. One of the best I've seen in 30 years in the electronics game.
Thanks for that note Rob! Much appreciated!
lipakk!
The quality of your tutorials is incredible. Thank you!
Thanks for the note and thanks a ton for watching!
Hi, it is the best teaching I ever watch. One question, why did you add '\0' at the end of the message?
Thank you for the simple to understand and detailed explanation of this. It's super helpful.
Thanks for watching Jon!
Thank you so much!
with this I can control a servo wirelessly using node-red serial out
you just saved my thesis dear sir!
Great teacher sir.
Thanks!
very informative to understand Serial. thanks
Thanks Ed!
Why are you declaring your variables inside of the loop? It looks like message[] and message_pos will be created anew with every incoming byte.
Great question Hugh! Those are static variables, so they will only be declared and initialized the first time through the loop.
@@programmingelectronics Thanks. I'm more familiar with database programming and didn't understand the "static" declaration.
Very useful, subscribed!
Awesome, thank you!
Thanks for another great tutorial, Michael. I was following closely but expected line 26 to have an OR || rather than an AND &&:
26 If (inByte != ‘
’ && (message_pos < MAX_MESSAGE_LENGTH - 1))
I thought would be,
26 If (inByte != ‘
’ || (message_pos < MAX_MESSAGE_LENGTH - 1))
If I have spotted an error, then it is all thanks to having completed your course. But if I have misunderstood I wonder if you could set me right? Many thanks.
Super Great Video! but I dont see anything in your code to indicate which pin incoming data would coming in?
(also i'm kind of a noob)
Great question!! The serial Input here is coming in via USB which is connected to pins 0 and 1 on the Arduino. Hope that helps some!
It was a great explanation. Thank you so much.
Glad it helped!
Great. now how do I compare the “message” to a constant in an if statement to actually use it?
Hi, thanks
However, my doubts are not yet satisfied
I still wonder if arduino mega has different buffers for the different serial ports
Also, there are plenty of tutorials how to send ASCII characters with serial communication, and my goal, is really understand if i can take the incoming bytes as such, instead to deal with ASCII; most of all, thinking in communication between arduinos instead a PC. For example, an arduino controlling a maschine, with instructions that another one can get from internet via wifi , or any sensor arrangement, or a arduino that controlls others that operate maschines, etc.
Arduino is a excellent device to control real world equipment, that allows us to not have to depend on specific control devices already made, that mostly are not the exactly what we need, or are too expensive, or does not fit our needs in implementation
Sadly, seems that arduino is used almost as a toy, instead of the real capabilities it offers Just a thought
Again , thanks
I have a q. Are you sure we have to put the char message and message_pos inside the while loop?
Good q.
Great question. You could set those up as global variables if you wanted.
@programmingelectronics I suppose they should go just outside the while loop and inside the void loop. That way you can reset them to default in each loop. Leaving them inside the while loop the pos is always 0 and the message always changes. I can't understand if it works properly.
@@periklisdrakousis6537 The variable is set as static, and so it is only initialized once (then that initialization is skipped over after that), which is why it works like it does.
@@programmingelectronics ok thk u.
i'm sorry but, i'm confused.
static char message[12] consists of 11 characters and a NULL character
when you typed "sub sandwich" = 12 characters, where is the NULL character?
at 13th position you can print it to check.
Get it “cereal bowl”…. Lolo😂😂
Thank you very much....
And today I feel even more cheated by my college tuition when I see your extremely clear and understandable videos right on the internet.
I hope you find them helpful!
how perfectly described... wow..
Thanks!
Excellent tutorial. However, I was expecting some sort of example towards the end to show how this program works.
Can ESP32 code by Ardunio IDE use this code sir ?
how to send data from arduino uno to my esp8266 nodemcu and how to connect the to components ?
Thanks for the great tutorial series. Is there a way we could put a reset in the program when serial communication between master & slave (Simplex) could not sync. I have a master that sends multiple bytes Ex. "A" contains int val of 2, B has 5, C has7 value and so on. When I power up both master & slave at the same time it all syncs fine. But when you power up one after the other it does not sync even after waiting. When you press reset of slave, one or several times it syncs. I'm using Arduino mega for both master & slave using Serial 2 port. Is there a way to put a software reset when it does not sync for say about 2 seconds. I'm using arduinoJson to serialize & deserialize. I think it's also useful to have a reset when the serial wire was accidentally disconnected. Thanks you.
so i can create a while loop to read msg.payload from node red before running the rest of the sketch ?
9600 bits per second og bytes per second. At about 3:10 in the video you said one thing and wrote the other in the subtitle?
It bits, my apologies for any confusion.
thanks or serial communication class, i tried to implement that i got following message extern int atoi(const char *__s) __ATTR_PURE__; initializing argument 1 of 'int atoi(const char*)'. now i do not know what is the solution to that. please give some hint , THANKS
^~~~
Hi Can I use Serial.read() to input long data type?
Got something going with a GPS module and a Cardputer.
Cool!
Is anyone testing this with the Arduino sketch editor? I copied the code in and tinkered in the serial monitor with No line editing, newline, carriage return, Both NL & CR and none of them parse the data into neatly organized output. It doesn't work for me. Bummer.
We need to do same data read from lcdI2c
bro in this code .how to make if condition .eg a charecter is sented to serial monitor (‘A’).the charecter is after sent i want print (serial.println(“enter”)
you understand this?
please help 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
i am waiting your reply
hi, if i want to send let's say 6000 int from laptop to arduino how i can do this ? because arduino buffer take only 64 byte !
Great question! When you use the read function, it clears the serial receive buffer - so depending on the timing you need, you could send a couple, then read a couple, and work through the 6k ints that way... of course, it might depend on what you're doing with the ints when they arrive...
where is the next video?
Hi V J, I believe it is this one:
sprintf() with Arduino
ua-cam.com/video/wCfH9VlJKrY/v-deo.html
when we will see next part?
The last part in this series should be out this week.
error..number not declared after atoi() statement
Using the same code, if I type a random word and type Enter then the serial monitor displayed the same word I typed in, but on the next line, it gave a zero, is it because the atoi() function doesn't work, or what gets stored in the variable number, when assigned with atoi(message)?
Great question, by chance, in your serial monitor window do you have something other than "New Line" selected in the drop down?
Are you the voice actor for two point hospital XD
They asked me, but I respectfully declined.
no need to do this kind of read procedure. various functions of serial read is already available for reading string char and numbers
Ahh a real tuturial. Not this garbage where a guy with a mobile phone-microphone talks and shows the full code for a few seconds and then shows the outro. Make more of this kind of tutorials.
Thanks so much - I hope it helped!
@@programmingelectronics Yepi learned to read serial messages only with this video in a half hour! THANKS!
@@altesocke1727 Great!
one of the best tutorials ive ever seen...The format, content, even the voice is cool ...Thank you
It's impossible not to subscribe after this smooth tutorial
Glad it was helpful! Are there any specific Arduino topics you would like covered?
@@programmingelectronics I think topic on proper use of PWM, interrupts, multiple serials(once I was programming rfid,fingerprint,gps and gsm and I was getting trouble on which serial initialize first later on I managed to rearrange properly but I didn't know why arrangement of which serial matter), and serial plotter as well Thanks
@@blackartista awesome! Thanks for these ideas!