SlideShare a Scribd company logo
Carl Howe
Director of Education, RStudio
carl@rstudio.com
http://carlhowe.com
@cdhowe
!2
RStudio's Mission:
Equip everyone, regardless of means,
to participate in a global economy that
rewards data literacy
!3
RStudio Education's mission:
Train the next million R users
#NextMillionRUsers
rstd.dio/learning-r-survey
Using R to Understand
the Internet ofThings
Carl Howe
Director of Education
carl@rstudio.com
@cdhowe
18 YEARS AGO IN 2001.....
• Google was 5 years old
• Dial-up still ruled the Internet
• E-commerce companies had just crashed and burned (e.g., pets.com)
• Facebook and Twitter hadn't been founded yet
• Nokia dominated mobile phones
• The mobile internet didn't exist
AGENDA
• Which Internet things are we talking about?
• Ingredients
• Software
• Tricky bits
Internet of Things Definition:
Semi-programmable devices

that try to talk on the Internet
!11
2013 GRAND 5-YEAR GREEN PLAN
1.Install solar panels
2.Buy electric cars
3.Install solar batteries
4.Live more greenly
!13
DC-to-AC
Solar
Inverters
Solar
Circuilt
Breaker
#1
Solar
Power
Meter
Solar
Circuilt
Breaker
#2
Solar
Circuilt
Breaker
#3
Two-
Way
Smart
Meter
SOLAR POWER SYSTEM (SIMPLIFIED)
Solar Panels
Direct
Current
(DC)
Alternating
Current
(AC)
Inverters Solar Power Meter Utility Power Meter
TWO FUNDAMENTAL QUESTIONS
• How much power do we generate?
• How much power do we use?
SOLAR POWER SYSTEM (SIMPLIFIED)
Solar Panels
Direct
Current
(DC)
Alternating
Current
(AC)
Inverters Solar Power Meter Utility Power Meter
Solar
Monitoring System
Internet
Monitoring
Unit
Internet of Things Rule #1
Most IoT devices either use or respond to TCP/IP Port 80
In other words, they speak Web
THIS IS WHAT YOU SEE ON PORT 80!
WAT?
WATT???
Internet of Things Rule #2
If something speaks Web, 

