(for web developers)
Our goal today is to understand what is going on here
Moore's Law: They will keep getting smaller, cheaper and faster
Often communicating via low-energy wireless protocols
Heat, temperature, sound, light, smoke, steam, LiDAR...
Small computers specializing in real-time operations
GitHub, Containers, Node.js etc
Are you up for the task?
(actual definition)
(technical definition)
Now that we can run Linux on our IoT devices, full-stack developer takes on a whole new meaning!
What can we do with microcontrollers?
Gamification of drones and robots
Sign language translation glove
Smart chicken tender
Makes tiny cheese
They specialize in real-time behavior
They are used everywhere (automotive, industrial etc)
They are contained on an integrated circuit
*Other stuff may vary
*Printed Circuit Board
PCB with microcontroller pinout
Anywhere you need cheap, highly reliable, event-driven computers
Sensors attached to PCB boards are the "user interface" for microcontrollers, lets learn how that works
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!
Johnny-Five
Communication for basic data
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);
}
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.
Let us turn a jaggy thing into a squiggly thing
Has a ground wire, power wire and 3-analog wires
// "ADXL335"
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
io: new Edison()
});
board.on("ready", function() {
var accelerometer = new five.Accelerometer({
controller: "ADXL335",
pins: ["A0", "A1", "A2"]
});
accelerometer.on("change", function() {
console.log(" x : ", this.x);
console.log(" y : ", this.y);
console.log(" z : ", this.z);
});
});
Communication for fancy data
Data is sent one chunk at a time based on a clock signal
Errors and noise occur when sending data via wire requiring safeguards.
// 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();
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.
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.
Many microcontrollers support both protocols.
Uses start and stop bits for primitive error correction
Buad Rate: Transmission speed (9600, 115200 etc)
Long history, common on PCs before USB
Test Time: Xadow Main Board with ATmega32U4
Lets find: SPI, UART, I2C, Analog I/O
Test Time: Find GPIO, Analog, PWM, UART, SPI
Test Time: Find SPI, UART, I2C, USB, PWM, GPIO, Clock lines