Broken Promises

A talk on Node.js, asynchronous I/O, Promises and the Raspberry Pi
(not necessarily in that order)


by Jean-Claude Batista  /@jcbatista

Microcontrollers or Microprocessors?

Analog vs Digital IO

First, let's talk GPIOs...

GPIOs

On the Pi, GPIOs are like a regular files
we can write to and read from...


# Set up GPIO 7 (Pin 26 in board) and set it to output

echo 7  > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio7/direction

# Write output
echo 1 > /sys/class/gpio/gpio7/value

# Clean up
echo 7 > /sys/class/gpio/unexport
						

Using the Pi-GPIO module in Node.js

Node.JS

Introducing
Party.js

Paul, the *REAL* question should have been ...


How many Web Developers does it take to stop the party!?

curl -H "Content-Type: application/json" -d '{"action":"stop"}' http://192.168.31.161:8080/api/party
					

Words of Wisdom

“This can’t be understated. Writing asynchronous code is hard”

Bottom Line

It's OKAY, to use {mostly} synchronous GPIO calls for your Internet of Things related project

But ...

If you go asynchronous all the way, learn how to use Promises ...

Fin

Thanks for listening!