we can almost always use R and Linux to work with it
Our platform: Raspberry Pi B+
RASPBERRY PI B+ DETAILS
System on a chip: Broadcom BCM2835
CPU: ARM Cortex-A53, 700 MHz
RAM: 512MB RAM
Networking: 10/100 Ethernet, no wireless
Storage: microSD
GPIO: 40-pin header, populated
Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface
(CSI), Display Serial Interface (DSI)
Costs about $25 plus power supply and case (total about $45)
RASPBERRY PI SOFTWARE
Raspbian OS, which is a derivative of Debian Linux
Comes with Python pre-installed
Does NOT come with R pre-installed
WAT????
USEFUL TOOLS WE'LL WANT
• curl (fetch web pages)
• R
• RCurl (fetch web pages)
• XML (parse web pages)
• rvest (harvest web pages in a dplyr kind of way)
• Apache Web server
GOTCHAS
• A Raspberry Pi is not an Intel machine
• You may have to compile most or all of your libraries
• Some libraries and functions may not be available at all.
INSTALL TOOLS AND LIBRARIES YOU NEED
• apt-get is a Linux tool to install software from Internet repositories
• We'll use it to fetch tools and libraries we'll need on Raspbian
sudo apt-get -y build-dep libcurl4-gnutls-dev
sudo apt-get -y install libcurl4-gnutls-dev
sudo apt-get install libcurl4-openssl-dev libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install emacs apache2
NOW INSTALL THE LATEST VERSION OF R
$ time sudo apt-get install -y gfortran libreadline6-dev libx11-dev libxt-
dev 
libpng-dev libjpeg-dev libcairo2-dev xvfb 
libbz2-dev libzstd-dev liblzma-dev 
libcurl4-openssl-dev 
texinfo texlive texlive-fonts-extra 
screen wget
$ cd /usr/local/src
$ sudo wget https://cran.rstudio.com/src/base/R-3/R-3.5.2.tar.gz
NOW INSTALL THE LATEST VERSION OF R
$ sudo su -
# cd /usr/local/src
# tar zxvf R-3.5.2.tar.gz
# cd R-3.5.2
/* Modify line 27483 in the ./configure file by changing :: to ;; */
/* This was a distribution but in 3.5.1 -- not sure if it's there in 3.5.2 */
/* But it can't hurt to check
# time ./configure
# time make
# time make install
# which R
AND INSTALL ALL THE R PACKAGES
# install.packages("tidyverse") fails!!! You'll have to install dplyr,
ggplot2, etc. separately
# Expect it to take an hour or two to download and install everything you
need.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> install.packages(c("dplyr", "ggplot2", "httr",
"reprex", "rvest", "RCurl", "XML2"), depends = TRUE)
So Where Were We?
ARCHITECTURE: VERSION 1
/var/www directory
Data Plotter
SolarToday.png
Apache Web
Server
Index.html2019-01-21.csv
Inverter Data
Collector
Read inverter monitor
Try to parse HTML
Find the data hidden in Javascript
The plotter is just straight ggplot2
OUTPUT: VERSION 1
HOWEVER.....
• Every few days one of the R programs just stops with funky errors
WAT????
Internet of Things Rule #3
Just because your IoT device speaks Web
doesn't mean it's smart or error-free
GOTCHA #1: DEVICES DO THEIR OWN THING
• Solar inverters turn off when the sun isn't shining
• When they are in the process of turning on or off, they don't always return results
• Both the solar monitoring and plotting program needed tweaks to deal with very
unexpected results
• Error returns
• Badly formatted HTML
IOT ECONOMICS
Your device was programmed by the lowest bidder
using the cheapest components
Do not expect that it has been rigorously vetted or
even rigorously tested
Treat data skeptically before trusting it
Inverter 1 Inverter 2
2019-01-21 10:37:52 8 195
2019-01-21 10:39:49 9 198
2019-01-21 10:41:48 4105 203
2019-01-21 10:43:48 4106 214
2019-01-21 10:45:49 10 205
2019-01-21 10:47:48 10 219
2019-01-21 10:49:48 4104 204 WAT????
INVERTER 1 OCCASIONALLY FLIPS THE 4096 BIT
Inverter 1 Inverter 2 Total output
2019-01-21 10:37:52 8 195 203
2019-01-21 10:39:49 9 198 207
2019-01-21 10:41:48 4105 203 219
2019-01-21 10:43:48 4106 214 213
2019-01-21 10:45:49 10 205 213
2019-01-21 10:47:48 10 219 229
2019-01-21 10:49:48 4104 204 213
After
cleaning
Internet of Things Rule #4
Your IoT device's environment matters
WAT????
FORTUNATELY, I HAVE A WEATHER STATION
But even a weather
station doesn't tell you
if the sun is out
ARCHITECTURE: VERSION 2
Data Plotter
SolarToday.png
Apache Web
Server
2019-01-21.csv
Inverter Data
Collector
SkyImage.png
Camera
Grabber
Weather
Station Monitor
WeatherToday.png Index.html
weather.gov weatherunderground.com
THIS IS THE VERSION RUNNING TODAY
Raspberry Pi B+
Weather Station
Ethernet Gateway
Click for larger image
Click for minute-by-minute .csv data
Click Here
BUT THE R PROGRAMS STILL CRASH 

EVERY NOW AND AGAIN
WAT WAT WAT??????
SLEEPING LOOPS AREN'T THE BEST TOOLS....
• Difficult to have them fire at the right times (lubridate math isn't trivial)
• Difficult to sync them to wall clock time
• Code in the loops may leak memory over time
Internet of Things Rule #5
Run IoT things on a clock
LINUX HAS A SCHEDULER CALLED CRON
• Can run any program you like (including R code) based on wall clock time
• Very flexible (although the way you program it is a bit obscure)
• Allows you to quick and easy one-shot programs instead of long-running server code
CRONTAB EXAMPLE ON THE WEATHER PI
10 0 * * * $HOME/Solar-monitor-pi-sleepfix.R
*/5 * * * * $HOME/Plot-today-crontab.R
Run this every day at 10 minutes, 0 hours (i.e., 10 min past midnight)
CRONTAB EXAMPLE ON THE WEATHER PI
10 0 * * * $HOME/Solar-monitor-pi-sleepfix.R
*/5 * * * * $HOME/Plot-today-crontab.R
Run Plot-today-crontab.R every 5 minutes
• https://crontab-generator.org will generate these expressions for you
• You add them to your own cron table using "crontab -e" for editing
ARCHITECTURE: VERSION 3
Data Plotter
SolarToday.png
Apache Web
Server
2019-01-21.csv
Inverter Data
Collector
SkyImage.png
Camera
Grabber
Weather
Station Monitor
WeatherToday.png Index.html
weatherunderground.com
weather.gov
Cron
TWO FUNDAMENTAL QUESTIONS
• We now know how much power we generate
• How much power do we use?
HOME POWER EQUATION
Power Used Power Generated Power Bought From Utility
– =
HOME POWER EQUATION
Power Used Power Generated Power Bought From Utility
– =
ANNOYANCES
• I only get how much power I've used from the utility once a month, long after I've
used it
• Energy storage (batteries) will make this much more complicated on an hour to hour
basis
HOME POWER EQUATION
Power Used Power Generated Power Bought From Utility
– =
±
Internet of Things Rule #6
Most smart things are going wireless
REMEMBER THIS DEVICE?
• The power company doesn't want
to pay someone to physically read
my power sold and bought
• Instead, they simply broadcast the
information wirelessly on 900 MHz
(the Industrial and Scientific
Radio band, AKA the garbage
band) Two-
Way
Smart
Meter
Internet of Things Rule #7
Wireless things are pretty easy to spy on
ENTER THE SOFTWARE DEFINED RADIO (SDR)
• Listens to pretty much anything
between 100 KHz and 2 GHz
• USB interface
• Programmable to decode most any
radio signal
• Cheap to buy ($20-$30)
RASPBERRY PI V3 DETAILS FOR POWER MONITORING
System on a chip: Broadcom BCM2837
CPU: Quad-core ARM Cortex-A53, 1.2GHz
GPU: Broadcom VideoCore IV
RAM: 1GB LPDDR2 (900 MHz)
Networking: 10/100 Ethernet, 2.4GHz 802.11n wireless built in
Bluetooth: Bluetooth 4.1 Classic, Bluetooth Low Energy
Storage: microSD
GPIO: 40-pin header, populated
Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface (CSI), Display
Serial Interface (DSI)
Costs about $35 plus case and power supply (total about $55)
SOLAR POWER MONITOR VERSION 3
Data Plotter
SolarToday.png
Apache Web
Server
2019-01-21.csv
Inverter Data
Collector
SkyImage.png
Camera
Grabber
Weather
Station Monitor
WeatherToday.png Index.html
weatherunderground.com
weather.gov
Cron
ARCHITECTURE: METER READER
Data Plotter
SolarToday.png
Apache Web
Server
2019-01-21.csv
Inverter Data
Collector
Cron
power.txt
Power
Meter Reader
rtlamr
Index.html
MORE SOFTWARE TO LOAD
• Libraries for reading the SDR
• sudo apt-get install rtl-sdr gr-osmosdr
• Libraries for running the Go language
• sudo apt-get install golang
• Software for reading smart meters
• git clone https://github.com/bemasher/rtlamr
!77
RAW POWER METER READINGS
{Time:2019-01-22T14:02:35.477 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:02:35.645 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35975 CRC:0x6070}}
{Time:2019-01-22T14:13:47.105 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:13:47.174 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35976 CRC:0x6642}}
{Time:2019-01-22T14:22:03.393 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:22:03.509 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35976 CRC:0x6642}}
{Time:2019-01-22T14:32:15.257 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:32:15.375 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35977 CRC:0x84A0}}
{Time:2019-01-22T14:42:26.594 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:42:26.711 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35978 CRC:0xCCE5}}
{Time:2019-01-22T14:52:32.936 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}}
{Time:2019-01-22T14:52:33.054 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35978 CRC:0xCCE5}}
Meter IDs kWh bought
kWh sold
COMBINED POWER DATA
Power Sales
(1 kWh each)
CONSOLIDATED HOUSEHOLD USE (WITH BUGS)
Bug in windowing
calculation
ACTUAL SCREEN DISPLAYED
CONCLUSION: WE'VE ANSWERED OUR QUESTIONS
• How much power do we generate?
• How much power do we use?
INTERNET OF THINGS RULES
1.Most IoT devices either use or respond to TCP/IP Port 80
2.If something speaks Web, we can almost always use R and Linux to work with it
3.Just because your IoT device speaks Web doesn't mean it's smart or error-free
4.Your IoT device's environment matters
5.Run IoT things on a clock
6.Most smart things are going wireless
7.Wireless things are pretty easy to spy on
Carl Howe
Director of Education, RStudio
carl@rstudio.com
http://carlhowe.com
@cdhowe

