SlideShare a Scribd company logo
Building Connected Things
with Electric Imp
These slides are licensed under the MIT License
http://opensource.org/licenses/MIT
SSID: impdemo
PW: electric
Matt Haines | Tom Byrne
matt@electricimp.com | tom@electricimp.com
@beardedinventor | @tlbyrn
Agenda
The Internet of Things
• What is the Internet of Things
• What does the Internet of Things space look like
• What goes into an Internet of Things application
• Overview of the Electric Imp platform
Workshop – Your first imp project
• Getting your first imp online
• Digital I/O
• Building a basic HTTPS request handler
• Making HTTP requests
The Internet of Things (2025)
50B
Connected
Devices
$6.2T
Economic
Impact
McKinsey Global Institute, 2013
Internet of Things Verticals
What Goes Into an IoT Application
• Hardware
• Microcontrollers, radios, sensors, actuators, etc
• Firmware
• Device logic, drivers, network stack, etc
• Server Code
• Heavy processing, external device API, data storage, etc
• External Web Services
• Weather APIs, Twitter, Twilio, Gmail/email, IFTTT, etc
• App / Website / Etc
• User interface, OAuth, etc
• Areas of knowledge required:
• Electrical Engineering, embedded software, security, backend/server
development, web development, database admin, app development, …
The Electric Imp Platform
Connectivity Infrastructure
In-house
Great products
Focus on the
core business
Platform
Server Infrastructure
In-house
Great products
Focus on the
core business
Platform
The Electric Imp Platform – Overview
The Electric Imp Platform - Devices
• 32-Bit ARM Cortex M3 processor
• 802.11 b/g/n WiFi
• Open WiFi, WEP, WPA, WPA2
• 80 KB* code space (device – 'firmware')
• 6/12 Configurable GPIO Pins
• Digital In/Out
• Analog In
• 12 bit DAC (Analog Out)
• PWM Out
• I2C, UART, SPI
* This value changes a little bit each release (the imp originally only had about 40 KB of code space)
The Electric Imp Platform - Agents
• Micro-server than can act on behalf of a device
• Runs on the Electric Imp Servers
• 1 MB code space
• 1MB RAM
• Allows you to do things that you typically can’t on an embedded processor
• Process incoming HTTP requests (create APIs for your device)
• Make outgoing HTTP requests (interact with external APIs)
• Persist small amounts of data
Let’s get started
BlinkUp - Getting Online
• Create an Electric Imp Account: https://ide.electricimp.com
• Download the Electric Imp mobile app:
• Android: play.google.com/store/apps/details?id=com.electricimp.electricimp
• iPhone: itunes.apple.com/us/app/electric-imp
• Sign into the app with your Electric Imp Account
• Enter WiFi credentials:
• SSID: impdemo
• PW: electric
• Power up your imp
• The imp’s internal LED must be blinking before continuing to the next step
• Click BlinkUp in the mobile app
• Hold screen of phone against blinking light of imp until BlinkUp is complete
• Your device should now be blinking green (online)*
* Your imp will stop blinking after 1 minute to save power (it is still powered on)
BlinkUp Example
* Your imp will stop blinking after 1 minute to save power (it is still powered on)
Creating a New Model
Creating a New Model
Creating a New Model
Creating a New Model
Digital Output - Circuit
Digital Output - Device Code
// Device Code
led <- hardware.pin9;
led.configure(DIGITAL_OUT);
state <- 0;
function blink() {
imp.wakeup(1.0, blink);
state = 1 – state;
led.write(state);
}
blink();
Blocking Loops are Bad!
// Device Code
// NOTE: THIS IS BAD CODE:
led <- hardware.pin9;
led.configure(DIGITAL_OUT);
function loop() {
local state = 0;
while (1) {
led.write(state);
state = 1 – state;
imp.sleep(1.0);
}
}
loop();
Digital Input – Circuit
Digital Input - Device Code
// Device Code:
led <- hardware.pin9;
led.configure(DIGITAL_OUT);
button <- hardware.pin1;
function onButton() {
local state = button.read();
led.write(state);
}
button.configure(DIGITAL_IN_PULLUP, onButton);
Event Driven Programming and Callbacks
• Squirrel is an Event Driven Language
• Behaviour is defined by events and callbacks
• An event is a pre-programmed thing that can happen:
• The timeout on an imp.wakeup ends
• The state of a DIGITAL_IN pin changes
• A message is passed from the device to the agent or vice versa
• An agent receives an incoming HTTP request
• A callback is a function bound to a event:
• imp.wakeup(5, blink);
• Tells the imp to run the function called blink in 5 seconds
• button.configure(DIGITAL_IN, onButton);
• Tells the imp to run the function called onButton when the state of the pin
assigned to button changes
HTTP Handlers
• Each device has an agent – a tiny micro servers that act on behalf of their device
• Each agent has a unique URL associated with it (see below)
• http.onrequest binds a callback to the 'received incoming HTTP Request' event
HTTP Handler – Agent Code
// Agent Code:
function httpHandler(request, response) {
if ("state" in request.query) {
local state = request.query["state"];
device.send("led", state);
}
response.send(200, "OK");
}
http.onrequest(httpHandler);
HTTP Handler – Device Code
// Device Code:
led <- hardware.pin9;
led.configure(DIGITAL_OUT);
function ledHandler(data) {
if (data == "0") {
server.log("LED OFF")
led.write(0);
} else {
server.log("LED ON");
led.write(1);
}
}
agent.on("led", ledHandler);
Passing Messages
Making HTTP Requests – Device Code
// Device Code:
led <- hardware.pin9;
led.configure(DIGITAL_OUT);
function ledHandler(data) {
if (data == "0") {
server.log("LED OFF")
led.write(0);
} else {
server.log("LED ON");
led.write(1);
}
}
agent.on("led", ledHandler);
Making HTTP Requests – Agent Code
// Add to the bottom of your agent code:
const URL = "https://agent.electricimp.com/RO5HOrveo4I1";
function buttonPressHandler(state) {
local url = URL + "?state=" + state;
local request = http.get(url);
request.sendasync(function(resp) {
server.log(resp.statuscode + " - " + resp.body);
});
}
device.on("buttonPress", buttonPressHandler)
Passing Messages
Other activities
• Device:
• Try to control your LED with PWM
• electricimp.com/docs/examples/pwm-led
• Bonus: Try to control the brightness with a web request
• Create multiple “states” for your LED (on, off, blinking slow, blinking fast)
• Make the button switch between states
• Agent:
• Grab the Wunderground API code
• github.com/electricimp/reference/tree/master/webservices/wunderground
• Grab weather every 5 mins and change the brightness of the LED based on
the temperature
• Bonus: Create an Umbrella reminder to keep by your front door:
• Every morning the agent checks the weather
• If there’s > 50% chance of rain, LED turns on
• Grab the Twitter API
• github.com/electricimp/reference/tree/master/webservices/twitter
• Make your imp tweet whenever the button is pressed
• Bonus: Control the state of the LED based on a Twitter stream
• Turn the light on whenever something is tweeted with a tracked tag
• Click the button to clear the light
Electric Imp Resource
Getting Started Guide electricimp.com/docs/getting-started
API Documentation electricimp.com/docs/api
Squirrel Documentation electricimp.com/docs/squirrel
Reference Code github.com/electricimp/reference
Community Blog community.electricimp.com
Forums forums.electricimp.com

