Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DIY: Home monitoring with Ruby & Pi

Helio Cola
February 04, 2017

DIY: Home monitoring with Ruby & Pi

Ruby and RaspberryPi are available to us for quite sometime and this talk is meant to discuss how to use Ruby to explore things on a RaspberryPi. From a practical point of view, we will go through installation, setup, and build a simple Motion Sensor application on a RaspberryPi.

In a world we teach ourselves a lot of things, why not do it Ruby & Pi way? Let’s get our hands on a piece of hardware, understand what it takes to setup one up, install a couple of libraries, Ruby, RVM, RBENV, a GUI. Let’s get a couple of sensors: motion, temperature, humidity, tsunami, ectoplasm and see if we detect a cool thing or two.

Helio Cola

February 04, 2017

More Decks by Helio Cola

Other Decks in Programming


  1. FOSDEM <3 Ruby 2017 hac-rods.me Hi, I am Helio Cola!

    • ~16 years developing SW • 6/7 years since I found happiness • ~5 years full time happiness • I go by @hacrods on the internet…
  2. FOSDEM <3 Ruby 2017 Agenda • Why RaspberryPi, Parallella, Micro

    PCs • What is available • Buy, Install, Setup • Development Environment • Motion (and others) Sensor App
  3. FOSDEM <3 Ruby 2017 Why RaspberryPi & Parallella • Because

    of Ray Hightower (http://rayhightower.com/) • Because I was curious • Because I was bored • And I’ve been doing some renovations at my house
  4. FOSDEM <3 Ruby 2017 What is available • RaspberryPi: https://www.raspberrypi.org/

    Raspberry Pi Zero Raspberry Pi 1 Model A+ Raspberry Pi 2 Model B Raspberry Pi 3 Model B
  5. FOSDEM <3 Ruby 2017 Differences between the Pi’ CPU RAM

    Display USB Others Pi Zero 1Ghz, Single-core CPU 512MB RAM CSI (v1.2 only) and Mini HDMI USB On-The-Go ports Half the size of a Model A+, with twice the utility Pi 1 A+ 700Mhz ARM CPU 512MB RAM HDMI One USB 2.0 Port No Ethernet Low power 0.5W and 1W Pi 2 B A 900MHz quad- core ARM Cortex- A7 CPU 1GB RAM CSI, DSI, Full HDMI 4 USB 2.0 ports Ethernet Pi 3 B 1.2GHz 64-bit quad-core ARMv8 CPU 1GB RAM CSI, DSI, Full HDMI 4 USB ports Ethernet, 802.11n, Bluetooth & BLE
  6. FOSDEM <3 Ruby 2017 Differences between the Pi’ Price Dimensions

    GPIO Pi Zero $5 65mm long x 30mm wide x 5mm thick HAT-compatible 40-pin header Pi 1 A+ $24.95 65mm x 56mm 40 GPIO pins Pi 2 B $39.95 40 GPIO pins Pi 3 B $39.95 86.9mm x 58.5mm x 19.1mm 40 GPIO pins
  7. FOSDEM <3 Ruby 2017 What is available • Parallella: https://www.parallella.org/

    Parallella Microserver (P1600) Parallella Desktop (P1601) Parallella Embedded (P1602)
  8. FOSDEM <3 Ruby 2017 The differences CPU Price RAM HDMI

    USB GPIO Microserver 18 cores Zynq Z7010 667 MHz (max 1 GHz) $99 1GB RAM No 1 port No Desktop 18 cores Zynq Z7010 667 MHz (max 1 GHz) $149 1GB RAM Yes 1 port 24 ports Embedded 18 cores Zynq Z7020 667 MHz (max 1 GHz) $264.94 1GB RAM Yes 1 port 48 ports
  9. FOSDEM <3 Ruby 2017 Microcontrolers & Motherboards ASUS Mini ITX

    Motherboards (processor bought separately) Intel GALILEO: Intel® Quark SoC X1000 Application Processor
  10. FOSDEM <3 Ruby 2017 Stick PCs ASUS VivoStick TS10-B017D Intel

    Atom Z8350 Intel Compute Stick CS125: Windows 10
  11. FOSDEM <3 Ruby 2017 Where to buy • If you

    are near Element14: buy it • If you are near Adafruit: buy it • If you are near Amazon: buy it • Otherwise: find micro center near you
  12. FOSDEM <3 Ruby 2017 What to buy • Depend of

    what you are trying to do • The basics: Starter kit (Pi 3, case, power supply, heatsink) and Micro SDHC • Extras: Camera, sensors, 7” Touch screen display Other gadgets
  13. FOSDEM <3 Ruby 2017 Pi 3: Install, Setup • If

    your machine is Windows/Linux/Mac: https://developer.ubuntu.com/core/get-started/ installation-medias • If your machine is Linux: https://ubuntu-mate.org/raspberry-pi/
  14. FOSDEM <3 Ruby 2017 Pi3: Install, Setup • My one

    tip to all of you: don’t use ‘bs=32m’ use ‘bs=1m’ instead
  15. FOSDEM <3 Ruby 2017 Pi 3: OS Download • Ubuntu

    Core, Ubuntu Mate, Windows 10 IoT Core Core: https://developer.ubuntu.com/core/get-started/ raspberry-pi-2-3 Mate: https://ubuntu-mate.org/download/ Windows (still on my TODO list): http://ms- iot.github.io/content/en-US/Downloads.htm
  16. FOSDEM <3 Ruby 2017 Pi 3: Installation on Mac •

    More or less these were my steps: 1. Download the image, un-archive, insert SD card 2. Run:
  17. FOSDEM <3 Ruby 2017 Pi 3: Setup • First boot:

    it will take longer • It may automatically extend the file system (Core) • Or you will have to do it manually (Mate) • Follow the instructions on the display • Configure your network • And an administrator account
  18. FOSDEM <3 Ruby 2017 Pi 3: From your machine $

    ssh <Ubuntu user name>@<Pi IP address>
  19. FOSDEM <3 Ruby 2017 (My) Development Environment • UbuntuMate OS:

    a GUI on top an Ubuntu distribution • RVM, RBENV • Postgres & PgAdmin • Text Editor: Atom or VIM • Chrome & Firefox: more than enough • A monitor or TV, keyboard and mouse
  20. FOSDEM <3 Ruby 2017 Motion Sensor App • My Hello

    World for RaspberryPi • Detect “movement” • Do something: • Call an API • Sound an alarm • Turn on the lights and play a music • Turn on the Camera & record it until no more presence • Reporte event + video
  21. FOSDEM <3 Ruby 2017 Motion Sensor App • Ruby as

    usual: rvm, ruby, rack, rails, rails-api, postgres, etc. Data model
  22. FOSDEM <3 Ruby 2017 Motion Sensor App • CRUD admin

    app & api to allow events to come in
  23. FOSDEM <3 Ruby 2017 (My) Home monitoring system experiment •

    We will go away for 2 months • Our contractor will come by regularly • And walk through the sensor • From November 1st to December 21st 2016 • Let’s look at the logs
  24. FOSDEM <3 Ruby 2017 (My) Home monitoring system experiment My

    theories: There is a ghost in my house There is IR noise near my sensor The sensor is broken Or can also be a bug in my code
  25. FOSDEM <3 Ruby 2017 References http://rayhightower.com/ https://www.raspberrypi.org/ https://www.parallella.org/ https://developer.ubuntu.com/core/get-started/installation-medias https://ubuntu-mate.org/raspberry-pi/

    https://developer.ubuntu.com/core/get-started/raspberry-pi-2-3 https://ubuntu-mate.org/download/ http://ms-iot.github.io/content/en-US/Downloads.htm https://www.element14.com/community/docs/DOC-78156/l/raspberry-pi-7- touchscreen-display https://cdn-learn.adafruit.com/downloads/pdf/pir-passive-infrared-proximity- motion-sensor.pdf https://github.com/jwhitehorn/pi_piper http://bit.ly/k8s-rpi