More Related Content

What's hot

GDG Meetup Jakarta - Low Power IoT
GDG Meetup Jakarta - Low Power IoTGDG Meetup Jakarta - Low Power IoT
GDG Meetup Jakarta - Low Power IoTAlwin Arrasyid
 
GSM Based climate Monitoring System for Agriculture
GSM Based climate Monitoring System for AgricultureGSM Based climate Monitoring System for Agriculture
GSM Based climate Monitoring System for AgricultureLokesh K N
 
Soldatos io t-academy-cosmote-231117-v-final
Soldatos io t-academy-cosmote-231117-v-finalSoldatos io t-academy-cosmote-231117-v-final
Soldatos io t-academy-cosmote-231117-v-finalJohn Soldatos
 
Track 2 session 1 - st dev con 2016 - avnet - making things real
Track 2   session 1 - st dev con 2016 - avnet - making things realTrack 2   session 1 - st dev con 2016 - avnet - making things real
Track 2 session 1 - st dev con 2016 - avnet - making things realST_World
 
IoT Home monitoring system
IoT Home monitoring system IoT Home monitoring system
IoT Home monitoring system Puneet Mishra
 
Arduino Project Ideas
Arduino Project IdeasArduino Project Ideas
Arduino Project IdeasPhdtopiccom
 
