0

What would be the best way to send the following information from one MCU to another?

Now I'm just sending the sentence over as is eg. Serial.print(sentence in here)

Example sentence: 1306,60.123456,50.123456,23.765382,40.897558,245,85,20.3,5,65,1500,0.9

Many thanks.

1 Answer 1

1

It depends actually on your requirements what is 'best'.

If (transmission) speed is an issue, there are mainly some things you can do to improve this:

  1. Increase the transmission speed (this depends on the distance of the wires and the noise).
  2. Decrease the start/stop bits (this reduces the certainty the values will arrive ok)
  3. Pack your data (takes more processing time possibly, and more programming work, but can be faster).

About the third option: since you are mostly sending values, you can make some improvements. So you can send them as float (by sending the float data, with the length of sizeof(float)). However, note there could be inaccuracies in the last digit.

5
  • Well I'm now at 9600baud and what I want to achive is less air time. How would one pack the values? Jan 3, 2020 at 20:07
  • For example like I said, instead of serial.print, send it as floats Jan 3, 2020 at 20:08
  • using Serial.print(floatVariable); Jan 3, 2020 at 20:19
  • 1
    And boost the serial speed to 115200, will be 12x faster.
    – CrossRoads
    Jan 3, 2020 at 20:42
  • @CrossRoads if the noise/distance allows it, that's an easy improvement Jan 3, 2020 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.