2017년 6월 10일 토요일

How to send integers from an Arduino device to a desktop?


I'm new to Arduino and I'm struggling to find a way to send integer value from the Bluefruit Feather 32u4 to my desktop app. I'm trying to send data through my BLE connection like this:

int value = 300;
ble.println(value);
However, I think that this function isn't for that, cause in the desktop app, what I get is a string. The code I wrote for that BLE client was based on the example provided by Microsoft (available here). Any suggestions on what should I be doing to send integer values from the Arduino device to the desktop?

--
You might want to try write() instead, but be aware that you might have to deal with several technical issues, e.g. different architecture endianness and different variable size. Even if it works on your own machine without much effort, portability is still an issue since it might not work on others. String-based data exchange is good enough for most applications, since it avoids unnecessary complexity.

--
Thank you for your reply! But in this case I'm worried with performance too, cause I'll need to send a stream of data. I don't believe that sending strings will be the best in this scenario.

--
fine, mine was only a suggestion. :) 

--

댓글 없음:

댓글 쓰기