Building Blocks for IoT Devices
Building Blocks for IoT DevicesBuilding Blocks for IoT Devices
Building Blocks for IoT DevicesAnil Gorthy
 
Internet of things (iot) based weather
Internet of things (iot) based weatherInternet of things (iot) based weather
Internet of things (iot) based weatherVivek Bhakta
 
Internet of Things using Raspberry pi
Internet of Things using Raspberry pi Internet of Things using Raspberry pi
Internet of Things using Raspberry pi sumit sharma
 
Green IoT for Smart World
Green IoT for Smart WorldGreen IoT for Smart World
Green IoT for Smart WorldPriyanka2828
 
Ardu sat (Arduino based satellite)
Ardu sat (Arduino based satellite)Ardu sat (Arduino based satellite)
Ardu sat (Arduino based satellite)Barira Khan
 
Iot based energy management system
Iot based energy management systemIot based energy management system
Iot based energy management systemTalha Mughal
 
Garbage monitoring system IOT
Garbage monitoring system IOTGarbage monitoring system IOT
Garbage monitoring system IOTamandeep singh
 
Solving connectivity for the Internet of Things - Telenor Group Technology Fair
Solving connectivity for the Internet of Things - Telenor Group Technology FairSolving connectivity for the Internet of Things - Telenor Group Technology Fair
Solving connectivity for the Internet of Things - Telenor Group Technology FairJan Jongboom
 
IoT based smart grid FYP for students
IoT based smart grid FYP for studentsIoT based smart grid FYP for students
IoT based smart grid FYP for studentsMuhammadRohanSaeed
 
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...Ekansh Agarwal
 
IOT Based Data Monitoring System
IOT Based Data Monitoring SystemIOT Based Data Monitoring System
IOT Based Data Monitoring SystemAshok Fair
 
Internet of Things (IoT) based Solar Energy System security considerations
Internet of Things (IoT) based Solar Energy System security considerationsInternet of Things (IoT) based Solar Energy System security considerations
Internet of Things (IoT) based Solar Energy System security considerationsBohitesh Misra, PMP
 

What's hot (20)

GDG Meetup Jakarta - Low Power IoT
GDG Meetup Jakarta - Low Power IoTGDG Meetup Jakarta - Low Power IoT
GDG Meetup Jakarta - Low Power IoT
 
GSM Based climate Monitoring System for Agriculture
GSM Based climate Monitoring System for AgricultureGSM Based climate Monitoring System for Agriculture
GSM Based climate Monitoring System for Agriculture
 
Soldatos io t-academy-cosmote-231117-v-final
Soldatos io t-academy-cosmote-231117-v-finalSoldatos io t-academy-cosmote-231117-v-final
Soldatos io t-academy-cosmote-231117-v-final
 
Track 2 session 1 - st dev con 2016 - avnet - making things real
Track 2   session 1 - st dev con 2016 - avnet - making things realTrack 2   session 1 - st dev con 2016 - avnet - making things real
Track 2 session 1 - st dev con 2016 - avnet - making things real
 
IoT Home monitoring system
IoT Home monitoring system IoT Home monitoring system
IoT Home monitoring system
 
Arduino Project Ideas
Arduino Project IdeasArduino Project Ideas
Arduino Project Ideas
 
Building Blocks for IoT Devices
Building Blocks for IoT DevicesBuilding Blocks for IoT Devices
Building Blocks for IoT Devices
 
Internet of things (iot) based weather
Internet of things (iot) based weatherInternet of things (iot) based weather
Internet of things (iot) based weather
 
Internet of Things using Raspberry pi
Internet of Things using Raspberry pi Internet of Things using Raspberry pi
Internet of Things using Raspberry pi
 
Green IoT for Smart World
Green IoT for Smart WorldGreen IoT for Smart World
Green IoT for Smart World
 
Ardu sat (Arduino based satellite)
Ardu sat (Arduino based satellite)Ardu sat (Arduino based satellite)
Ardu sat (Arduino based satellite)
 
Iot based energy management system
Iot based energy management systemIot based energy management system
Iot based energy management system
 
Garbage monitoring system IOT
Garbage monitoring system IOTGarbage monitoring system IOT
Garbage monitoring system IOT
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Solving connectivity for the Internet of Things - Telenor Group Technology Fair
Solving connectivity for the Internet of Things - Telenor Group Technology FairSolving connectivity for the Internet of Things - Telenor Group Technology Fair
Solving connectivity for the Internet of Things - Telenor Group Technology Fair
 
IoT based smart grid FYP for students
IoT based smart grid FYP for studentsIoT based smart grid FYP for students
IoT based smart grid FYP for students
 
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...
A PRESENTATION ON Simulation Home automation System using Proteus and Arduino...
 
