SlideShare a Scribd company logo
1 of 27
Automating a fishtank with
python and IoT sensors
Version 2.0
Ben Chodroff, CTO – CloudOne
Why?
• I left the water running after a water change and the tank overflowed
• Solutions:
• Set a timer while filling my tank, or…
• Over engineer a solution
Over Engineering It
• Collect all data points:
• Water pH
• Water Temperature
• Water level
• Filter flow
• Light state (on/off)
• Topoff state (on/off)
• Removal state (on/off)
• Photosynthesis rate (IR sensor)
• Dosing, water changes, filter changes and other scheduled maintenance events
• Automate maintenance
• CO2 solenoid control of pH
• Chemical dosing (N, P, K, Fe, Micro)
• Water topoff and changes
• Automate alerts
• CO2 replacement (5 weeks)
• Filter replacement (8 weeks)
• Water level low/high/critical
• Water flow low/high
• Temperature low/high
• pH low/high
Demo
Platform – Raspberry Pi2
• Cheap and well supported ($30)
• Provides full Linux environment: https://www.raspberrypi.org/help/noobs-
setup/
• Easy to interface to most digital hardware sensors via GPIO pins
• Provides python environment (easier than TI LaunchPad/Arduino for
generic tasks)
• Camera integration via RaspiCam ($25):
http://www.amazon.com/Raspberry-5MP-Camera-Board-
Module/dp/B00E1GGE40
• Easy to IoT enable ($10): http://www.amazon.com/Kootek-Raspberry-Wifi-
Dongle-
Adapter/dp/B00FWMEFES/ref=sr_1_2?s=pc&ie=UTF8&qid=1439503682&s
r=1-2&keywords=raspberry+pi+wifi
Platform – Raspberry Pi2 Pinout Mapping
Sensors – 8 Channel relay control
• Control up to AC 250V 10A or DC 30V 10A devices
• CO2 solenoid (DC 12V)
• Dosing peristaltic pumps (DC 12V)
• Amazon for $10: http://www.amazon.com/JBtek-Channel-Relay-
Arduino-
Raspberry/dp/B00KTELP3I/ref=sr_1_2?ie=UTF8&qid=1439503217
• Easy to hook up – connect ground and voltage pins, then connect
GPIO pins to each relay controller.
• No circuit knowledge required
• Use Python GPIO library to set each pin to high or low
Sample Code – 8 Channel relay control
English:
Import the raspberry pi GPIO (so we can talk with devices)
Import the time module (so we can time the commands)
Go into GPIO.BCM mode (so we can map pin numbers)
pinList is an array of pins connected to the relays
For each pin in the list:
Set the pin to “output” digital mode (on or off)
Initialize the pin to ”HIGH” (which equals off)
For each pin in the list:
Set the pin to LOW (which equals on)
Sleep for one second
Set the pin to HIGH (which equals off)
Python:
Sensors – Water Level
• eTape Liquid Water Level Sensor (adafruit.com $60)
• Make sure you buy the one with the jacket so you get a built in voltage divider
• The non-jacket version requires a little circuit knowledge and is prone to damage
• Red wire -> 3.3v, black wire -> ground, white wire -> voltage correspends to level
• Measure the white wire by connecting to a MCP3008 ”CH0”
• Raspberry Pi has no ADC - use a MCP3008-I/P (adafruit.com $4)
• Great guide on using MCP3008 with a Raspberry Pi using “Bit banging”:
https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-
raspberry-pi/overview
• Hardest sensor
• Raspberry Pi has no analog pin so MCP3008 is required and it has a learning curve
• The sensor is difficult to calibrate and may require some software finessing to get reliable
accurate readings
• Achieved accuracy to +-0.5cm but took a lot of work
• Might be able to use ultrasonic distance sensor? Float switch?
Sample Code – Water Level
English:
Import time and our gpio libraries
Connect as BCM pins
Define a function “readadc” where we pass in the analog channel (0-7)
what channel to read, the clockpin, mosi pin, miso pin, and cspin:
If we are reading a channel below 0 or above 7, bomb out
Set our cspin to HIGH
Set our clock to low
Set our cspin to low
*** complicated stuff – manually advancing the clock to read a message:
read message by flicking clock on/off
Compare 12 bit response to get the channel we want
Call the readadc to retrieve CH0
Use the 10 bits to determine the level (requires calibration)
Sensors – Water Level
• Calculating the water level requires
initial calibration to find the slope of
a line between two known points
• Numpy can find m (slope) and c (y
intercept) if you don’t remember how
• Avoid false readings by checking a
known resistor and using median
• Fixed resistor on CH1 and throw out
results off by more than “3” (>99.99%)
• Use a median function to avoid false
readings by reading 100 times
Sensors – pH, Flow meter, and temperature
• Atlas Scientific
• Crème de la crème – worth every penny but not cheap
• Reliable, high quality, and best of all - prebuilt serial circuits [no circuit skill required]
• Use PWR-ISO module ($36) for power isolation: avoid ground loops and electrical noise
• Serial Expander ($11) – Control up to 4 separate serial devices even though your
Raspberry Pi only has one serial connection
• Digital Temperature ($25) > cheaper analog probes: easier to calibrate, easier
to integrate, high quality
• Flow Meter sensor ($38) “just works” with a cheap (adafruit $9) flow meter
• pH probe kit ($150) is high quality, easy to calibrate, easy to read
Sensors – Data sheets
• pH Circuit: http://atlas-scientific.com/_files/_datasheets/_circuit/pH_EZO_datasheet.pdf
• Flow Circuit: http://atlas-scientific.com/_files/_datasheets/_circuit/flow_EZO_Datasheet.pdf
• Temperature Circuit: http://atlas-scientific.com/_files/_datasheets/_probe/ENV-TEMP-D.pdf
• Power isolation: http://atlas-scientific.com/_files/_datasheets/_circuit/pwr-iso.pdf
• Serial expander: https://www.atlas-
scientific.com/_files/_datasheets/_circuit/serial_port_expander_datasheet.pdf
Sample Code – Atlas Scientific SensorsEnglish:
We need to create a serial connection
We need two pins to tell the serial expander which device to connect to:
Which requires two output pins to flip between 4 devices:
(00, 01, 10, and 11)
We open our serial connection at 9600kbps with /dev/ttyAMA0
Use a TextIOWrapper to io buffer until a newline character is returned
Forever:
Set the device to 00 (flow sensor)
Read in a few lines (to make sure we clear out garbage)
Read the line and split the volume and flow to variables
If we fail, just output “unknown”
Set the device to 01 (pH meter)
Read in a few lines, return line
etc…
Python:
Serial Expander Mapping
Video
• Raspivid is incredible – 1080p live video streaming to Youtube
• Requires ~3-5Mbps of traffic
• How to make it work
• Create a Live stream (free!): https://www.youtube.com/live_dashboard
• Create a bash script and enter your server and key
• Download optimized ffmpeg for ARM (required!):
https://www.reddit.com/r/raspberry_pi/comments/2ahzp2/raspberry_pi_encoder_live_streaming_to_youtube/
• Tweak the raspivid options to fix the ISO, gain, fps, color/white balance correction.
• No sound (I tried at one point to tee in some repeating mp3 audio using mpg123 but it caused issues)
Bash Example:
IoT Dashboard
• https://freeboard.io/board/l1XbFY
• Freeboard.io (BugLabs)
• Great dashboards out of the box
• Free hosting and open source
• Possible to integrate with MQTT
• MQTT using IBM IoT Foundation
• Free
• Extremely fast IOT message transport
• Paho MQTT client (javascript):
• https://rawgit.com/benjaminchodroff/freeboard-mqtt/paho-mqtt-
default/ibm.iotfoundation.plugin.js
• https://rawgit.com/benjaminchodroff/freeboard-mqtt/paho-mqtt-
default/paho.mqtt.plugin.js
• Integrates to Freeboard plugin through “Developer Console”
IoT Messaging – IBM Watson IoT
• MQTT based
• Lightweight, high performance protocol perfectly suited
for M2M messaging in a variety of IoT scenarios
• Free to set up for limited number of devices
• Scales easily in the public cloud
• Contact CloudOne if you need private/custom
implementations using BlueMix Local with
MessageSight
• Easy code examples to integrate variety of
embedded devices in many languages
Sample Code – IBM Watson IoT
English:
Config = my secret passwords
Import the iot foundation
Import a json wrapper for the iot foundation
Let’s send a message with 12345 in it
Try:
Set our device connection configuration
Connect using that configuration
myData = “hello”: “world”, and “x”: 12345
Publish that message with myData
Except/finally: Some quick error publishing and disconnect if it fails
Python:
IoT Messaging – NodeRED
• Visual tool for wiring together hardware devices, APIs and online service
• Based on NodeJS
• Requires no javascript programming knowledge to use
• Can be ran in IBM BlueMix Public or Local, or on site
• Integrates easily to the IBM IoT Foundation, Twilio/SMS/Email/Twitter
• Easily construct lightweight functions to parse messages and do logical
evaluations – perfect for makers
• Why?
• Replaces 100’s of lines of python code and make it easy to visualize – great for tinkering
• Free BlueMix Public hosting allows me to monitor my aquarium remotely
• If the internet at home goes down, NodeRED knows device presence and can alert me
• Sending control messages back to the aquarium (I performed a water change while in China)
• Scales horizontally with clustering if your application requires it (I am not allowed to buy
more aquariums to test this)
NodeRED – Aquarium IOT
Project Box
Before After
Next Steps – Analytics
Analytics of photosynthesis (NDVI infragram.org) response to dosing
Next Steps – You
• All the source code/experimentation
• https://github.com/benjaminchodroff/aquariumiot
• Think this is fun?
• CloudOne is hiring developers, data scientists, and building the future of IoT
• Contact me! Benjamin.chodroff@oncloudone.com
Extras
CO2 Levels based on kH and pH
• 6.5 is the sweet
spot at my kH 3 due
to RO water
• My tap water
comes from Lake
Michigan and has a
kH of 11+ -- too
high for my plants
Dosing Guide
One day machine imaging will be good enough
But for now this is a manual inspection
with manual adjustment
Dosing Regimen – Cron Schedule
• http://www.seachem.com/downloads/charts/Plant-Dose-Chart.pdf
• http://www.aquaticplantcentral.com/forumapc/attachment.php?atta
chmentid=5525&d=1192589007

