5. By 2020, there will be 50 billionBy 2020, there will be 50 billion
computers on earthcomputers on earth
Moore's Law: They will keep getting
smaller, cheaper and faster
6. Many of these devices willMany of these devices will lacklack useruser
interfacesinterfaces
Often communicating via low-energy wireless
protocols
7. They will rely on sensors to understandThey will rely on sensors to understand
their environmenttheir environment
Heat, temperature, sound, light, smoke, steam,
LiDAR...
8. And form "the edge" of large internetAnd form "the edge" of large internet
connected systems...connected systems...
9. These computers will often take theThese computers will often take the
form ofform of MicrocontrollersMicrocontrollers
Small computers specializing in real-time
operations
10. Increasingly we are using webIncreasingly we are using web
development tools and techniques todevelopment tools and techniques to
program these devicesprogram these devices
GitHub, Containers, Node.js etc
11. "Hybrid" developers will be needed who"Hybrid" developers will be needed who
are capable of understanding theseare capable of understanding these
systemssystems
Are you up for the task?
12. Full-Stack Developer, n: Person who isFull-Stack Developer, n: Person who is
comfortable programming both frontcomfortable programming both front
and back-end systemsand back-end systems
Full-Stack Developer, n: Person who isFull-Stack Developer, n: Person who is
paid once to do the work of four peoplepaid once to do the work of four people
(actual definition)
(technical definition)
Now that we can run Linux on our IoT devices, full-stack
developer takes on a whole new meaning!
18. A Microcontroller (MCU) is aA Microcontroller (MCU) is a smallsmall
computercomputer with awith a processorprocessor,, memorymemory,,
andand programmable input/outputprogrammable input/output
peripherals.peripherals.
They specialize in real-time behavior
They are used everywhere (automotive, industrial etc)
They are contained on an integrated circuit
21. Example UsesExample Uses
Home appliances
Industrial
Automotive
Drones
Everything, really
Anywhere you need cheap, highly reliable, event-
driven computers
22. Sensors attached to PCB boards are the "user
interface" for microcontrollers, lets learn how that
works
24. LibMRAALibMRAA FirmataFirmata
Firmata is a protocol for
communicating with
microcontrollers from software
on a computer (based on MIDI).
LibMRAA is a C/C++ library
with bindings to javascript &
python to interface with the
IO on Galileo, Edison etc.
We can now talk to our microcontrollers without writing
assembly language!
26. Digital and Analog SensorsDigital and Analog Sensors
Communication for basic data
27. Digital I/ODigital I/O
GPIO: General purpose input / output
High or Low depending on voltage level (1 or 0)
Frequently come in "ports" of 8 (a byte)
Can alternate as analog pins (but not both!)
Good for LEDs, buttons, buzzers, relays
28. Example: LED with MRAAExample: LED with MRAA
var m = require('mraa'); //require mar
//write the mraa version to the console
console.log('MRAA Version: ' + m.getVersion());
//LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
var myLed = new m.Gpio(13);
myLed.dir(m.DIR_OUT); //set the gpio direction to output
var ledState = true; //Boolean to hold the state of Led
periodicActivity(); //call the periodicActivity function
function periodicActivity()
{
//if ledState is true then write a '1' (high) otherwise write a '0' (low)
myLed.write(ledState?1:0);
ledState = !ledState; //invert the ledState
//call the indicated function after 1 second (1000 milliseconds)
setTimeout(periodicActivity,1000);
}
29. Analog I/OAnalog I/O
GPIO pins for digital can often be used for analog
Good for sensing light, temperature, sound etc
We must translate digital signals to analog signals
(PWM)
30. Pulse Width ModulationPulse Width Modulation
Pulse Width Modulation, or
PWM, is a technique for
getting analog results with
digital means. Digital control
is used to create a square
wave, a signal switched
between on and off.
Useful for servos (robotics, drones), audio and more
Let us turn a jaggy thing into a squiggly thing
34. "Serial" aka "Time Division Multiplexed""Serial" aka "Time Division Multiplexed"
Data is sent one chunk at a time based on a clock signal
Errors and noise occur when sending data via wire
requiring safeguards.
35. : Inter-integrated circuit
: Serial peripheral communication
(SCI): Universal asynchronous receiver/ transmitter
I²C
SPI
UART
Want more? Read this.
Common Serial CommunicationsCommon Serial Communications
37. // How to write to the Seeed LCD Screen
// NOTE: You *MUST* plug the LCD into an I2C slot or this will not work!
var Cylon = require('cylon');
function writeToScreen(screen, message) {
screen.setCursor(0,0);
screen.write(message);
}
Cylon
.robot({ name: 'LCD'})
.connection('edison', { adaptor: 'intel-iot' })
.device('screen', { driver: 'upm-jhd1313m1', connection: 'edison' })
.on('ready', function(my) {
writeToScreen(my.screen, "Ready!");
}).start();
Cylon SyntaxCylon Syntax
38. SPISPI
“ A master sends a clock signal, and
upon each clock pulse it shifts one bit out
to the slave, and one bit in, coming from
the slave. Signal names are therefore SCK
for clock, MOSI for Master Out Slave In,
and MISO for Master In Slave Out.
I²CI²C
“ SCL and SDA. SCL is the clock line.
It is used to synchronize all data
transfers over the I2C bus. SDA is the
data line. The SCL & SDA lines are
connected to all devices on the I2C
bus.
Common Synchronous ProtocolsCommon Synchronous Protocols
39. SPISPI
Faster, 1-20MHz
Requires 3+ physical lines
Less worry about "noise"
All lines are unidirectional
Chip-select lines required
I²CI²C
Slower, 100 - 400MHz
2 lines only, easier to wire
Noise an issue
All lines are bi-directional
For chaining devices
Common Synchronous Protocols ComparedCommon Synchronous Protocols Compared
Many microcontrollers support both
protocols.
40. (or SCI) uses two wires (TX / RX) to transmit data(or SCI) uses two wires (TX / RX) to transmit data
asynchronously at an agreed-upon baud rateasynchronously at an agreed-upon baud rate
UARTUART
Uses start and stop bits for primitive error correction
Buad Rate: Transmission speed (9600, 115200 etc)
Long history, common on PCs before USB
41. UART NotesUART Notes
UART is a hardware module, not a protocol
Can run in a
Slow: 9 - 56 kHz (vs. 1 - 20 MHz for SPI)
Used for sending ASCII characters
Also: Keyboard, LCD monitor data
synchronous mode called USART