IOT Based Data Monitoring System
IOT Based Data Monitoring SystemIOT Based Data Monitoring System
IOT Based Data Monitoring System
 
Internet of Things (IoT) based Solar Energy System security considerations
Internet of Things (IoT) based Solar Energy System security considerationsInternet of Things (IoT) based Solar Energy System security considerations
Internet of Things (IoT) based Solar Energy System security considerations
 
IoT@Cloud
IoT@CloudIoT@Cloud
IoT@Cloud
 

Similar to Using R for the internet of things

Hacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreHacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreNick Landry
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Adam Dunkels
 
IOT with Drupal 8 - Webinar Hyderabad Drupal Community
IOT with Drupal 8 -  Webinar Hyderabad Drupal CommunityIOT with Drupal 8 -  Webinar Hyderabad Drupal Community
IOT with Drupal 8 - Webinar Hyderabad Drupal CommunityPrateek Jain
 
Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)Jonathan Carter
 
Prototyping with the Internet of Things
Prototyping with the Internet of ThingsPrototyping with the Internet of Things
Prototyping with the Internet of ThingsSarah Ritter
 
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)MicheleNati
 
Rapid iteration for an Internet of Things
Rapid iteration for an Internet of ThingsRapid iteration for an Internet of Things
Rapid iteration for an Internet of ThingsStudioSFO
 
DockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General SessionDockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General SessionDocker, Inc.
 
Data Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixData Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixC4Media
 
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn UCICove
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: KeynoteDocker-Hanoi
 
Streaming 4 billion Messages per day. Lessons Learned.
Streaming 4 billion Messages per day. Lessons Learned.Streaming 4 billion Messages per day. Lessons Learned.
Streaming 4 billion Messages per day. Lessons Learned.Angelos Petheriotis
 
Simplifying and Future-Proofing Hadoop
Simplifying and Future-Proofing HadoopSimplifying and Future-Proofing Hadoop
Simplifying and Future-Proofing HadoopPrecisely
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Adam Dunkels
 
Internet of things - The Present & The Future
Internet of things - The Present & The FutureInternet of things - The Present & The Future
Internet of things - The Present & The Futureiotians
 
Unveiling the Sydney IoT Landscape
Unveiling the Sydney IoT LandscapeUnveiling the Sydney IoT Landscape
Unveiling the Sydney IoT LandscapeAndrew Blades
 
Big Data Approaches to Cloud Security
Big Data Approaches to Cloud SecurityBig Data Approaches to Cloud Security
Big Data Approaches to Cloud SecurityPaul Morse
 

Similar to Using R for the internet of things (20)

Hacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT CoreHacking with the Raspberry Pi and Windows 10 IoT Core
Hacking with the Raspberry Pi and Windows 10 IoT Core
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
 
IOT with Drupal 8 - Webinar Hyderabad Drupal Community
IOT with Drupal 8 -  Webinar Hyderabad Drupal CommunityIOT with Drupal 8 -  Webinar Hyderabad Drupal Community
IOT with Drupal 8 - Webinar Hyderabad Drupal Community
 
Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)Talk at the Landelijk Architecure Congress (NL)
Talk at the Landelijk Architecure Congress (NL)
 
Prototyping with the Internet of Things
Prototyping with the Internet of ThingsPrototyping with the Internet of Things
Prototyping with the Internet of Things
 
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)
IoTMeetupGuildford#2: IOT Resin.io - Lorenzo Stoakes (Resin.io)
 
Rapid iteration for an Internet of Things
Rapid iteration for an Internet of ThingsRapid iteration for an Internet of Things
Rapid iteration for an Internet of Things
 
DockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General SessionDockerCon EU 2015: Day 1 General Session
DockerCon EU 2015: Day 1 General Session
 
IoT Session Thomas More
IoT Session Thomas MoreIoT Session Thomas More
IoT Session Thomas More
 
Cc internet of things @ Thomas More
Cc internet of things @ Thomas MoreCc internet of things @ Thomas More
Cc internet of things @ Thomas More
 
Data Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixData Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFix
 
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn
How to Build Out a Tech Eco-System | Dan Cregg | Lunch & Learn
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: Keynote
 
Streaming 4 billion Messages per day. Lessons Learned.
Streaming 4 billion Messages per day. Lessons Learned.Streaming 4 billion Messages per day. Lessons Learned.
Streaming 4 billion Messages per day. Lessons Learned.
 
Simplifying and Future-Proofing Hadoop
Simplifying and Future-Proofing HadoopSimplifying and Future-Proofing Hadoop
Simplifying and Future-Proofing Hadoop
 
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
Advanced Internet of Things firmware engineering with Thingsquare and Contiki...
 
Internet of things - The Present & The Future
Internet of things - The Present & The FutureInternet of things - The Present & The Future
Internet of things - The Present & The Future
 