More Related Content

Similar to Hackbright Workshop (20)

PDF
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
Hackito Ergo Sum
 
PPTX
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Adam Dunkels
 
PDF
LG Developer Event 2013 in San Francisco
LGDeveloper
 
PPTX
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
Rapid7
 
PPTX
Internet of Things 101 - Part II
Yoonseok Hur
 
PDF
DIY Technology for the Internet of Things
srmonk
 
KEY
Android and Arduio mixed with Breakout js
musart Park
 
PPTX
Arduino blueooth
Nitish Kumar
 
PDF
Node red for Raspberry Pi
Anshu Pandey
 
PPTX
Android Things, Alexey Rybakov, Technical Evangelist, DataArt
Alina Vilk
 
PDF
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CanSecWest
 
PPTX
IAB3948 Wiring the internet of things with Node-RED
PeterNiblett
 
PPTX
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Adam Dunkels
 
PDF
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Codemotion Tel Aviv
 
PPTX
Uvais
Rao Uvais Khan
 
PPTX
Introduction to Node MCU
Amarjeetsingh Thakur
 
PDF
Gobot Meets IoT : Using the Go Programming Language to Control The “Things” A...
Justin Grammens
 
PPTX
Windows 10 IoT-Core to Azure IoT Suite
David Jones
 
