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
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:
- Increase the transmission speed (this depends on the distance of the wires and the noise).
- Decrease the start/stop bits (this reduces the certainty the values will arrive ok)
- 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.
-
Well I'm now at 9600baud and what I want to achive is less air time. How would one pack the values?user3635319– user36353192020年01月03日 20:07:41 +00:00Commented Jan 3, 2020 at 20:07
-
For example like I said, instead of serial.print, send it as floatsMichel Keijzers– Michel Keijzers2020年01月03日 20:08:41 +00:00Commented Jan 3, 2020 at 20:08
-
using Serial.print(floatVariable);Michel Keijzers– Michel Keijzers2020年01月03日 20:19:05 +00:00Commented Jan 3, 2020 at 20:19
-
1And boost the serial speed to 115200, will be 12x faster.CrossRoads– CrossRoads2020年01月03日 20:42:37 +00:00Commented Jan 3, 2020 at 20:42
-
@CrossRoads if the noise/distance allows it, that's an easy improvementMichel Keijzers– Michel Keijzers2020年01月03日 20:54:19 +00:00Commented Jan 3, 2020 at 20:54