Node-Red
Node-RedNode-Red
Node-Red
 
Unveiling the Sydney IoT Landscape
Unveiling the Sydney IoT LandscapeUnveiling the Sydney IoT Landscape
Unveiling the Sydney IoT Landscape
 
Big Data Approaches to Cloud Security
Big Data Approaches to Cloud SecurityBig Data Approaches to Cloud Security
Big Data Approaches to Cloud Security
 

Recently uploaded

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfmbmh111980
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
Benefits of Employee Monitoring Software
Benefits of  Employee Monitoring SoftwareBenefits of  Employee Monitoring Software
Benefits of Employee Monitoring SoftwareMera Monitor
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownloadvrstrong314
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 

Recently uploaded (20)

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Benefits of Employee Monitoring Software
Benefits of  Employee Monitoring SoftwareBenefits of  Employee Monitoring Software
Benefits of Employee Monitoring Software
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 

Using R for the internet of things

  • 1. Carl Howe Director of Education, RStudio carl@rstudio.com http://carlhowe.com @cdhowe
  • 2. !2 RStudio's Mission: Equip everyone, regardless of means, to participate in a global economy that rewards data literacy
  • 3. !3 RStudio Education's mission: Train the next million R users #NextMillionRUsers rstd.dio/learning-r-survey
  • 4. Using R to Understand the Internet ofThings Carl Howe Director of Education carl@rstudio.com @cdhowe
  • 5. 18 YEARS AGO IN 2001..... • Google was 5 years old • Dial-up still ruled the Internet • E-commerce companies had just crashed and burned (e.g., pets.com) • Facebook and Twitter hadn't been founded yet • Nokia dominated mobile phones • The mobile internet didn't exist
  • 6.
  • 7.
  • 8. AGENDA • Which Internet things are we talking about? • Ingredients • Software • Tricky bits
  • 9. Internet of Things Definition: Semi-programmable devices
 that try to talk on the Internet
  • 10.
  • 11. !11
  • 12. 2013 GRAND 5-YEAR GREEN PLAN 1.Install solar panels 2.Buy electric cars 3.Install solar batteries 4.Live more greenly
  • 13. !13
  • 17. SOLAR POWER SYSTEM (SIMPLIFIED) Solar Panels Direct Current (DC) Alternating Current (AC) Inverters Solar Power Meter Utility Power Meter
  • 18. TWO FUNDAMENTAL QUESTIONS • How much power do we generate? • How much power do we use?
  • 19. SOLAR POWER SYSTEM (SIMPLIFIED) Solar Panels Direct Current (DC) Alternating Current (AC) Inverters Solar Power Meter Utility Power Meter Solar Monitoring System Internet
  • 21.
  • 22.
  • 23. Internet of Things Rule #1 Most IoT devices either use or respond to TCP/IP Port 80 In other words, they speak Web
  • 24. THIS IS WHAT YOU SEE ON PORT 80!
  • 26. Internet of Things Rule #2 If something speaks Web, 
 we can almost always use R and Linux to work with it
  • 28.
  • 29. RASPBERRY PI B+ DETAILS System on a chip: Broadcom BCM2835 CPU: ARM Cortex-A53, 700 MHz RAM: 512MB RAM Networking: 10/100 Ethernet, no wireless Storage: microSD GPIO: 40-pin header, populated Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface (CSI), Display Serial Interface (DSI) Costs about $25 plus power supply and case (total about $45)
  • 30. RASPBERRY PI SOFTWARE Raspbian OS, which is a derivative of Debian Linux Comes with Python pre-installed Does NOT come with R pre-installed WAT????
  • 31.
  • 32. USEFUL TOOLS WE'LL WANT • curl (fetch web pages) • R • RCurl (fetch web pages) • XML (parse web pages) • rvest (harvest web pages in a dplyr kind of way) • Apache Web server
  • 33. GOTCHAS • A Raspberry Pi is not an Intel machine • You may have to compile most or all of your libraries • Some libraries and functions may not be available at all.
  • 34. INSTALL TOOLS AND LIBRARIES YOU NEED • apt-get is a Linux tool to install software from Internet repositories • We'll use it to fetch tools and libraries we'll need on Raspbian sudo apt-get -y build-dep libcurl4-gnutls-dev sudo apt-get -y install libcurl4-gnutls-dev sudo apt-get install libcurl4-openssl-dev libssl-dev sudo apt-get install libxml2-dev sudo apt-get install emacs apache2
  • 35. NOW INSTALL THE LATEST VERSION OF R $ time sudo apt-get install -y gfortran libreadline6-dev libx11-dev libxt- dev libpng-dev libjpeg-dev libcairo2-dev xvfb libbz2-dev libzstd-dev liblzma-dev libcurl4-openssl-dev texinfo texlive texlive-fonts-extra screen wget $ cd /usr/local/src $ sudo wget https://cran.rstudio.com/src/base/R-3/R-3.5.2.tar.gz
  • 36. NOW INSTALL THE LATEST VERSION OF R $ sudo su - # cd /usr/local/src # tar zxvf R-3.5.2.tar.gz # cd R-3.5.2 /* Modify line 27483 in the ./configure file by changing :: to ;; */ /* This was a distribution but in 3.5.1 -- not sure if it's there in 3.5.2 */ /* But it can't hurt to check # time ./configure # time make # time make install # which R
  • 37. AND INSTALL ALL THE R PACKAGES # install.packages("tidyverse") fails!!! You'll have to install dplyr, ggplot2, etc. separately # Expect it to take an hour or two to download and install everything you need. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > install.packages(c("dplyr", "ggplot2", "httr", "reprex", "rvest", "RCurl", "XML2"), depends = TRUE)
  • 39. ARCHITECTURE: VERSION 1 /var/www directory Data Plotter SolarToday.png Apache Web Server Index.html2019-01-21.csv Inverter Data Collector
  • 40. Read inverter monitor Try to parse HTML Find the data hidden in Javascript
  • 41. The plotter is just straight ggplot2
  • 43. HOWEVER..... • Every few days one of the R programs just stops with funky errors WAT????
  • 44. Internet of Things Rule #3 Just because your IoT device speaks Web doesn't mean it's smart or error-free
  • 45. GOTCHA #1: DEVICES DO THEIR OWN THING • Solar inverters turn off when the sun isn't shining • When they are in the process of turning on or off, they don't always return results • Both the solar monitoring and plotting program needed tweaks to deal with very unexpected results • Error returns • Badly formatted HTML
  • 46. IOT ECONOMICS Your device was programmed by the lowest bidder using the cheapest components Do not expect that it has been rigorously vetted or even rigorously tested Treat data skeptically before trusting it
  • 47. Inverter 1 Inverter 2 2019-01-21 10:37:52 8 195 2019-01-21 10:39:49 9 198 2019-01-21 10:41:48 4105 203 2019-01-21 10:43:48 4106 214 2019-01-21 10:45:49 10 205 2019-01-21 10:47:48 10 219 2019-01-21 10:49:48 4104 204 WAT????
  • 48. INVERTER 1 OCCASIONALLY FLIPS THE 4096 BIT Inverter 1 Inverter 2 Total output 2019-01-21 10:37:52 8 195 203 2019-01-21 10:39:49 9 198 207 2019-01-21 10:41:48 4105 203 219 2019-01-21 10:43:48 4106 214 213 2019-01-21 10:45:49 10 205 213 2019-01-21 10:47:48 10 219 229 2019-01-21 10:49:48 4104 204 213 After cleaning
  • 49. Internet of Things Rule #4 Your IoT device's environment matters
  • 51.
  • 52. FORTUNATELY, I HAVE A WEATHER STATION But even a weather station doesn't tell you if the sun is out
  • 53. ARCHITECTURE: VERSION 2 Data Plotter SolarToday.png Apache Web Server 2019-01-21.csv Inverter Data Collector SkyImage.png Camera Grabber Weather Station Monitor WeatherToday.png Index.html weather.gov weatherunderground.com
  • 54. THIS IS THE VERSION RUNNING TODAY Raspberry Pi B+ Weather Station Ethernet Gateway
  • 55. Click for larger image Click for minute-by-minute .csv data Click Here
  • 56.
  • 57. BUT THE R PROGRAMS STILL CRASH 
 EVERY NOW AND AGAIN WAT WAT WAT??????
  • 58. SLEEPING LOOPS AREN'T THE BEST TOOLS.... • Difficult to have them fire at the right times (lubridate math isn't trivial) • Difficult to sync them to wall clock time • Code in the loops may leak memory over time
  • 59. Internet of Things Rule #5 Run IoT things on a clock
  • 60. LINUX HAS A SCHEDULER CALLED CRON • Can run any program you like (including R code) based on wall clock time • Very flexible (although the way you program it is a bit obscure) • Allows you to quick and easy one-shot programs instead of long-running server code
  • 61. CRONTAB EXAMPLE ON THE WEATHER PI 10 0 * * * $HOME/Solar-monitor-pi-sleepfix.R */5 * * * * $HOME/Plot-today-crontab.R Run this every day at 10 minutes, 0 hours (i.e., 10 min past midnight)
  • 62. CRONTAB EXAMPLE ON THE WEATHER PI 10 0 * * * $HOME/Solar-monitor-pi-sleepfix.R */5 * * * * $HOME/Plot-today-crontab.R Run Plot-today-crontab.R every 5 minutes • https://crontab-generator.org will generate these expressions for you • You add them to your own cron table using "crontab -e" for editing
  • 63. ARCHITECTURE: VERSION 3 Data Plotter SolarToday.png Apache Web Server 2019-01-21.csv Inverter Data Collector SkyImage.png Camera Grabber Weather Station Monitor WeatherToday.png Index.html weatherunderground.com weather.gov Cron
  • 64. TWO FUNDAMENTAL QUESTIONS • We now know how much power we generate • How much power do we use?
  • 65. HOME POWER EQUATION Power Used Power Generated Power Bought From Utility – =
  • 66. HOME POWER EQUATION Power Used Power Generated Power Bought From Utility – =
  • 67. ANNOYANCES • I only get how much power I've used from the utility once a month, long after I've used it • Energy storage (batteries) will make this much more complicated on an hour to hour basis
  • 68. HOME POWER EQUATION Power Used Power Generated Power Bought From Utility – = ±
  • 69. Internet of Things Rule #6 Most smart things are going wireless
  • 70. REMEMBER THIS DEVICE? • The power company doesn't want to pay someone to physically read my power sold and bought • Instead, they simply broadcast the information wirelessly on 900 MHz (the Industrial and Scientific Radio band, AKA the garbage band) Two- Way Smart Meter
  • 71. Internet of Things Rule #7 Wireless things are pretty easy to spy on
  • 72. ENTER THE SOFTWARE DEFINED RADIO (SDR) • Listens to pretty much anything between 100 KHz and 2 GHz • USB interface • Programmable to decode most any radio signal • Cheap to buy ($20-$30)
  • 73. RASPBERRY PI V3 DETAILS FOR POWER MONITORING System on a chip: Broadcom BCM2837 CPU: Quad-core ARM Cortex-A53, 1.2GHz GPU: Broadcom VideoCore IV RAM: 1GB LPDDR2 (900 MHz) Networking: 10/100 Ethernet, 2.4GHz 802.11n wireless built in Bluetooth: Bluetooth 4.1 Classic, Bluetooth Low Energy Storage: microSD GPIO: 40-pin header, populated Ports: HDMI, 3.5mm analogue audio-video jack, 4× USB 2.0, Ethernet, Camera Serial Interface (CSI), Display Serial Interface (DSI) Costs about $35 plus case and power supply (total about $55)
  • 74. SOLAR POWER MONITOR VERSION 3 Data Plotter SolarToday.png Apache Web Server 2019-01-21.csv Inverter Data Collector SkyImage.png Camera Grabber Weather Station Monitor WeatherToday.png Index.html weatherunderground.com weather.gov Cron
  • 75. ARCHITECTURE: METER READER Data Plotter SolarToday.png Apache Web Server 2019-01-21.csv Inverter Data Collector Cron power.txt Power Meter Reader rtlamr Index.html
  • 76. MORE SOFTWARE TO LOAD • Libraries for reading the SDR • sudo apt-get install rtl-sdr gr-osmosdr • Libraries for running the Go language • sudo apt-get install golang • Software for reading smart meters • git clone https://github.com/bemasher/rtlamr
  • 77. !77
  • 78. RAW POWER METER READINGS {Time:2019-01-22T14:02:35.477 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:02:35.645 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35975 CRC:0x6070}} {Time:2019-01-22T14:13:47.105 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:13:47.174 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35976 CRC:0x6642}} {Time:2019-01-22T14:22:03.393 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:22:03.509 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35976 CRC:0x6642}} {Time:2019-01-22T14:32:15.257 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:32:15.375 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35977 CRC:0x84A0}} {Time:2019-01-22T14:42:26.594 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:42:26.711 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35978 CRC:0xCCE5}} {Time:2019-01-22T14:52:32.936 SCM:{ID:25228408 Type: 8 Tamper:{Phy:00 Enc:01} Consumption: 57131 CRC:0x519A}} {Time:2019-01-22T14:52:33.054 SCM:{ID:25228409 Type: 8 Tamper:{Phy:00 Enc:00} Consumption: 35978 CRC:0xCCE5}} Meter IDs kWh bought kWh sold
  • 79. COMBINED POWER DATA Power Sales (1 kWh each)
  • 80. CONSOLIDATED HOUSEHOLD USE (WITH BUGS) Bug in windowing calculation
  • 82. CONCLUSION: WE'VE ANSWERED OUR QUESTIONS • How much power do we generate? • How much power do we use?
  • 83. INTERNET OF THINGS RULES 1.Most IoT devices either use or respond to TCP/IP Port 80 2.If something speaks Web, we can almost always use R and Linux to work with it 3.Just because your IoT device speaks Web doesn't mean it's smart or error-free 4.Your IoT device's environment matters 5.Run IoT things on a clock 6.Most smart things are going wireless 7.Wireless things are pretty easy to spy on
  • 84. Carl Howe Director of Education, RStudio carl@rstudio.com http://carlhowe.com @cdhowe