PDF
Connecting Hardware to Flex (360MAX)
Justin Mclean
 
PPTX
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
The Internet of Things Methodology
 
[HES2013] Hacking apple accessories to pown iDevices – Wake up Neo! Your phon...
Hackito Ergo Sum
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 2
Adam Dunkels
 
LG Developer Event 2013 in San Francisco
LGDeveloper
 
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
Rapid7
 
Internet of Things 101 - Part II
Yoonseok Hur
 
DIY Technology for the Internet of Things
srmonk
 
Android and Arduio mixed with Breakout js
musart Park
 
Arduino blueooth
Nitish Kumar
 
Node red for Raspberry Pi
Anshu Pandey
 
Android Things, Alexey Rybakov, Technical Evangelist, DataArt
Alina Vilk
 
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
CanSecWest
 
IAB3948 Wiring the internet of things with Node-RED
PeterNiblett
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Adam Dunkels
 
Can we build an Azure IoT controlled device in less than 40 minutes that cost...
Codemotion Tel Aviv
 
Introduction to Node MCU
Amarjeetsingh Thakur
 
Gobot Meets IoT : Using the Go Programming Language to Control The “Things” A...
Justin Grammens
 
Windows 10 IoT-Core to Azure IoT Suite
David Jones
 
Connecting Hardware to Flex (360MAX)
Justin Mclean
 
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
The Internet of Things Methodology
 

More from Matt Haines (6)

PDF
Best Practices for Design Hardware APIs
Matt Haines
 
PPTX
Robots conf microcontroller and iot survey
Matt Haines
 
PPTX
Your Device Needs an API
Matt Haines
 
PDF
Api workshop
Matt Haines
 
PPTX
Electric Imp - Hackathon Intro
Matt Haines
 
PPTX
electric imp Intro
Matt Haines
 
Best Practices for Design Hardware APIs
Matt Haines
 
Robots conf microcontroller and iot survey
Matt Haines
 
Your Device Needs an API
Matt Haines
 
Api workshop
Matt Haines
 
Electric Imp - Hackathon Intro
Matt Haines
 
electric imp Intro
Matt Haines
 

Recently uploaded (20)

PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
The Future of Artificial Intelligence (AI)
Mukul
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 

