I have experimented with reading an Arduino signal into R in the past, using Rserve and Processing. Actually, it is much easier. I can read the output of my Arduino directly into R with the scan function.
Here is my temperature sensor example again:
And all it needs to read the signal into the R console with my computer is:
> f <- file("/dev/cu.usbmodem3a21", open="r") > scan(f, n=1) <b>Read 1 item</b>  20.
It is really getting colder in London - it is now about 5°C outside. The heating is on and I have got better at measuring the temperature at home as well. Or, so I believe.
Last week’s approach of me guessing/feeling the temperature combined with an old thermometer was perhaps too simplistic and too unreliable. This week’s attempt to measure the temperature with my Arduino might be a little OTT (over the top), but at least I am using the micro-controller again.
It is getting colder in London, yet it is still quite mild considering that it is late November. Well, indoors it still feels like 20°C (68°F) to me, but I have been told last week that I should switch on the heating.
Luckily I found an old thermometer to check. The thermometer showed 18°C. Is it really below 20°C?
The thermometer is quite old and I’m not sure that is works properly anymore.
What a great little device the Raspberry Pi is! After my initial setup it is time to play around with the input and output pins. The first example has to be to switch on an LED. This can also be done remotely via a web interface and better, I cannot only switch the LED off, but the whole Raspberry Pi as well.
Thanks to the work of many others, it is straightforward to control the GPIO (General-purpose input/output) pins.
Since Christmas I have been playing around with a Raspberry Pi. It is certainly not the fastest computer, but what a great little toy! Here are a few experiences and online resources that I found helpful. Setup Initially I connected the Raspberry Pi via HDMI to a TV; together with keyboard, mouse and an old USB Wifi adapter. Everything worked out of the box and I could install Raspbian and set up the network.
I have a mid-2007 iMac with a 2.4 GHz Core2Duo processor and despite the fact that it is already six years old, it still does a good job. However, compared to a friend’s recent MacBook Air with a solid state disk (SSD) it felt sluggish when opening programmes and loading larger documents.
So, I thought it would be worthwhile to replace the old spinning hard disk drive with an SSD, instead of buying a new computer.
If connecting data to the real world is the next sexy job, then how do I do this? And how do I connect the real world to R?
It can be done as Matt Shottwell showed with his home made ECG and a patched version of R at useR! 2011. However, there are other options as well and here I will use an Arduino. The Arduino is an open-source electronics prototyping platform.