More Related Content

What's hot

TMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IITMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IINEEVEE Technologies
 
Remote temperature monitor (DHT11)
Remote temperature monitor (DHT11)Remote temperature monitor (DHT11)
Remote temperature monitor (DHT11)Parshwadeep Lahane
 
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackTaking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackDrew Fustini
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino WebinarFragiskos Fourlas
 
Raspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionRaspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionVatsal N Shah
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsSudar Muthu
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioKevin Hooke
 
Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started동호 손
 
Iot bootcamp abridged - part 2
Iot bootcamp   abridged - part 2Iot bootcamp   abridged - part 2
Iot bootcamp abridged - part 2Marcus Tarquinio
 
Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1Marcus Tarquinio
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and CircuitsJason Griffey
 
Smart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PISmart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PIKrishna Kumar
 
PCB Business Card
PCB Business CardPCB Business Card
PCB Business Cardyeokm1
 
Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry PiShahed Mehbub
 
Exploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with PythonExploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with PythonShahed Mehbub
 

What's hot (20)

TMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session IITMS20DM8148 Embedded Linux Session II
TMS20DM8148 Embedded Linux Session II
 
Remote temperature monitor (DHT11)
Remote temperature monitor (DHT11)Remote temperature monitor (DHT11)
Remote temperature monitor (DHT11)
 
