Cristian Pavan | Stefano Morandi
Linux Day 2019-10-26
PNLUG, Linuxday 2019
I'm Cristian and I'm Developer (@tux_eithel).
I'm Stefano and I'm DevOps (@umorando).
We work at AKQA.
And we ❤️ Linux!
and play with Raspberry Pi 🔌 💡 🔨 💻 ...
Today we will play a little bit
with the Raspberry Pi
to create SmartThings!
A SmartThing is a computing device that do some actions after events has been detected.
It can communicate with other devices.
We associate them to the concept of Internet of Things.
Example of SmartThings devices are:
Generally these devices are very closed, and we don't have the full control.
They are also expensive.
So today we are going to build our SmartThing devices!
It is a single computer board developed by the Raspberry Pi Foundation to promote teaching of basic computer science in schools and in developing countries.
There are different boards versions.
The latest released one is really dope!
Low cost: Makes it easy to get one to play.
It's like your pc, but smaller:
you can connect your monitor, keyboard and mouse.
It has WiFi and Bluetooth.
It runs a full OS
A lot of projects have been made using Raspberry Pi: there are a lot of docs and videos.
Easy to find the right sensor.
⚡️⚡️⚡️⚡️⚡️⚡️
I'm "studying" at PC and mum enters in the room.
I need to switch my PC window.
Let's use a SmartThings to do something stupid 😁 !
A Raspberry Pi
We are building our SmartThing using it.
A Sensor
To detect the mum inside our room.
Some software
To let sensor communicate with other "things".
We are going to use a Motion Sensor.
These kind of sensor emits a signal when some amounts of movement has been detected.
We are going to use the sensor HC-SR501.
We use Gobot https://gobot.io/.
It is a robotics/IoT framework written in Go.
It supports 35 platforms, abstracting sensors and platforms.
Due the nature of Go:
GOARM=6 GOARCH=arm GOOS=linux go build -o *.go
A simple program in Go which uses the sensor to detect motions.
It acts as server on the Raspberry Pi.
It allows clients to be registered.
Each time a motion is detect, it notifies the clients.
All communications are made using http, so it's very easy to implement and consume.
No authentication, don't run in production!!
We try to use some fruits / vegetables to play some music!
Raspberry Pi connected with some audio device.
A chip to "detect" analogous variations.
A basic script to listen these variations and play sounds.
Some fruits / vegetables.
We are going to use the MCP3008 chip which converts analogue signals in digital and use SPI ports on Raspberry Pi.
It's based on the principle that all the things are conductive, that means in this case that when toughing the fruits / vegetables we alter their resistance
It is inspired by Makey Makey.
We've made a simple script which polls MCP3008 channels.
In case any value changes, it means that someone has touched the fruit / vegetable.
We link each input channel to a different sound.
Anytime there's some movement detected, we take a picture!
We then use AI to detect faces and replace them with kitty images, making those prettier 😻.
Raspberry Pi with camera module.
A server where AI is used to detect faces whenever an images is uploaded.
We use a python library - Face Recognition - to detect and manipulate faces.
It provides a model with an accuracy of 99.38%.
Once a face has been recognized, we call an external service https://placekitten.com to generate the 🐱 image to swap with the face.
We wrote a simple program in Go which uses the sensor to detect motions.
When a motion has been detect, we use raspistill utility to take a picture.
We upload the image into the AI "server":
It generates the cat-images.
Connecting it to the internet: becomes a real IoT device.
You can control your devices from all around the world.
Opening your device to internet can be scary 😟.
It requires resources to maintain the system updated.
Use cloud computing to get more CPU power.
Useful when your device it's really small.
You're going to use a closed solution.
Use artificial intelligence to do more awesome stuff!!
You can make your device more fun!
... or precise.
It's hard to use open source solutions.
Now it's your turn to do stupid SmartThings!
Cristian (@tux_eithel)
Stefano (@umorando)
Linux Day 26-10-2019