Hackbright Workshop

  • 1. Building Connected Things with Electric Imp These slides are licensed under the MIT License http://opensource.org/licenses/MIT SSID: impdemo PW: electric Matt Haines | Tom Byrne [email protected] | [email protected] @beardedinventor | @tlbyrn
  • 2. Agenda The Internet of Things • What is the Internet of Things • What does the Internet of Things space look like • What goes into an Internet of Things application • Overview of the Electric Imp platform Workshop – Your first imp project • Getting your first imp online • Digital I/O • Building a basic HTTPS request handler • Making HTTP requests
  • 3. The Internet of Things (2025) 50B Connected Devices $6.2T Economic Impact McKinsey Global Institute, 2013
  • 4. Internet of Things Verticals
  • 5. What Goes Into an IoT Application • Hardware • Microcontrollers, radios, sensors, actuators, etc • Firmware • Device logic, drivers, network stack, etc • Server Code • Heavy processing, external device API, data storage, etc • External Web Services • Weather APIs, Twitter, Twilio, Gmail/email, IFTTT, etc • App / Website / Etc • User interface, OAuth, etc • Areas of knowledge required: • Electrical Engineering, embedded software, security, backend/server development, web development, database admin, app development, …
  • 6. The Electric Imp Platform Connectivity Infrastructure In-house Great products Focus on the core business Platform Server Infrastructure In-house Great products Focus on the core business Platform
  • 7. The Electric Imp Platform – Overview
  • 8. The Electric Imp Platform - Devices • 32-Bit ARM Cortex M3 processor • 802.11 b/g/n WiFi • Open WiFi, WEP, WPA, WPA2 • 80 KB* code space (device – 'firmware') • 6/12 Configurable GPIO Pins • Digital In/Out • Analog In • 12 bit DAC (Analog Out) • PWM Out • I2C, UART, SPI * This value changes a little bit each release (the imp originally only had about 40 KB of code space)
  • 9. The Electric Imp Platform - Agents • Micro-server than can act on behalf of a device • Runs on the Electric Imp Servers • 1 MB code space • 1MB RAM • Allows you to do things that you typically can’t on an embedded processor • Process incoming HTTP requests (create APIs for your device) • Make outgoing HTTP requests (interact with external APIs) • Persist small amounts of data
  • 11. BlinkUp - Getting Online • Create an Electric Imp Account: https://ide.electricimp.com • Download the Electric Imp mobile app: • Android: play.google.com/store/apps/details?id=com.electricimp.electricimp • iPhone: itunes.apple.com/us/app/electric-imp • Sign into the app with your Electric Imp Account • Enter WiFi credentials: • SSID: impdemo • PW: electric • Power up your imp • The imp’s internal LED must be blinking before continuing to the next step • Click BlinkUp in the mobile app • Hold screen of phone against blinking light of imp until BlinkUp is complete • Your device should now be blinking green (online)* * Your imp will stop blinking after 1 minute to save power (it is still powered on)
  • 12. BlinkUp Example * Your imp will stop blinking after 1 minute to save power (it is still powered on)
  • 13. Creating a New Model
  • 14. Creating a New Model
  • 15. Creating a New Model
  • 16. Creating a New Model
  • 17. Digital Output - Circuit
  • 18. Digital Output - Device Code // Device Code led <- hardware.pin9; led.configure(DIGITAL_OUT); state <- 0; function blink() { imp.wakeup(1.0, blink); state = 1 – state; led.write(state); } blink();
  • 19. Blocking Loops are Bad! // Device Code // NOTE: THIS IS BAD CODE: led <- hardware.pin9; led.configure(DIGITAL_OUT); function loop() { local state = 0; while (1) { led.write(state); state = 1 – state; imp.sleep(1.0); } } loop();
  • 20. Digital Input – Circuit
  • 21. Digital Input - Device Code // Device Code: led <- hardware.pin9; led.configure(DIGITAL_OUT); button <- hardware.pin1; function onButton() { local state = button.read(); led.write(state); } button.configure(DIGITAL_IN_PULLUP, onButton);
  • 22. Event Driven Programming and Callbacks • Squirrel is an Event Driven Language • Behaviour is defined by events and callbacks • An event is a pre-programmed thing that can happen: • The timeout on an imp.wakeup ends • The state of a DIGITAL_IN pin changes • A message is passed from the device to the agent or vice versa • An agent receives an incoming HTTP request • A callback is a function bound to a event: • imp.wakeup(5, blink); • Tells the imp to run the function called blink in 5 seconds • button.configure(DIGITAL_IN, onButton); • Tells the imp to run the function called onButton when the state of the pin assigned to button changes
  • 23. HTTP Handlers • Each device has an agent – a tiny micro servers that act on behalf of their device • Each agent has a unique URL associated with it (see below) • http.onrequest binds a callback to the 'received incoming HTTP Request' event
  • 24. HTTP Handler – Agent Code // Agent Code: function httpHandler(request, response) { if ("state" in request.query) { local state = request.query["state"]; device.send("led", state); } response.send(200, "OK"); } http.onrequest(httpHandler);
  • 25. HTTP Handler – Device Code // Device Code: led <- hardware.pin9; led.configure(DIGITAL_OUT); function ledHandler(data) { if (data == "0") { server.log("LED OFF") led.write(0); } else { server.log("LED ON"); led.write(1); } } agent.on("led", ledHandler);
  • 27. Making HTTP Requests – Device Code // Device Code: led <- hardware.pin9; led.configure(DIGITAL_OUT); function ledHandler(data) { if (data == "0") { server.log("LED OFF") led.write(0); } else { server.log("LED ON"); led.write(1); } } agent.on("led", ledHandler);
  • 28. Making HTTP Requests – Agent Code // Add to the bottom of your agent code: const URL = "https://agent.electricimp.com/RO5HOrveo4I1"; function buttonPressHandler(state) { local url = URL + "?state=" + state; local request = http.get(url); request.sendasync(function(resp) { server.log(resp.statuscode + " - " + resp.body); }); } device.on("buttonPress", buttonPressHandler)
  • 30. Other activities • Device: • Try to control your LED with PWM • electricimp.com/docs/examples/pwm-led • Bonus: Try to control the brightness with a web request • Create multiple “states” for your LED (on, off, blinking slow, blinking fast) • Make the button switch between states • Agent: • Grab the Wunderground API code • github.com/electricimp/reference/tree/master/webservices/wunderground • Grab weather every 5 mins and change the brightness of the LED based on the temperature • Bonus: Create an Umbrella reminder to keep by your front door: • Every morning the agent checks the weather • If there’s > 50% chance of rain, LED turns on • Grab the Twitter API • github.com/electricimp/reference/tree/master/webservices/twitter • Make your imp tweet whenever the button is pressed • Bonus: Control the state of the LED based on a Twitter stream • Turn the light on whenever something is tweeted with a tracked tag • Click the button to clear the light
  • 31. Electric Imp Resource Getting Started Guide electricimp.com/docs/getting-started API Documentation electricimp.com/docs/api Squirrel Documentation electricimp.com/docs/squirrel Reference Code github.com/electricimp/reference Community Blog community.electricimp.com Forums forums.electricimp.com

