Catalog / Particle Photon Cheatsheet
Particle Photon Cheatsheet
A comprehensive cheat sheet for the Particle Photon, covering its key features, setup, coding, and cloud integration. This guide provides a quick reference for developers working with the Photon for IoT projects.
Photon Basics & Setup
Hardware Overview
Particle Photon: A small Wi-Fi enabled development kit for creating connected projects. Key Features:
|
Setting up the Photon
npm install -g particle-cli |
Important Pins
D0-D7: |
Digital I/O pins |
A0-A7: |
Analog input pins |
TX/RX: |
Serial communication pins |
VIN: |
Voltage Input (3.6V - 12V) |
3V3: |
3.3V output |
GND: |
Ground |
Coding with the Photon
Basic Structure
|
Digital I/O
|
Sets the mode of a digital pin (INPUT, OUTPUT, INPUT_PULLUP) |
|
Writes HIGH or LOW to a digital pin |
|
Reads the value (HIGH or LOW) from a digital pin |
Example: |
|
Analog I/O
|
Reads the analog value (0-4095) from an analog pin |
|
Writes an analog value (PWM) to a digital pin (0-255) |
Example: |
|
Timing
|
Pauses the program for a specified number of milliseconds |
|
Returns the number of milliseconds since the program started running |
|
Returns the number of microseconds since the program started running |
Cloud Functions & Variables
Cloud Functions
Cloud functions allow you to call functions on your Photon from the Particle Cloud API.
Accessing the Function via the API: |
Cloud Variables
Cloud variables allow you to read variables from your Photon via the Particle Cloud API.
Accessing the Variable via the API: |
Publishing Events
Publishing events allows you to send data from your Photon to the Particle Cloud.
|
You can also specify the event’s privacy:
Options are |
Networking & System
Checking Connection Status
|
Returns |
|
Returns |
System Functions
|
Resets the Photon. |
|
Puts the Photon in DFU (Device Firmware Upgrade) mode for flashing firmware via USB. |
|
Puts the Photon in a low-power sleep mode. |
Error Handling
Use |