It's game time
It's game timeIt's game time
It's game time
 
MarsBoard - NXP IMX6 Processor
MarsBoard - NXP IMX6 ProcessorMarsBoard - NXP IMX6 Processor
MarsBoard - NXP IMX6 Processor
 
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackTaking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
 
TMS320DM8148 Embedded Linux
TMS320DM8148 Embedded LinuxTMS320DM8148 Embedded Linux
TMS320DM8148 Embedded Linux
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino Webinar
 
EVBMC-1471L - HDBaseT Multi Format Transmitter
EVBMC-1471L - HDBaseT Multi Format Transmitter EVBMC-1471L - HDBaseT Multi Format Transmitter
EVBMC-1471L - HDBaseT Multi Format Transmitter
 
Raspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionRaspbeery Pi : An Introduction
Raspbeery Pi : An Introduction
 
Using arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of thingsUsing arduino and raspberry pi for internet of things
Using arduino and raspberry pi for internet of things
 
Raspberry Pi and Amateur Radio
Raspberry Pi and Amateur RadioRaspberry Pi and Amateur Radio
Raspberry Pi and Amateur Radio
 
Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started
 
Iot bootcamp abridged - part 2
Iot bootcamp   abridged - part 2Iot bootcamp   abridged - part 2
Iot bootcamp abridged - part 2
 
Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1Iot Bootcamp - abridged - part 1
Iot Bootcamp - abridged - part 1
 
Introduction to Arduino and Circuits
Introduction to Arduino and CircuitsIntroduction to Arduino and Circuits
Introduction to Arduino and Circuits
 
Smart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PISmart Wireless Surveillance Monitoring using RASPBERRY PI
Smart Wireless Surveillance Monitoring using RASPBERRY PI
 
PCB Business Card
PCB Business CardPCB Business Card
PCB Business Card
 
Up and running with Raspberry Pi
Up and running with Raspberry PiUp and running with Raspberry Pi
Up and running with Raspberry Pi
 
Exploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with PythonExploring the ABC's of Raspberry Pi with Python
Exploring the ABC's of Raspberry Pi with Python
 
Remote tanklevelmonitor
Remote tanklevelmonitorRemote tanklevelmonitor
Remote tanklevelmonitor
 

Viewers also liked

IoT... this time it is different?
IoT... this time it is different?IoT... this time it is different?
IoT... this time it is different?Heinz Tonn
 
AD1542 Get Hands On With Bluemix
AD1542 Get Hands On With BluemixAD1542 Get Hands On With Bluemix
AD1542 Get Hands On With BluemixMartin Donnelly
 
Bolt IoT Platform: How to build IoT products and prototypes easily.
Bolt IoT Platform: How to build IoT products and prototypes easily.Bolt IoT Platform: How to build IoT products and prototypes easily.
Bolt IoT Platform: How to build IoT products and prototypes easily.Pranav Pai Vernekar
 
Building a PaaS Platform like Bluemix on OpenStack
Building a PaaS Platform like Bluemix on OpenStackBuilding a PaaS Platform like Bluemix on OpenStack
Building a PaaS Platform like Bluemix on OpenStackAnimesh Singh
 
I2CでRaspberry Piから 複数の周辺機器を制御する
I2CでRaspberry Piから複数の周辺機器を制御するI2CでRaspberry Piから複数の周辺機器を制御する
I2CでRaspberry Piから 複数の周辺機器を制御するHirokazu Nishio
 
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT PlatformCreating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT PlatformValeria Naldi
 
Building Applications with Eclipse IoT, Block by Block
Building Applications with Eclipse IoT, Block by BlockBuilding Applications with Eclipse IoT, Block by Block
Building Applications with Eclipse IoT, Block by BlockAnne Nevin
 
What Will You Build with IBM Watson on Bluemix?
What Will You Build with IBM Watson on Bluemix?What Will You Build with IBM Watson on Bluemix?
What Will You Build with IBM Watson on Bluemix?Swami Chandrasekaran
 
Open source IoT
Open source IoTOpen source IoT
Open source IoTIoT613
 
IoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
IoTWorld 2016 OSS Keynote Param Singh, Ian SkerrettIoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
IoTWorld 2016 OSS Keynote Param Singh, Ian SkerrettParam Singh
 
Examining the emergent open source IoT ecosystem - IoT World Europe 2016
Examining the emergent open source IoT ecosystem - IoT World Europe 2016Examining the emergent open source IoT ecosystem - IoT World Europe 2016
Examining the emergent open source IoT ecosystem - IoT World Europe 2016Benjamin Cabé
 
Eclipse Edje: A Java API for Microcontrollers
Eclipse Edje: A Java API for MicrocontrollersEclipse Edje: A Java API for Microcontrollers
Eclipse Edje: A Java API for MicrocontrollersMicroEJ
 
2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summitMike Milinkovich
 
Building the Internet of Things with Eclipse IoT - JavaLand 2014
Building the Internet of Things with Eclipse IoT - JavaLand 2014Building the Internet of Things with Eclipse IoT - JavaLand 2014
Building the Internet of Things with Eclipse IoT - JavaLand 2014Benjamin Cabé
 
Eclipse IoT Edje project: the software foundation for IoT devices
Eclipse IoT Edje project: the software foundation for IoT devicesEclipse IoT Edje project: the software foundation for IoT devices
Eclipse IoT Edje project: the software foundation for IoT devicesMicroEJ
 
IoT World Forum Press Conference - 10.14.2014
IoT World Forum Press Conference - 10.14.2014IoT World Forum Press Conference - 10.14.2014
IoT World Forum Press Conference - 10.14.2014Bessie Wang
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTBenjamin Cabé
 
Eclipse IoT: Open source technology for IoT developers
Eclipse IoT: Open source technology for IoT developersEclipse IoT: Open source technology for IoT developers
Eclipse IoT: Open source technology for IoT developersIan Skerrett
 
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTBenjamin Cabé
 
IoT Microservices at the Edge with Eclipse ioFog
IoT Microservices at the Edge with Eclipse ioFogIoT Microservices at the Edge with Eclipse ioFog
IoT Microservices at the Edge with Eclipse ioFogKilton Hopkins
 

Viewers also liked (20)

IoT... this time it is different?
IoT... this time it is different?IoT... this time it is different?
IoT... this time it is different?
 
AD1542 Get Hands On With Bluemix
AD1542 Get Hands On With BluemixAD1542 Get Hands On With Bluemix
AD1542 Get Hands On With Bluemix
 
