Sometimes world of embedded devices are not really far from ruby world.
I’m currently playing with sensor data and arduino. Sensor data and data science can be amazing. Getting some insights from data of real world. Statistics on sound level snapshots for example… and try to detect wider context from small and poor data.
So pushing the information to internet is a bigger concern. I use the cc3000 wifi component but i need to code the server side and higher volume or rate of data seams to be more difficult.
So why not get directly data from serial ? It is just having the arduino board connected to the USB of my mac and using a devices like this: /dev/cu.usbmodem14111
Here is the code to print characters received:
#simplest ruby program to read from arduino serial,
#using the SerialPort gem
#params for serial port
port_str = "/dev/cu.usbmodem14111" #may be different for you
baud_rate = 115200
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
#just read forever
while true do
while (i = sp.gets.chomp) do # see note 2
#puts i.class #String
sp.close #see note 1
Its time to bench and try to push data the faster way possible ;) … can be interesting for snapshot of mean sonor level for example…