R Meets Hardware

R is a programming language for statistical computing and data visualization. It has been adopted in the fields of data mining, bioinformatics, and data analysis.

https://en.wikipedia.org/wiki/R_%28programming_language%29

Data mining, bioinformatics, data analysis…

…But not hardware.

We assume R isn’t useful for flipping switches and reading sensors. But that’s an assumption, not a fact.

Let’s be honest. Computer languages are just an abstraction layer on top of the metal. Languages provide constructs to make the expression of logic easier, tailored for the different ways people approach logic and data. But all languages eventually drive the behavior of transistors, and the logic gates and microcircuits built on top of those transistors.

We assume R doesn’t care about transistors. Possibly true, but I don’t believe that’s set in stone. In fact, I’ve proved it’s not true.

Continue reading R Meets Hardware

Rain – Evapotranspiration = mm Water

“Eeee-VAP-oooo-TRANS-PURR-ation,” I savor the word as I release it into our conversation. I’m still at the party with Marsha and Bob. We’re trying to determine why anyone (such as me) would want to use R on their Raspberry Pi.

Photo by Tima Miroshnichenko

“Big word,” says Bob. “What’s it mean?”

“Water evaporation from the earth and transpiration from plants,” I respond. “It’s a sum of the water escaping from my irrigation system. Look it up on Wikipedia.”

Marsha interrupts grumpy Bob; “So – That means, um…desired amount of water – rainfall + evapotranspiration equals the amount of water your irrigation system needs to supply.”

“Precisely,” I agree. “Until I found out about evapotranspiration, I was unsure how to account for temperature. I knew hot days would require more water because of increased evaporation; but was stumped how to translate temperature into increased inches of necessary water.”

“Never heard of it,” says Bob.

“Me neither,” I agree. “Evapotranspiration is handy, but doesn’t show up in all weather forecasts. Open-Meteo makes it available.”

“Say you’ve got seven days worth of this miracle number,” says Bob. “What does the R code look like?”

Continue reading Rain – Evapotranspiration = mm Water

Party Buzz Kill: Data Storage

I’m at this party where Bob and Marsha and I are discussing the best languages for programming a Raspberry Pi. Bob advocates for Python, Marsha is a devout student of C. I’m defending my use of R. After all, Raspberry Pi starts with R. We have chased all the other guests out of the room with our conversation.

“With R, I have all sorts of built-in data management,” I say. “Manipulating matrices is in R’s basic DNA.”

Steve wanders in from the other room and joins our conversation. “Matrices aren’t a proper data strategy. You should be using a database. You can run SQLite on a Raspberry Pi with hardly any effort.”

Bob and Marsha simultaneously turn to stare me down. They are curious about how I’m going to get around this supposition.

“Sure. SQL with R–in particular SQLite, would have been easy to implement,” I pontificate. “Just call up RSQLite, push a few buttons, and Bob’s Your Uncle.”

“And that’s not what you did?” Steve is incredulous.

“I store the R object on disk and pull it into memory when I need it.”

“What kind of knucklehead stores data as a file on disk?”

Continue reading Party Buzz Kill: Data Storage

R Waters My Garden

I’m at a party, and the topic of programming languages comes up. A quarter of the room politely leaves, another half rudely leaves, and the remaining three people banter about the proper language for a certain project. Bob, Marsha, and I have the room to ourselves.

Tonight we’re talking microcontrollers: Arduino or Raspberry Pi. We like to connect things and aren’t afraid to release the magic white smoke with an ill-advised application of excess voltage. Bob assumes programming is done with micropython. Marsha prefers C.

“I use R to water my garden,” I say. “Yep, I installed R on a Raspberry Pi and use it to turn the water valves on and off.”

Continue reading R Waters My Garden

In Praise of the Dirty Protype

I’m working on my irrigation system. This requires a controller to turn it on and off. Cheap controllers are just timers. More expensive controllers factor in the current weather and avoid watering the garden during a rainstorm. Very expensive controllers (weather-based irrigation controllers) look at weather forecasts to avoid irrigating the garden when a rainstorm is going to happen in the next few days.

I’m satisfied with simple timers, but I forget to bring them in before freezing weather. They freeze, they break. Time to buy a new timer.

I’d like to be more sophisticated about my watering schedule. And I have all these Raspberry Pi and electronics parts laying around the house. It’s time to put together a Raspberry Pi Powered irrigation system with look-ahead scheduling based on the actual water needs of my plants. That’s a lot of technology to put together and get to work reliably.

Continue reading In Praise of the Dirty Protype