Slide 1

Slide 1 text

FOSDEM <3 Ruby 2017 DIY: Home monitoring with Ruby & Pi Helio Cola @hacrods

Slide 2

Slide 2 text

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…

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

FOSDEM <3 Ruby 2017 Why RaspberryPi, Parallella, Micro PCs

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

FOSDEM <3 Ruby 2017 What is available

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

FOSDEM <3 Ruby 2017 Pi Zero Pi 1 A+ Pi 2 B Pi 3 B

Slide 9

Slide 9 text

FOSDEM <3 Ruby 2017 Pi Zero vs Quarter

Slide 10

Slide 10 text

FOSDEM <3 Ruby 2017 Pi 3 Case vs Quarter

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

FOSDEM <3 Ruby 2017 What is available • Parallella: https://www.parallella.org/ Parallella Microserver (P1600) Parallella Desktop (P1601) Parallella Embedded (P1602)

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

FOSDEM <3 Ruby 2017 Microcontrolers & Motherboards ASUS Mini ITX Motherboards (processor bought separately) Intel GALILEO: Intel® Quark SoC X1000 Application Processor

Slide 16

Slide 16 text

FOSDEM <3 Ruby 2017 Stick PCs ASUS VivoStick TS10-B017D Intel Atom Z8350 Intel Compute Stick CS125: Windows 10

Slide 17

Slide 17 text

FOSDEM <3 Ruby 2017 Buy, Install, Setup

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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/

Slide 21

Slide 21 text

FOSDEM <3 Ruby 2017 Pi3: Install, Setup • My one tip to all of you: don’t use ‘bs=32m’ use ‘bs=1m’ instead

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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:

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

FOSDEM <3 Ruby 2017 Pi 3: On a TV

Slide 26

Slide 26 text

FOSDEM <3 Ruby 2017 Pi 3: On a touch screen

Slide 27

Slide 27 text

FOSDEM <3 Ruby 2017 Pi 3: From your machine $ ssh @

Slide 28

Slide 28 text

FOSDEM <3 Ruby 2017 Development Environment

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

FOSDEM <3 Ruby 2017 7” Touch Screen display https://www.element14.com/community/docs/DOC-78156/l/raspberry-pi-7- touchscreen-display

Slide 31

Slide 31 text

FOSDEM <3 Ruby 2017 7” Touch Screen display

Slide 32

Slide 32 text

FOSDEM <3 Ruby 2017 7” Touch Screen display

Slide 33

Slide 33 text

FOSDEM <3 Ruby 2017 7” Touch Screen display

Slide 34

Slide 34 text

FOSDEM <3 Ruby 2017 Motion Sensor App

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

FOSDEM <3 Ruby 2017 Motion Sensor App • CRUD admin app & api to allow events to come in

Slide 38

Slide 38 text

FOSDEM <3 Ruby 2017 PIR Motion Sensor

Slide 39

Slide 39 text

FOSDEM <3 Ruby 2017 PIR Motion Sensor • Reference: https://cdn-learn.adafruit.com/downloads/pdf/pir-passive-infrared- proximity-motion-sensor.pdf Passive infrared Pyroelectric IR motion

Slide 40

Slide 40 text

FOSDEM <3 Ruby 2017 Monitoring a PIR sensor Reference: https://github.com/jwhitehorn/pi_piper

Slide 41

Slide 41 text

FOSDEM <3 Ruby 2017 Sensor’ journey

Slide 42

Slide 42 text

FOSDEM <3 Ruby 2017 PIR Motion Sensor

Slide 43

Slide 43 text

FOSDEM <3 Ruby 2017 Smoke and Combustible Gas

Slide 44

Slide 44 text

FOSDEM <3 Ruby 2017 Buzzer

Slide 45

Slide 45 text

FOSDEM <3 Ruby 2017 Carbon Monoxide

Slide 46

Slide 46 text

FOSDEM <3 Ruby 2017 Digital touch

Slide 47

Slide 47 text

FOSDEM <3 Ruby 2017 Flame

Slide 48

Slide 48 text

FOSDEM <3 Ruby 2017 Vibration

Slide 49

Slide 49 text

FOSDEM <3 Ruby 2017 Temperature and Humidity

Slide 50

Slide 50 text

FOSDEM <3 Ruby 2017 Sound

Slide 51

Slide 51 text

FOSDEM <3 Ruby 2017 Water level

Slide 52

Slide 52 text

FOSDEM <3 Ruby 2017 (My) Home monitoring system

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

FOSDEM <3 Ruby 2017 Thank you! http://bit.ly/k8s-rpi Helio Cola @hacrods