“Sensors are fun. They are small electronic chips that can sense this world. Our smartphones have a bunch of sensors, like gyroscope and accelerometer, but you can also connect these sensors with either an Arduino or a Raspberry Pi. (In this post, I won’t talk about Raspberry Pi because although I have one Raspberry Pi at home, the only thing I did with that board so far is to get it out of box… 😳)
As an open-source project, Arduino allows people to write C-like code to program a microcontroller. It also has an IDE, which comes with a Serial Monitor. As a data scientist, from the moment I saw the data inside the Serial Monitor, I began to wonder if we can get the data out of this box and maybe visualize them in R, where I have a lot more tools to generate better visualizations.
Therefore, after some trial and error, I managed to use rcpp to port a C-based library ArduinoSerial into R as an R package called arduinor and use that to stream data into R and RStudio. I also created a addin-like shiny app to make the “entry-level” visualization and data-collection a little easier. However, since this C package only runs on POSIX-compatible systems, you can’t use this arduinor R package on a Windows machine either - it won’t build. In the future, it might be possible to extend the support to Windows through using this libserialport C++ package.”