Bolt IoT Platform: How to build IoT products and prototypes easily.
Bolt IoT Platform: How to build IoT products and prototypes easily.Bolt IoT Platform: How to build IoT products and prototypes easily.
Bolt IoT Platform: How to build IoT products and prototypes easily.
 
Building a PaaS Platform like Bluemix on OpenStack
Building a PaaS Platform like Bluemix on OpenStackBuilding a PaaS Platform like Bluemix on OpenStack
Building a PaaS Platform like Bluemix on OpenStack
 
I2CでRaspberry Piから 複数の周辺機器を制御する
I2CでRaspberry Piから複数の周辺機器を制御するI2CでRaspberry Piから複数の周辺機器を制御する
I2CでRaspberry Piから 複数の周辺機器を制御する
 
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT PlatformCreating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
 
Building Applications with Eclipse IoT, Block by Block
Building Applications with Eclipse IoT, Block by BlockBuilding Applications with Eclipse IoT, Block by Block
Building Applications with Eclipse IoT, Block by Block
 
What Will You Build with IBM Watson on Bluemix?
What Will You Build with IBM Watson on Bluemix?What Will You Build with IBM Watson on Bluemix?
What Will You Build with IBM Watson on Bluemix?
 
Open source IoT
Open source IoTOpen source IoT
Open source IoT
 
IoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
IoTWorld 2016 OSS Keynote Param Singh, Ian SkerrettIoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
IoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
 
Examining the emergent open source IoT ecosystem - IoT World Europe 2016
Examining the emergent open source IoT ecosystem - IoT World Europe 2016Examining the emergent open source IoT ecosystem - IoT World Europe 2016
Examining the emergent open source IoT ecosystem - IoT World Europe 2016
 
Eclipse Edje: A Java API for Microcontrollers
Eclipse Edje: A Java API for MicrocontrollersEclipse Edje: A Java API for Microcontrollers
Eclipse Edje: A Java API for Microcontrollers
 
2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit2016-09-eclipse-iot-cf-summit
2016-09-eclipse-iot-cf-summit
 
Building the Internet of Things with Eclipse IoT - JavaLand 2014
Building the Internet of Things with Eclipse IoT - JavaLand 2014Building the Internet of Things with Eclipse IoT - JavaLand 2014
Building the Internet of Things with Eclipse IoT - JavaLand 2014
 
Eclipse IoT Edje project: the software foundation for IoT devices
Eclipse IoT Edje project: the software foundation for IoT devicesEclipse IoT Edje project: the software foundation for IoT devices
Eclipse IoT Edje project: the software foundation for IoT devices
 
IoT World Forum Press Conference - 10.14.2014
IoT World Forum Press Conference - 10.14.2014IoT World Forum Press Conference - 10.14.2014
IoT World Forum Press Conference - 10.14.2014
 
End-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoTEnd-to-end IoT solutions with Java and Eclipse IoT
End-to-end IoT solutions with Java and Eclipse IoT
 
Eclipse IoT: Open source technology for IoT developers
Eclipse IoT: Open source technology for IoT developersEclipse IoT: Open source technology for IoT developers
Eclipse IoT: Open source technology for IoT developers
 
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
 
IoT Microservices at the Edge with Eclipse ioFog
IoT Microservices at the Edge with Eclipse ioFogIoT Microservices at the Edge with Eclipse ioFog
IoT Microservices at the Edge with Eclipse ioFog
 

Similar to IoT Aquarium 2

teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxethannguyen1618
 
Challenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of viewChallenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of viewbrouer
 
SIGFOX Makers Tour - Barcelona
SIGFOX Makers Tour - BarcelonaSIGFOX Makers Tour - Barcelona
SIGFOX Makers Tour - BarcelonaNicolas Lesconnec
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiNeil Broers
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityAhmed Magdy Farid
 
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioWhen DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioDevOps4Networks
 
ARDUINO AND RASPBERRYPI.pptx
ARDUINO AND RASPBERRYPI.pptxARDUINO AND RASPBERRYPI.pptx
ARDUINO AND RASPBERRYPI.pptxvennetikiran1
 
Multipilot pres-ufficiale def
Multipilot pres-ufficiale defMultipilot pres-ufficiale def
Multipilot pres-ufficiale defRoberto Navoni
 
microbit Microbit programming Microbit programming
microbit Microbit programming Microbit programmingmicrobit Microbit programming Microbit programming
microbit Microbit programming Microbit programmingssuser5feb2c1
 
2015 02 28 DotNetSpain IoT Fight
2015 02 28 DotNetSpain IoT Fight2015 02 28 DotNetSpain IoT Fight
2015 02 28 DotNetSpain IoT FightBruno Capuano
 