Editor's Notes

  • #2: Welcome everyone Introduce yourself Ensure everyone is on WiFi Share a link to the slides or provide a printed copy as a handout (printed copies means participants will need to type in code, instead of copy paste)
  • #3: Quickly go over what they will be learning tonight The Internet of Things Startup space slide / discussion is very optional, and should really only be used when it will provide interest / value to the workshop (i.e. – university students) Go over the main goals of the course Understand how to get your imps online Understand basic event driven programming and message passing in the Electric Imp platform Understand how to write basic APIs for your hardware Understand how to make basic web requests from an agent
  • #4: Quickly go over what they will be learning tonight The Internet of Things Startup space slide / discussion is very optional, and should really only be used when it will provide interest / value to the workshop (i.e. – university students) Go over the main goals of the course Understand how to get your imps online Understand basic event driven programming and message passing in the Electric Imp platform Understand how to write basic APIs for your hardware Understand how to make basic web requests from an agent
  • #5: Talk about some of the various verticals in the IoT Space (note this is far from complete) Talk about how some of the products work, and the various components that go into it - Nest is a good example.. - Hardware (the Nest), Software (running on the Nest, your phone, the Nest Servers), security between everything so someone else can’t set your thermostat, see when you’re home, etc - Revenue from Nest comes from selling units, but also potentially from power companies for cycling AC in a way that prevents peaks while people are away from home - Toymail is a good Electric Imp Example - Little mailbox shapped toys - Allows parents/grandparents to send voice mails to kits without phones - Hardware, software (on the device, your phone, Toymails servers, imp servers), security (you don’t want strangers sending voicemails to your kids, you don’t want strangers knowing when your kids are playing messages (ie – they’re home and their parents may not be). - Revenue from selling toys, also in-app purchase to send more than X messages per month (on-going revenue stream)
  • #6: Can talk about this in the context of the startups discussed previously, and how those applications have each of the following This is designed to illustrate the complexities of building an Internet of Things application and why platforms are a good thing Talk a little bit about how each layer fits into an IoT application and the user’s experience, and that each layer requires specialized knowledge
  • #7: Comparing Electric Imp to AWS – depending on the audience this slide may or may not make sense Focus on the things you’re good at – designing products, making Things Use platforms to solve things you are not good at / don’t want to focus on in product (security, connectivity, etc)
  • #8: There are four core components of the Electric Imp platform we’re going to look at today The imp / impOS This is the hardware that will execute your device code More details on the next slide The imp cloud & Open API Each imp has a tiny micro servo that runs in our cloud (i.e. on our servers) that you can program to do just about anything The imp cloud acts as a proxy for your device to do things embeeded devices traditionally can’t do (make and process web requests, encode/decode json, persist data, etc) BlinkUp BlinkUp is the process we use to get the imp online More information shortly The imp IDE (part of the imp cloud) This is where you write code for your device and your agent, view logs, and push updates to developer devices
  • #9: Imp001 (SD Card) has 6 configurable GPIO pins Imp002 (solder down module) has 12 configurable GPIO pins Imp003 (8mm x 10mm Murata module) has 24 configurable GPIO pins, but is not well suited for Makers, so we won’t talk about that Firmware is not true firmware, but rather interpreted code running in a VM on the device. Agents are embedded code running in a VM on the Electric Imp servers
  • #10: Imp001 (SD Card) has 6 configurable GPIO pins Imp002 (solder down module) has 12 configurable GPIO pins Imp003 (8mm x 10mm Murata module) has 24 configurable GPIO pins, but is not well suited for Makers, so we won’t talk about that Firmware is not true firmware, but rather interpreted code running in a VM on the device. Agents are embedded code running in a VM on the Electric Imp servers
  • #12: This is typically one of the longest and most difficult steps with a large group of people. Ensure that everyone is online before continuing.. If you don’t there will be people left behind who can’t do anything past this step. BlinkUp flashes the screen at 60 hz Please advise the room that if anyone is photosensitive or epileptic they should look away during BlinkUp If their phones audio is turned on, there are audio cues to indicate when BlinkUp starts and finishes BlinkUp is the process Electric Imp uses to get imps online Each imp card has a light sensor + led that is used in the BlinkUp process BlinkUp flashes the screen very quickly, which the light sensor reads as 1’s (bright) and 0’s (dark) Once BlinkUp is complete, the imp attempts to connect to the WiFi – and once it connects it talks to our servers and registers itself with your account If you want to change the account the imp is connected to, you can BlinkUp the device with new credentials The imp retains it’s network information even when powered off When the imp is powered on, it checks to see if it has network information, and if it does it tries to connect See course FAQ for BlinkUp troubleshooting
  • #13: This is typically one of the longest and most difficult steps with a large group of people. Ensure that everyone is online before continuing.. If you don’t there will be people left behind who can’t do anything past this step. BlinkUp flashes the screen at 60 hz Please advise the room that if anyone is photosensitive or epileptic they should look away during BlinkUp If their phones audio is turned on, there are audio cues to indicate when BlinkUp starts and finishes BlinkUp is the process Electric Imp uses to get imps online Each imp card has a light sensor + led that is used in the BlinkUp process BlinkUp flashes the screen very quickly, which the light sensor reads as 1’s (bright) and 0’s (dark) Once BlinkUp is complete, the imp attempts to connect to the WiFi – and once it connects it talks to our servers and registers itself with your account If you want to change the account the imp is connected to, you can BlinkUp the device with new credentials The imp retains it’s network information even when powered off When the imp is powered on, it checks to see if it has network information, and if it does it tries to connect See course FAQ for BlinkUp troubleshooting
  • #14: If people don’t see their devices, they may need to refresh The arrow points to the device we just blinked up - Click on the gear icon beside it
  • #15: Enter a model name - A model is a pair of device and agent code that tied together We’re naming our model Electric Imp Workshop 1 – you can call yours whatever you want Hit enter after you’ve entered a name
  • #16: Click Save Changes
  • #17: Select your device - A model can have multiple devices associated with it - Each device has it’s own agent We need to select what device we want to communicate with, view logs for, etc
  • #18: Make sure to point out that LEDs have a “right way” and a “wrong way” and that the longer leg of the LED must be connected to the PIN9 side
  • #19: Things to point out: <- global variable Configure hardware.pin9 as a DIGITAL_OUT – it’s either on (1) or off (0) state = current state of the LED Functions are blocks of code we can programmatically call imp.wakeup schedules a function to run in a certain amount of time.. - In this case we’re telling the imp to run blink function again in 1 second Need to call blink() once to get things started
  • #20: Have participants run this code Their device should disconnect after 30 seconds or a minute, and will require a power cycle to get it back online Explain the single thread of execution - imp has lots of things to do.. Running your code is only 1 of them - Infinite loops steal the thread of execution and don’t allow anything else to happen - one of the background tasks the imp does is manage it’s wifi connection + connection to the server - if you steal the thread of execution, it can’t do that, so it looks disconnected to the imp servers.
  • #21: Make sure button is connected to GND and PIN1 Buttons connected to VIN and PIN1 could potentially damage the imp
  • #22: Things to point out local makes a local variable - if you try and use “state” outside of function onButton, it won’t work We configure button as a DIGITAL_IN_PULLUP - this means that when the button is not pressed, it will be 1, and when the button is pressed, it will be 0 Configuring a DIGITAL_IN allows you to pass an optional second parameter of a callback function - This function gets called whenever the state changes - more info on next slide
  • #23: Explain how event driven languages differ from non-event driven languages (like Arduino’s processing) Explain the power of event driven processing - When there is nothing to do, we can spin down clocks, etc - You don’t need to check variables 100 times a second (the OS manages all of that for you) We’ll see a few more examples of event driven programming + callbacks throughout the rest of the class
  • #24: Point out where the Agent URL can be found If they can’t find it, they likely need to select a device (slide 12)
  • #25: Explain what query parameters are, how we can check to see if a specific query parameter was included, and how to access it Make sure to point out that we’re doing no validation here, which means someone could pass in state=pineapple if they wanted to resp.send returns a response back to whoever made the request – it is VERY important that every incoming request send a response back i.e. make sure you don’t have code paths that don’t send a response
  • #26: agent.on catches a message from the agent the parameter for ledHandler comes from the device.send in the previous slide Next slide explains flow better
  • #27: Describe how basic message passing between the agent and device works device.send(“messageName”, data) is caught by agent.on(“messageName”, callback) - The callback MUST have 1 parameter - The data from device.send will be the parameter passed into the callback It’s a lot easier to explain flow of data with this slide than the previous two code slids
  • #28: Similar to previous example, but data flow is going the other way
  • #29: Talk about request verbs (GET, PUT, POST, etc) We’re making a get since it’s the simplest request Agents can make any kind of request Talk about sync vs async requests This code example also introduces inline functions (lambda functions)
  • #30: Same data flow as slide (22) but with the device -> agent code as well
  • #31: If people finish early they can try these They should have all of the required hardware The exercises get increasingly difficult as you go down the list
  • #32: Getting Started Guide – essentially what we just went through Also has a “Next Steps” section, which is worth looking at API Documentation – complete Electric Imp API spec Squirrel Standard Library – complete docs for Squirrel standard library Reference Code – great place to find classes for various web services and hardware components Community blog – Technical articles, and community contributed projects and blog posts Forums – The place to ask questions about the Electric Imp platform, and building connected devices