SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Taking the "hard" out of hardware
@RonaldMcCollam
mccollam@gmail.com / ronald@resin.io
www.ronaldmccollam.com
resin.io
int main() {
About me and how I learned hardware
Hardware for Linux geeks
Going smaller: microcontrollers
Building a project
Where to go from here
resin.io
Who am I?
Linux geek from way back (when Slackware was the easy distro!)
Terrified of hardware… at least until recently
Email: mccollam@gmail.com or ronald@resin.io
Twitter: @RonaldMcCollam
Web: www.ronaldmccollam.com
resin.io
Software is "safe"...
resin.io
resin.ioPhoto: Tina Rataj-Berard
Hardware is scary!
resin.io
resin.ioPhoto: João Alves
How I learned hardware
I kept hearing about this "Internet of Things"... because it was constantly broken!
Weirdly, seeing other people fail made me feel better about making mistakes.
resin.io
How I learned hardware
I learned Linux by doing, breaking, and redoing.
Hardware would have to go the same way!
resin.io
Single biggest tip
Don't be afraid of "toy" projects!
resin.io
How I learned hardware
Start "big" and go small
If you know software, do what you can in software!
Let someone else worry about the hardware,
at least at first
Lots to choose from!
Raspberry Pi
Beaglebone
Samsung ARTIK
NextThing C.H.I.P.
Onion Omega
… so many more!
resin.io
Hardware for Linux geeks: Raspberry Pi
Very common
Cheap: $5 - $35
Lots of connectivity and expansion
● USB
● Ethernet
● HDMI
● WiFi / Bluetooth (on some models)
● HATs: Hardware Attached on Top
● GPIO
resin.io
Hardware for Linux geeks: GPIO
GPIO: General Purpose Input/Output
Can be read or write, digital or analog
Lots of ways to access in Linux
sysfs exposure: /sys/class/gpio
resin.io
"hello world" for hardware
resin.io
Using GPIO in Python
#!/usr/bin/env python
import RPi.GPIO as GPIO
# What pin the LED is connected to:
led = 11
# Set up that pin to be used for output:
GPIO.setup(led, GPIO.OUT)
# Set the pin value to 'high', turning it on:
GPIO.output(led, GPIO.HIGH)
resin.io
Using GPIO in bash(!)
#!/bin/bash
# What pin the LED is connected to:
LED=11
# Mark the pin as 'exported' and that it's used for output:
echo "$LED" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$LED/direction
# Set the pin value to 'high' (1) turning it on:
echo "1" > /sys/class/gpio/gpio$LED/value
resin.io
Adding more functionality
Most devices support some sort of add-ons via the
GPIO pins
E.g. Raspberry Pi Sense HAT
Accelerometer, gyroscope, magnetometer,
thermometer, barometer, hygrometer
Cool LED matrix
Common protocols for other add-ons:
I2
C - Inter-Integrated Circuit
SPI - Serial Peripheral Interface
USB - Universal Serial Bus (you know this!)
resin.io
The Raspberry Pi and similar devices are Linux computers!
You can use python, gcc/gdb, node.js, bash right on the device
Build packages, use git
(Shameless plug: resin.io lets you git push your code and have it run on these devices
directly in a Docker container! Really useful for production code...)
Tools, tools, tools
resin.io
resin.ioPhoto: Click and Boo
Going smaller: microcontrollers
Non-Linux devices - simple OS (or none at all!)
Usually very limited if you come from a desktop/web background
Many frameworks exist to work with these
microPython (Python)
Johnny-Five (javascript)
eLua/nodeMCU (Lua)
Arduino (C++)
… many others!
resin.io
Embedded hardware: ESP8266
Great hardware support: I2
C, SPI, UART (serial),
GPIO, WiFi
Reasonable power use (including deep sleep modes)
Widely used (so there are a lot of add-ons and
tutorials available)
Small and CHEAP!
($16.95 for a full breakout board from Adafruit, can be
less than $3 in small quantities from Chinese sources)
resin.io
C++ on embedded devices: Arduino
Probably the most common embedded framework
C/C++ based
LOTS of existing libraries
Open source
Expanded to support a vast array of hardware
resin.io
LEDs with Arduino
#define LED_PIN 5
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(1000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}
resin.io
Adding on
Remember I2
C and SPI? They work in microcontrollers too!
Every type of sensor you can think of
Output too
Displays, speakers
Even GPS and networking!
resin.io
A real project
Dryer is in the basement
People 3 floors up want to know when it's finished
● ESP8266 with Arduino framework ($3)
● I2
C LCD module ($4)
● 4x4 matrix keypad ($1)
● I2
C I/O module for keypad ($1.50)
● MPU 6050 accelerometer ($1)
Total: $10.50
(Plus paper for keypad, wood for case, screws, USB
cable for power -- stuff I had already)
resin.io
Lots of libraries
// ESP8266 WiFi support:
#include <ESP8266WiFi.h>
// I2C support:
#include <Wire.h>
// LCD support:
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
// Matrix keypad support:
#include <Keypad_I2C/Keypad_I2C.h>
#include <Keypad.h>
// MQTT support:
#include <PubSubClient.h>
// Accelerometer support:
#include <MPU6050.h>
resin.io
Simple C code
void set_status_lcd()
{
lcd.setCursor(0, 0);
lcd.print(dryerRunning ? "running" : "stopped");
lcd.print(" ");
// Calculation for real temperature from
// https://www.i2cdevlib.com/forums/topic/53-mpu-6050-temperature-compensation/
String temp = String(round((mpu.getTemperature()/340. + 36.53) * 10) / 10.0).substring(0, 4);
lcd.print(temp + (char)223 + "C"); // 223 == degree sign ⁰
}
void set_notify_mqtt()
{
// Publish MQTT message
mqtt.publish(mqttTopicPerson, notifyPerson, true);
mqtt.publish(mqttTopicMethod, notifyMethod, true);
}
resin.io
resin.io
resin.ioPhoto: Randall Bruder
Resources: where to get hardware
Top recommendations:
● Adafruit - https://www.adafruit.com
○ The "Huzzah" board is a great way to get started with the ESP8266 -- lots of add-ons and libraries
● Sparkfun - https://www.sparkfun.com
○ The "ESP8266 Thing Dev Board" looks similar to the "Huzzah" from Adafruit (but I haven't used it)
More esoteric:
● AliExpress (look in 'electronic components and supplies')
https://www.aliexpress.com/category/502/electronic-components-supplies.html
resin.io
Resources: frameworks and tutorials
● Arduino: https://www.arduino.cc
● Johnny-Five: http://johnny-five.io
● MicroPython: https://micropython.org
● NodeMCU (Lua environment for ESP8266): http://nodemcu.com
● https://learn.adafruit.com
● https://learn.sparkfun.com
resin.io
Resources: tools
● PlatformIO (makes installing/managing Arduino libraries easier):
http://platformio.org
● resin.io (makes building and deploying to Linux devices easier):
https://resin.io
resin.io
Thank you!
@RonaldMcCollam
mccollam@gmail.com / ronald@resin.io
www.ronaldmccollam.com
resin.io

Weitere ähnliche Inhalte

Was ist angesagt?

chilug-bbone-20140118-151216015606
chilug-bbone-20140118-151216015606chilug-bbone-20140118-151216015606
chilug-bbone-20140118-151216015606
Drew Fustini
 
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
codebits
 
You're open source
You're open sourceYou're open source
You're open source
Ahmed Abdou
 

Was ist angesagt? (15)

Retrocomputers as Hacking Platforms
Retrocomputers as Hacking PlatformsRetrocomputers as Hacking Platforms
Retrocomputers as Hacking Platforms
 
chilug-bbone-20140118-151216015606
chilug-bbone-20140118-151216015606chilug-bbone-20140118-151216015606
chilug-bbone-20140118-151216015606
 
Internet Technology for the Commodore 64
Internet Technology for the Commodore 64Internet Technology for the Commodore 64
Internet Technology for the Commodore 64
 
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
Hardware Hacking area: Make Cool Things with Microcontrollers (and learn to s...
 
2016/11/05: OSWDem16 intro
2016/11/05: OSWDem16 intro2016/11/05: OSWDem16 intro
2016/11/05: OSWDem16 intro
 
Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64Alessandro Abbruzzetti - Kernal64
Alessandro Abbruzzetti - Kernal64
 
Audible Objects
Audible ObjectsAudible Objects
Audible Objects
 
More Mad Science for the Commodore 64 (ECCC 2015)
More Mad Science for the Commodore 64 (ECCC 2015)More Mad Science for the Commodore 64 (ECCC 2015)
More Mad Science for the Commodore 64 (ECCC 2015)
 
Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64Wi-Fi Modem For the Commodore 64
Wi-Fi Modem For the Commodore 64
 
Hardware hacking and internet of things
Hardware hacking and internet of thingsHardware hacking and internet of things
Hardware hacking and internet of things
 
Ultimate Modded Commodore 64
Ultimate Modded Commodore 64Ultimate Modded Commodore 64
Ultimate Modded Commodore 64
 
Hacking school computers for fun profit and better grades short
Hacking school computers for fun profit and better grades shortHacking school computers for fun profit and better grades short
Hacking school computers for fun profit and better grades short
 
You're open source
You're open sourceYou're open source
You're open source
 
History of Computing
History of ComputingHistory of Computing
History of Computing
 
Open source hardware
Open source hardwareOpen source hardware
Open source hardware
 

Ähnlich wie Taking the hard out of hardware

A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKINGA BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
Silvio Cesare
 
Intro to arduino
Intro to arduinoIntro to arduino
Intro to arduino
José Faria
 

Ähnlich wie Taking the hard out of hardware (20)

Let's begin io t with $10
Let's begin io t with $10Let's begin io t with $10
Let's begin io t with $10
 
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
 
Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
 
Single Boards Overview
Single Boards OverviewSingle Boards Overview
Single Boards Overview
 
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKINGA BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PI
 
Taller IoT en la Actualidad
Taller IoT en la ActualidadTaller IoT en la Actualidad
Taller IoT en la Actualidad
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Getting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
 
Начало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev KitНачало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev Kit
 
IoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT Devkit
 
Maker Movement
Maker MovementMaker Movement
Maker Movement
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
Arduino Development For Beginners
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For Beginners
 
pcDuino tech talk at Carnegie Mellon University 10/14/2014
pcDuino tech talk at Carnegie Mellon University 10/14/2014pcDuino tech talk at Carnegie Mellon University 10/14/2014
pcDuino tech talk at Carnegie Mellon University 10/14/2014
 
Arduino presentation
Arduino presentationArduino presentation
Arduino presentation
 
Intro to arduino
Intro to arduinoIntro to arduino
Intro to arduino
 
pcDuino Presentation at SparkFun
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
 
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
 
Developing a NodeBot using Intel XDK IoT Edition
Developing a NodeBot using Intel XDK IoT EditionDeveloping a NodeBot using Intel XDK IoT Edition
Developing a NodeBot using Intel XDK IoT Edition
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Taking the hard out of hardware

  • 1. Taking the "hard" out of hardware @RonaldMcCollam mccollam@gmail.com / ronald@resin.io www.ronaldmccollam.com resin.io
  • 2. int main() { About me and how I learned hardware Hardware for Linux geeks Going smaller: microcontrollers Building a project Where to go from here resin.io
  • 3. Who am I? Linux geek from way back (when Slackware was the easy distro!) Terrified of hardware… at least until recently Email: mccollam@gmail.com or ronald@resin.io Twitter: @RonaldMcCollam Web: www.ronaldmccollam.com resin.io
  • 8. How I learned hardware I kept hearing about this "Internet of Things"... because it was constantly broken! Weirdly, seeing other people fail made me feel better about making mistakes. resin.io
  • 9. How I learned hardware I learned Linux by doing, breaking, and redoing. Hardware would have to go the same way! resin.io
  • 10. Single biggest tip Don't be afraid of "toy" projects! resin.io
  • 11. How I learned hardware Start "big" and go small If you know software, do what you can in software! Let someone else worry about the hardware, at least at first Lots to choose from! Raspberry Pi Beaglebone Samsung ARTIK NextThing C.H.I.P. Onion Omega … so many more! resin.io
  • 12. Hardware for Linux geeks: Raspberry Pi Very common Cheap: $5 - $35 Lots of connectivity and expansion ● USB ● Ethernet ● HDMI ● WiFi / Bluetooth (on some models) ● HATs: Hardware Attached on Top ● GPIO resin.io
  • 13. Hardware for Linux geeks: GPIO GPIO: General Purpose Input/Output Can be read or write, digital or analog Lots of ways to access in Linux sysfs exposure: /sys/class/gpio resin.io
  • 14. "hello world" for hardware resin.io
  • 15. Using GPIO in Python #!/usr/bin/env python import RPi.GPIO as GPIO # What pin the LED is connected to: led = 11 # Set up that pin to be used for output: GPIO.setup(led, GPIO.OUT) # Set the pin value to 'high', turning it on: GPIO.output(led, GPIO.HIGH) resin.io
  • 16. Using GPIO in bash(!) #!/bin/bash # What pin the LED is connected to: LED=11 # Mark the pin as 'exported' and that it's used for output: echo "$LED" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$LED/direction # Set the pin value to 'high' (1) turning it on: echo "1" > /sys/class/gpio/gpio$LED/value resin.io
  • 17. Adding more functionality Most devices support some sort of add-ons via the GPIO pins E.g. Raspberry Pi Sense HAT Accelerometer, gyroscope, magnetometer, thermometer, barometer, hygrometer Cool LED matrix Common protocols for other add-ons: I2 C - Inter-Integrated Circuit SPI - Serial Peripheral Interface USB - Universal Serial Bus (you know this!) resin.io
  • 18. The Raspberry Pi and similar devices are Linux computers! You can use python, gcc/gdb, node.js, bash right on the device Build packages, use git (Shameless plug: resin.io lets you git push your code and have it run on these devices directly in a Docker container! Really useful for production code...) Tools, tools, tools resin.io
  • 20. Going smaller: microcontrollers Non-Linux devices - simple OS (or none at all!) Usually very limited if you come from a desktop/web background Many frameworks exist to work with these microPython (Python) Johnny-Five (javascript) eLua/nodeMCU (Lua) Arduino (C++) … many others! resin.io
  • 21. Embedded hardware: ESP8266 Great hardware support: I2 C, SPI, UART (serial), GPIO, WiFi Reasonable power use (including deep sleep modes) Widely used (so there are a lot of add-ons and tutorials available) Small and CHEAP! ($16.95 for a full breakout board from Adafruit, can be less than $3 in small quantities from Chinese sources) resin.io
  • 22. C++ on embedded devices: Arduino Probably the most common embedded framework C/C++ based LOTS of existing libraries Open source Expanded to support a vast array of hardware resin.io
  • 23. LEDs with Arduino #define LED_PIN 5 void setup() { pinMode(LED_PIN, OUTPUT); } void loop() { digitalWrite(LED_PIN, HIGH); delay(1000); digitalWrite(LED_PIN, LOW); delay(1000); } resin.io
  • 24. Adding on Remember I2 C and SPI? They work in microcontrollers too! Every type of sensor you can think of Output too Displays, speakers Even GPS and networking! resin.io
  • 25. A real project Dryer is in the basement People 3 floors up want to know when it's finished ● ESP8266 with Arduino framework ($3) ● I2 C LCD module ($4) ● 4x4 matrix keypad ($1) ● I2 C I/O module for keypad ($1.50) ● MPU 6050 accelerometer ($1) Total: $10.50 (Plus paper for keypad, wood for case, screws, USB cable for power -- stuff I had already) resin.io
  • 26. Lots of libraries // ESP8266 WiFi support: #include <ESP8266WiFi.h> // I2C support: #include <Wire.h> // LCD support: #include <hd44780.h> #include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header // Matrix keypad support: #include <Keypad_I2C/Keypad_I2C.h> #include <Keypad.h> // MQTT support: #include <PubSubClient.h> // Accelerometer support: #include <MPU6050.h> resin.io
  • 27. Simple C code void set_status_lcd() { lcd.setCursor(0, 0); lcd.print(dryerRunning ? "running" : "stopped"); lcd.print(" "); // Calculation for real temperature from // https://www.i2cdevlib.com/forums/topic/53-mpu-6050-temperature-compensation/ String temp = String(round((mpu.getTemperature()/340. + 36.53) * 10) / 10.0).substring(0, 4); lcd.print(temp + (char)223 + "C"); // 223 == degree sign ⁰ } void set_notify_mqtt() { // Publish MQTT message mqtt.publish(mqttTopicPerson, notifyPerson, true); mqtt.publish(mqttTopicMethod, notifyMethod, true); } resin.io
  • 30. Resources: where to get hardware Top recommendations: ● Adafruit - https://www.adafruit.com ○ The "Huzzah" board is a great way to get started with the ESP8266 -- lots of add-ons and libraries ● Sparkfun - https://www.sparkfun.com ○ The "ESP8266 Thing Dev Board" looks similar to the "Huzzah" from Adafruit (but I haven't used it) More esoteric: ● AliExpress (look in 'electronic components and supplies') https://www.aliexpress.com/category/502/electronic-components-supplies.html resin.io
  • 31. Resources: frameworks and tutorials ● Arduino: https://www.arduino.cc ● Johnny-Five: http://johnny-five.io ● MicroPython: https://micropython.org ● NodeMCU (Lua environment for ESP8266): http://nodemcu.com ● https://learn.adafruit.com ● https://learn.sparkfun.com resin.io
  • 32. Resources: tools ● PlatformIO (makes installing/managing Arduino libraries easier): http://platformio.org ● resin.io (makes building and deploying to Linux devices easier): https://resin.io resin.io
  • 33. Thank you! @RonaldMcCollam mccollam@gmail.com / ronald@resin.io www.ronaldmccollam.com resin.io