Scripting Things - Creating the Internet of Things with Perl
Scripting Things - Creating the Internet of Things with PerlScripting Things - Creating the Internet of Things with Perl
Scripting Things - Creating the Internet of Things with PerlHans Scharler
 
Docking stations andy_davis_ncc_group_slides
Docking stations andy_davis_ncc_group_slidesDocking stations andy_davis_ncc_group_slides
Docking stations andy_davis_ncc_group_slidesNCC Group
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfGVNSK Sravya
 
gas cylinder iot.pptx
gas cylinder iot.pptxgas cylinder iot.pptx
gas cylinder iot.pptxramalingams7
 
Green Code Lab Challenge 2015 Subject Details
Green Code Lab Challenge 2015 Subject DetailsGreen Code Lab Challenge 2015 Subject Details
Green Code Lab Challenge 2015 Subject DetailsOlivier Philippot
 
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionBluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionSagar Mali
 

Similar to IoT Aquarium 2 (20)

Arduino
ArduinoArduino
Arduino
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
 
Challenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of viewChallenges and experiences with IPTV from a network point of view
Challenges and experiences with IPTV from a network point of view
 
SIGFOX Makers Tour - Barcelona
SIGFOX Makers Tour - BarcelonaSIGFOX Makers Tour - Barcelona
SIGFOX Makers Tour - Barcelona
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry Pi
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA University
 
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.ioWhen DevOps and Networking Intersect by Brent Salisbury of socketplane.io
When DevOps and Networking Intersect by Brent Salisbury of socketplane.io
 
SIGFOX Makers Tour - Madrid
SIGFOX Makers Tour - MadridSIGFOX Makers Tour - Madrid
SIGFOX Makers Tour - Madrid
 
ARDUINO AND RASPBERRYPI.pptx
ARDUINO AND RASPBERRYPI.pptxARDUINO AND RASPBERRYPI.pptx
ARDUINO AND RASPBERRYPI.pptx
 
Multipilot pres-ufficiale def
Multipilot pres-ufficiale defMultipilot pres-ufficiale def
Multipilot pres-ufficiale def
 
microbit Microbit programming Microbit programming
microbit Microbit programming Microbit programmingmicrobit Microbit programming Microbit programming
microbit Microbit programming Microbit programming
 
2015 02 28 DotNetSpain IoT Fight
2015 02 28 DotNetSpain IoT Fight2015 02 28 DotNetSpain IoT Fight
2015 02 28 DotNetSpain IoT Fight
 
Scripting Things - Creating the Internet of Things with Perl
Scripting Things - Creating the Internet of Things with PerlScripting Things - Creating the Internet of Things with Perl
Scripting Things - Creating the Internet of Things with Perl
 
Docking stations andy_davis_ncc_group_slides
Docking stations andy_davis_ncc_group_slidesDocking stations andy_davis_ncc_group_slides
Docking stations andy_davis_ncc_group_slides
 
Network
NetworkNetwork
Network
 
IoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdfIoT Physical Devices and End Points.pdf
IoT Physical Devices and End Points.pdf
 
gas cylinder iot.pptx
gas cylinder iot.pptxgas cylinder iot.pptx
gas cylinder iot.pptx
 
Green Code Lab Challenge 2015 Subject Details
Green Code Lab Challenge 2015 Subject DetailsGreen Code Lab Challenge 2015 Subject Details
Green Code Lab Challenge 2015 Subject Details
 
MCB_HL_v10.pdf
MCB_HL_v10.pdfMCB_HL_v10.pdf
MCB_HL_v10.pdf
 
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionBluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
 

Recently uploaded

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

