Arduino segregating serial data

Hi😀. I'm planning to work on an rc joystick tank with hc05 or nrf24l01. Joysticks are basically potentiometers. So I'm basically sending potentiometer values into the air. I'm wondering, if I use the Serial.print(pot x axis) function and Serial.print(pot y axis), won't it get the receiver confused? Like its basically sending numbers, so how does it know that what I sent is for the x axis or y axis. I have heard about data "packaging" and it seems complex but I am willing to grasp if you will help me. Looking forward to your help. Thank you!

The approach is different, since HC05 is serial in nature, NRF is packet based in nature. So which one?

For the serial method, it's easy:

Serial.print(x);
Serial.print(",");
Serial.println(y);

at the other end you would see a line like

49,119

Which is terminated with an end of line, so you can always tell which value is which.

This is known as CSV format, Comma Separated Values, if you want to Google it.

It's also easy for the NRF. You'd define a struct containing the 'x' and 'y' values and send it as a whole in a single packet.

I was thinking, beginner level. But I never touched on receiving serial. That often needs some guidance.

Perhaps some detailed information about the OPs project would dig up some pointers to help choose between the BT and NRF. It may be the determining factor.

Thanks for your reply. I see. So for hc05, it will be separated by a comma. Then how do I read its value then store it in a variable?

Then for nrf, yeah it seem complex. But can't I do like the same thing? Separate values with commas?

Find the forum tutorial, "Serial Input Basics". You can find it with the search tool.

Our posts crossed, I was editing and the forum software is slow. Can you please tell us the transmission requirements, range, latency, etc? In what environment, fixed, variable, indoor, outdoor...?

The BT and NRF use inherently different comms protocols and it's reflected in the software requirements (needs). Then also the interface and data types used.

I was hoping to go with max 100m outdoor within sight. I'm not planning to go fpv so I don't think I will be going through some obstacles. My first decision really was hc05. But I figured out that nrf was "cheaper", and also a good start for me to learn spi. But if nrf won't be a practical device to use then maybe I might just go with hc05.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.