39
Building Internet Connected T hings with the Particle Photon Stephen Harrison @TinamousSteve [email protected] www.Tinamous.com www.ThingySticks.com

Building internet connected things with the particle photon

Embed Size (px)

Citation preview

Page 1: Building internet connected things with the particle photon

BuildingInternet Connected Things with theParticle

PhotonStephen Harrison

@TinamousSteve [email protected]

Page 2: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

About Me• Freelance Software Developer (C#)• Founder of Tinamous.com• An Internet of Things platform• Integrates really nicely with the Particle.io API

• Recently launched ThingySticks.com• Open source hardware based on the Photon/Electron.• Boards are for sale on Tindie

• Rubbish at PowerPoint

Page 3: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

The Plan…• Make some stuff Steve!

• Pizza Delivery Indicator Light

• Bring a Photon into the world• 10 Print “Hello World”• Particle Cloud Functions• 20 Print “Hello Interwebz”• Complete the Pizza Delivery Indicator• In-depth hardware• Some other Things I’ve made with the Photon

Page 4: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Make some stuff Steve!• PDD – Pizza Driven Development.• Lets make an Internet Connected Pizza Delivery

Indicator:• Tower of lights• Particle Relay Shield• Photon• 12V DC Power Supply• Victim Volunteer.

Page 5: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Pizza Delivery Indicator• Tower of Lights needs 12V to work.• A Relay is an Electro-Mechanical switch that

isolates the logic from the nasty:• High voltage (DON’T PLAY WITH MAINS!)• High current• AC or DC

• 1 Relay per light• Common Ground

Page 6: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Relay Wiring

Page 7: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

What is a Photon?• A small micro-controller….• With Wi-Fi on-board • Made By Particle• Connects to the Particle Cloud• Saves us from MQTT(s), HTTP(s), etc…

• Programmed like an Arduino

Page 8: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Page 9: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Bring a Photon into the world AKA: The demo guaranteed to go wrong!

• Register at Particle.io and download the App• Unbox (the difficult part)• Connect USB Power lead• Add the Photon in the App

Page 10: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Add the Photon

Page 11: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Select the Photon

Page 12: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Select your Wi-Fi access point

Page 13: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Let the magic happen…

Page 14: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Tada….

Page 15: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Hello Tinker

Page 16: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Build.Particle.io

Page 17: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

10 Print “Hello World”

Page 18: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

The Real Magic: Particle Cloud• Particle.publish()

• Publish events with data• Rate limited (1Hz) – Be kind to Particle• 255 bytes max.• Public by default

• Particle.subscribe()• Photon listens for events from Particle.publish()• Public by default • MY_DEVICES only works with private publish.

• Particle.variable()• Variables that can be read via the internet

• Particle.function()• Internet accessible code

Page 19: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

20 Print “Hello Interwebz”

Page 20: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Pizza Delivery IndicatorComplete the project.• Flash the code!• Uses the Relay Shield Library• Exposes Particle.functions:• NoPizza• PizzaIsHere• LetsEat

Page 21: Building internet connected things with the particle photon

Test the Lights:Tinamous Integration

@TinamousSteve - www.Tinamous.com

Page 22: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Pizza Indicator Setup

Page 23: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Particle functions and subscriptions

Page 24: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Helpers

Page 25: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Button Code

Page 26: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Safe ModeProbably the most useful thing you will learn this evening

• Hold BOTH buttons down• Release RESET• Wait for the LED to blink MAGENTA• Release SETUP

From: https://docs.particle.io/guide/getting-started/modes/photon/

Page 27: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Input modes

Page 28: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Pro-tip - Be careful when Flashing!

It’s very easy flash the wrong device!!!

Also, don’t use google image search of something funny to add to a “Flashing” slide.

Page 29: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

In-depth HardwareWi-Fi on-board24 “Pin” device (With and without headers)STM32 (ARM Cortex M3) 120MHz, 1M Flash, 128k RAM2047 bytes “EEPROM”18 “Digital” GPIO, 9 PWM-able. 20mA per pin max.8 ADC inputs (12 bit, 0-4095, 0.8mv)2 DACs2 SPI & 1x I2CI2S & CANUSB2x SerialFCC & CE certified.80mA @ 5V. 80uA Deep sleep.3x power options (3v3, Vin, USB)Cost: About $19 + …See also P0 and P1From: https://docs.particle.io/datasheets/photon-datasheet/

Page 30: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Bonus Features• Analog input (A0-A7) can be used as GPIO (digital in/out)• DAC and WKP are also analog in (A6 & A7).• Tx and Rx can be used for digital IO and PWM.• USB connection is a serial port – great for debugging.• You can control the RGB LED – also great for debugging.• Up-to 5 Wi-Fi credentials stored. • Soft AP – user configurable.• Automatic/Semi and Manual cloud connect.• Most pins 5v tolerant (Not Analog inputs!)

Page 31: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Bonus: The ElectronCellular. 2G or 3G.

Avoid 2G – Slow, wont be around for long, not much $$ saving.

Top 24 pins match the Photon.

Additional 12 pins for extra IO.

Battery and on-board charger .

Basic plan $2.99/month per device.

Most Photon code can run on the Electron.

Cost: $69 + …

From: https://docs.particle.io/datasheets/electron-datasheet/

Page 32: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Environment Sensor

Page 33: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Thermocouple

Page 34: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Filament Storage Box

https://github.com/Tinamous/HumidityMonitor

Page 35: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Low Voltage Lighting Controller

https://www.hackster.io/TinamousSteve/iot-low-voltage-lighting-controller-e7957d

Page 36: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Jedi Light Switch

Page 37: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Some Things I’ve made:Roll Pole

Page 38: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

What I (probably) didn’t cover• Local IDE.• Node command line util• Huge parts of the language• Low power modes• Webhooks• IFTTT integration• Azure integration

Page 39: Building internet connected things with the particle photon

@TinamousSteve - www.Tinamous.com

Useful Resources• Particle.io• SparkFun.com and Adafruit.com• CoolComponents.co.uk and skpang.co.uk – UK Suppliers.• DirtyPcbs.com and OSHPark.com• hackster.io/tinamoussteve • Tindie.com• Tinamous.com • ThingySticks.com • @TinamousSteve• Lets go Green!!! Bzzzzzz• Thank You!!!!