IoT Aquarium 2

  • 1. Automating a fishtank with python and IoT sensors Version 2.0 Ben Chodroff, CTO – CloudOne
  • 2. Why? • I left the water running after a water change and the tank overflowed • Solutions: • Set a timer while filling my tank, or… • Over engineer a solution
  • 3. Over Engineering It • Collect all data points: • Water pH • Water Temperature • Water level • Filter flow • Light state (on/off) • Topoff state (on/off) • Removal state (on/off) • Photosynthesis rate (IR sensor) • Dosing, water changes, filter changes and other scheduled maintenance events • Automate maintenance • CO2 solenoid control of pH • Chemical dosing (N, P, K, Fe, Micro) • Water topoff and changes • Automate alerts • CO2 replacement (5 weeks) • Filter replacement (8 weeks) • Water level low/high/critical • Water flow low/high • Temperature low/high • pH low/high
  • 5. Platform – Raspberry Pi2 • Cheap and well supported ($30) • Provides full Linux environment: https://www.raspberrypi.org/help/noobs- setup/ • Easy to interface to most digital hardware sensors via GPIO pins • Provides python environment (easier than TI LaunchPad/Arduino for generic tasks) • Camera integration via RaspiCam ($25): http://www.amazon.com/Raspberry-5MP-Camera-Board- Module/dp/B00E1GGE40 • Easy to IoT enable ($10): http://www.amazon.com/Kootek-Raspberry-Wifi- Dongle- Adapter/dp/B00FWMEFES/ref=sr_1_2?s=pc&ie=UTF8&qid=1439503682&s r=1-2&keywords=raspberry+pi+wifi
  • 6. Platform – Raspberry Pi2 Pinout Mapping
  • 7. Sensors – 8 Channel relay control • Control up to AC 250V 10A or DC 30V 10A devices • CO2 solenoid (DC 12V) • Dosing peristaltic pumps (DC 12V) • Amazon for $10: http://www.amazon.com/JBtek-Channel-Relay- Arduino- Raspberry/dp/B00KTELP3I/ref=sr_1_2?ie=UTF8&qid=1439503217 • Easy to hook up – connect ground and voltage pins, then connect GPIO pins to each relay controller. • No circuit knowledge required • Use Python GPIO library to set each pin to high or low
  • 8. Sample Code – 8 Channel relay control English: Import the raspberry pi GPIO (so we can talk with devices) Import the time module (so we can time the commands) Go into GPIO.BCM mode (so we can map pin numbers) pinList is an array of pins connected to the relays For each pin in the list: Set the pin to “output” digital mode (on or off) Initialize the pin to ”HIGH” (which equals off) For each pin in the list: Set the pin to LOW (which equals on) Sleep for one second Set the pin to HIGH (which equals off) Python:
  • 9. Sensors – Water Level • eTape Liquid Water Level Sensor (adafruit.com $60) • Make sure you buy the one with the jacket so you get a built in voltage divider • The non-jacket version requires a little circuit knowledge and is prone to damage • Red wire -> 3.3v, black wire -> ground, white wire -> voltage correspends to level • Measure the white wire by connecting to a MCP3008 ”CH0” • Raspberry Pi has no ADC - use a MCP3008-I/P (adafruit.com $4) • Great guide on using MCP3008 with a Raspberry Pi using “Bit banging”: https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the- raspberry-pi/overview • Hardest sensor • Raspberry Pi has no analog pin so MCP3008 is required and it has a learning curve • The sensor is difficult to calibrate and may require some software finessing to get reliable accurate readings • Achieved accuracy to +-0.5cm but took a lot of work • Might be able to use ultrasonic distance sensor? Float switch?
  • 10. Sample Code – Water Level English: Import time and our gpio libraries Connect as BCM pins Define a function “readadc” where we pass in the analog channel (0-7) what channel to read, the clockpin, mosi pin, miso pin, and cspin: If we are reading a channel below 0 or above 7, bomb out Set our cspin to HIGH Set our clock to low Set our cspin to low *** complicated stuff – manually advancing the clock to read a message: read message by flicking clock on/off Compare 12 bit response to get the channel we want Call the readadc to retrieve CH0 Use the 10 bits to determine the level (requires calibration)
  • 11. Sensors – Water Level • Calculating the water level requires initial calibration to find the slope of a line between two known points • Numpy can find m (slope) and c (y intercept) if you don’t remember how • Avoid false readings by checking a known resistor and using median • Fixed resistor on CH1 and throw out results off by more than “3” (>99.99%) • Use a median function to avoid false readings by reading 100 times
  • 12. Sensors – pH, Flow meter, and temperature • Atlas Scientific • Crème de la crème – worth every penny but not cheap • Reliable, high quality, and best of all - prebuilt serial circuits [no circuit skill required] • Use PWR-ISO module ($36) for power isolation: avoid ground loops and electrical noise • Serial Expander ($11) – Control up to 4 separate serial devices even though your Raspberry Pi only has one serial connection • Digital Temperature ($25) > cheaper analog probes: easier to calibrate, easier to integrate, high quality • Flow Meter sensor ($38) “just works” with a cheap (adafruit $9) flow meter • pH probe kit ($150) is high quality, easy to calibrate, easy to read
  • 13. Sensors – Data sheets • pH Circuit: http://atlas-scientific.com/_files/_datasheets/_circuit/pH_EZO_datasheet.pdf • Flow Circuit: http://atlas-scientific.com/_files/_datasheets/_circuit/flow_EZO_Datasheet.pdf • Temperature Circuit: http://atlas-scientific.com/_files/_datasheets/_probe/ENV-TEMP-D.pdf • Power isolation: http://atlas-scientific.com/_files/_datasheets/_circuit/pwr-iso.pdf • Serial expander: https://www.atlas- scientific.com/_files/_datasheets/_circuit/serial_port_expander_datasheet.pdf
  • 14. Sample Code – Atlas Scientific SensorsEnglish: We need to create a serial connection We need two pins to tell the serial expander which device to connect to: Which requires two output pins to flip between 4 devices: (00, 01, 10, and 11) We open our serial connection at 9600kbps with /dev/ttyAMA0 Use a TextIOWrapper to io buffer until a newline character is returned Forever: Set the device to 00 (flow sensor) Read in a few lines (to make sure we clear out garbage) Read the line and split the volume and flow to variables If we fail, just output “unknown” Set the device to 01 (pH meter) Read in a few lines, return line etc… Python: Serial Expander Mapping
  • 15. Video • Raspivid is incredible – 1080p live video streaming to Youtube • Requires ~3-5Mbps of traffic • How to make it work • Create a Live stream (free!): https://www.youtube.com/live_dashboard • Create a bash script and enter your server and key • Download optimized ffmpeg for ARM (required!): https://www.reddit.com/r/raspberry_pi/comments/2ahzp2/raspberry_pi_encoder_live_streaming_to_youtube/ • Tweak the raspivid options to fix the ISO, gain, fps, color/white balance correction. • No sound (I tried at one point to tee in some repeating mp3 audio using mpg123 but it caused issues) Bash Example:
  • 16. IoT Dashboard • https://freeboard.io/board/l1XbFY • Freeboard.io (BugLabs) • Great dashboards out of the box • Free hosting and open source • Possible to integrate with MQTT • MQTT using IBM IoT Foundation • Free • Extremely fast IOT message transport • Paho MQTT client (javascript): • https://rawgit.com/benjaminchodroff/freeboard-mqtt/paho-mqtt- default/ibm.iotfoundation.plugin.js • https://rawgit.com/benjaminchodroff/freeboard-mqtt/paho-mqtt- default/paho.mqtt.plugin.js • Integrates to Freeboard plugin through “Developer Console”
  • 17. IoT Messaging – IBM Watson IoT • MQTT based • Lightweight, high performance protocol perfectly suited for M2M messaging in a variety of IoT scenarios • Free to set up for limited number of devices • Scales easily in the public cloud • Contact CloudOne if you need private/custom implementations using BlueMix Local with MessageSight • Easy code examples to integrate variety of embedded devices in many languages
  • 18. Sample Code – IBM Watson IoT English: Config = my secret passwords Import the iot foundation Import a json wrapper for the iot foundation Let’s send a message with 12345 in it Try: Set our device connection configuration Connect using that configuration myData = “hello”: “world”, and “x”: 12345 Publish that message with myData Except/finally: Some quick error publishing and disconnect if it fails Python:
  • 19. IoT Messaging – NodeRED • Visual tool for wiring together hardware devices, APIs and online service • Based on NodeJS • Requires no javascript programming knowledge to use • Can be ran in IBM BlueMix Public or Local, or on site • Integrates easily to the IBM IoT Foundation, Twilio/SMS/Email/Twitter • Easily construct lightweight functions to parse messages and do logical evaluations – perfect for makers • Why? • Replaces 100’s of lines of python code and make it easy to visualize – great for tinkering • Free BlueMix Public hosting allows me to monitor my aquarium remotely • If the internet at home goes down, NodeRED knows device presence and can alert me • Sending control messages back to the aquarium (I performed a water change while in China) • Scales horizontally with clustering if your application requires it (I am not allowed to buy more aquariums to test this)
  • 22. Next Steps – Analytics Analytics of photosynthesis (NDVI infragram.org) response to dosing
  • 23. Next Steps – You • All the source code/experimentation • https://github.com/benjaminchodroff/aquariumiot • Think this is fun? • CloudOne is hiring developers, data scientists, and building the future of IoT • Contact me! Benjamin.chodroff@oncloudone.com
  • 25. CO2 Levels based on kH and pH • 6.5 is the sweet spot at my kH 3 due to RO water • My tap water comes from Lake Michigan and has a kH of 11+ -- too high for my plants
  • 26. Dosing Guide One day machine imaging will be good enough But for now this is a manual inspection with manual adjustment
  • 27. Dosing Regimen – Cron Schedule • http://www.seachem.com/downloads/charts/Plant-Dose-Chart.pdf • http://www.aquaticplantcentral.com/forumapc/attachment.php?atta chmentid=5525&d=1192589007