In this first tutorial, you'll become familiar with your team's IoT electronics kit.
The goals of this first tutorial are to help you:
Understand the features of your Photon circuit board (pins, ports, buttons, LED lights)
Identify the other components in your Photon kit and their purposes (inputs, outputs, connectors, and cables)
Understand how to create electronic circuits by connecting components to the Photon circuit board (using power pins, I/O pins, jumper wires, and breadboard)
This guidebook is tailored for an IoT electronics kit called the SparkFun Inventor's Kit for Photon, which will simply be referred to as the Photon kit.
SparkFun is a company that sells products to help people build and program electronics devices. Photon is a Wi-Fi enabled microcontroller (small computer) from a company called Particle that sells IoT hardware and services that help inventors and other companies create their own IoT products.
SparkFun created its own Photon kit by incorporating the Photon P1 microcontroller into an easy-to-use circuit board and packaged it with a set of inputs, outputs, wires, and other parts to help you start inventing your own IoT devices. It is also possible to purchase additional parts (sensors, motors, etc.) that can be used with this Photon kit.
NOTE: Your instructor may have provided you with a different IoT electronics kit. If your IoT kit is programmed using Arduino or Wiring, then you may still be able to use (or modify) the tutorials and references in this coding guidebook.
WI-FI NETWORK: Photon devices are relatively easy to setup to connect to home Wi-Fi networks or mobile hotspot devices. Photon devices running firmware version 0.7.0 or higher can be setup to connect to WPA2 Enterprise Wi-Fi networks (such as those typically found in schools, universities, and corporations). Teachers may need to coordinate with their school's IT administrator to follow Particle's guide to WPA2 Enterprise Setup.
GOAL: Identify the other components in your Photon kit and their purposes (inputs, outputs, connectors, and cables)
TASK: Review the information below, and then complete this assignment by finding each component in your Photon kit & identifying its name and function.
Your Photon kit includes these physical inputs, which can be connected to your circuit board:
Push Buttons – detects if button is being pushed (kit has red, yellow, green & blue buttons)
Trimpot Dial – detects position of dial (can be turned clockwise or counter-clockwise)
Motion Sensor – detects if something is moving in nearby environment
Magnetic Switch – detects if something is open or closed (such as door, window, etc.)
Photocell (Light Sensor) – measures amount of light in environment
Humidity & Temperature Sensor – measures relative humidity & temperature of air
Soil Moisture Sensor – measures amount of moisture in soil (or similar material)
Accelerometer – measures acceleration or tilt in 3 dimensions; can also detect taps or bumps
The following is not a standard part of the Photon kit, but your teacher may have added it:
Ultrasonic Sensor – measures distance to nearest object
Your Photon kit includes these physical outputs, which can be connected to your circuit board:
LED Lights – produces light (kit has red, yellow, green & blue LED lights)
Speaker – produces sound (tone) at any frequency from 20Hz to 20kHz
Servo Motor – rotates to any angle from 0° to ~180°
Micro OLED Display – displays text and simple graphics in monochrome
Your Photon kit includes these components to help connect inputs and outputs to your circuit board:
Breadboard – provides additional pins to help connect and power your inputs and outputs
Jumper Wires – help connect inputs and outputs to pins on breadboard and circuit board
Resistors – help limit electric current for certain inputs or outputs (such as LED lights, etc.)
Your Photon kit will include one or more cables to provide power to your circuit board:
USB to Micro-USB Cable – powers circuit board by connecting to USB port or charger
9V to Barrel Jack Adapter – powers circuit board by connecting to 9V battery
Only one power source (Micro-USB or Barrel Jack) needs to be connected.
USB to Barrel Jack: SparkFun sells a USB to Barrel Jack Adapter cable which is a great alternative to the cables included in the kit. This cable connects a USB port (computer, charger, etc.) to the barrel jack. If using this cable, the Photon's VIN pin will supply ~5 volts.
The product page for the SparkFun Inventor's Kit for Photon provides links to details about each part included in the kit. (Click the "Includes" tab on the product page to see the links to the parts.)
GOAL: Understand how to create electronic circuits by connecting components to the Photon circuit board (use of power pins, I/O pins, jumper wires, and breadboard)
TASK: Review the information below to begin to understand how to use the components in your Photon kit to create electronic circuits, and answer the questions in this document.
Each input and output connected to your Photon circuit board must form an electronic circuit, which is a continuous path that conducts electricity from the positive (+) terminal of a power source, through the input or output, and back to the negative (-) terminal of the power source.
An electronic circuit is a special type of electric circuit. Here are the two key differences:
The current in an electric circuit could be only a few volts, or it could be hundreds of volts (or more). Some electric circuits operate on direct current (DC), while others use alternating current (AC).
Electronic circuits always operate on low voltage direct current.
Electric circuits transfer electricity to components (such as: light bulbs, motors, etc.) that transform some of the electrical energy into other types of energy (such as: light, motion, etc.) in order to perform a useful physical task.
Electronic circuits have special components with semiconductors that use electrical signals to process and transfer information.
The electronic circuits in your IoT devices will actually do both: they will perform a useful physical task by processing and transferring information.
Each input and output connected to your Photon should have its own circuit – i.e., its own separate path to conduct electricity without having to travel through another input or output. These are called parallel circuits. Using parallel circuits has these advantages:
Parallel circuits ensure each input and output receives its full voltage from the circuit board (because the voltage is not being split with another input or output on the same circuit).
Parallel circuits allow each input and output to be independently controlled by the circuit board.
For each parallel circuit, most of the conductive path will consist of jumper wires and the breadboard (via its internal metal strips). The rest of the conductive path will include the input or output itself (via its internal wires or circuitry) and the circuit board (via its power pins, I/O pins, and other internal circuitry).
AVOID SHORT CIRCUITS: Do NOT try this, but if you were to connect a wire directly from the positive side of a power source to the negative side (without any input or output in the middle), you would create a short circuit that leads to excessive current flow.
Short circuits can possibly: burn up your wire, damage your circuit board, damage your USB power supply, damage or drain your battery, etc.
The power for your circuits will be supplied by the Photon circuit board, which itself must receive power from another source.
The Photon circuit board can receive power through either one of its power supply ports:
Barrel Jack: A barrel jack adapter can be plugged in to provide power from an external supply such as a battery, outlet, etc.
Micro-USB: A Micro-USB cable can be plugged in to provide power from a computer's USB port or a USB charger.
CHOOSE ONE: Only one power source (barrel jack or Micro-USB) needs to be connected to the Photon circuit board.
CAUTION: Be careful when plugging or unplugging the Micro-USB cable to avoid breaking the Micro-USB port on the Photon. Be sure the correct side of the cable is facing up.
The Photon circuit board can supply power to inputs and outputs through these pins:
I/O Pins: These pins can supply 3.3 volts (by reducing the incoming voltage from the USB or barrel jack power source). Only certain inputs and outputs will get their power from an I/O pin.
3.3V: This pin supplies 3.3 volts (by reducing the incoming voltage from the USB or barrel jack power source).
V-USB: If a power source is connected to the Micro-USB port, this pin supplies ~5 volts.
VIN: If a power source is connected to the barrel jack, this pin supplies the same voltage as the external source (which could range from 4.5-15 volts). For example, if a 9V battery with adapter were plugged into the barrel jack, this pin would supply 9 volts. If a USB adapter were plugged into the barrel jack, this pin would supply ~5 volts.
GND: This pin acts as the ground (negative terminal) when powering inputs and outputs. The Photon circuit board has 3 available GND pins.
CAUTION: The inputs and outputs in your Photon kit have different power requirements:
Certain inputs and outputs (such as: micro OLED display, etc.) require only 3.3 volts of power – using a higher voltage could damage these components.
Certain inputs and outputs (such as: servo motor, etc.) require 5 volts or more – using a lower voltage could prevent these components from working.
A breadboard has a large number of additional pins (plugs) that are useful for connecting inputs and outputs to your circuit board. First, your inputs and outputs connect to pins in the breadboard, and then jumper wires are used to help connect those breadboard pins to specific pins on your circuit board.
One purpose of using a breadboard is it allows you to connect multiple inputs and outputs to some of the same power supply pins – while still ensuring each input and output has its own parallel circuit.
For example, the Photon circuit board has only one V-USB pin to supply 5V of power, but your device might have multiple inputs and outputs that require 5V – so the breadboard can be used to allow these components to share this one V-USB pin.
To understand how a breadboard works and is used, you need to understand the "anatomy" of your breadboard. The image on the left below shows an external view of your breadboard, while the image on the right shows what's inside the breadboard:
First, let's examine the external view of your breadboard. While the breadboard might seem like one large rectangle of holes, it actually consists of 4 smaller rectangular sections:
On the far left is a power rail consisting of two columns of pins: one column is labeled as positive (+) and the other column is labeled as negative (-).
In the left center is a set of terminal strips consisting of rows of pins: each row is numbered (from 1-30) and the pins within each row are lettered (from A-E).
In the right center is another set of terminal strips consisting of rows of pins: each row is numbered (from 1-30) and the pins within each row are lettered (from F-J). Notice there is a divide between the left set of terminal strips and the right set of terminal strips.
On the far right is another power rail consisting of two columns of pins: one column is labeled as positive (+) and the other column is labeled as negative (-).
Inside the breadboard, there are metal strips underneath the pin holes. The image of the internal view shows these metal strips – and makes it easier to visualize the 4 separate sections of the breadboard. (The red arrows are pointing to the metal strips under the power rails.)
When you plug a wire into a breadboard pin, the wire makes contact with the specific metal strip underneath that pin hole location. If another wire is plugged into another pin along the same metal strip, the metal strip will allow electricity to be conducted between the wires. If the wires are touching different metal strips, then the wires are NOT connected to each other.
These metal strips inside the breadboard act like additional wires. While these metal strips may be "hidden" inside your breadboard, they become part of your circuits as you connect inputs and outputs.
Here are some examples to help explain further how the terminal strips and power rails work:
If you were to plug a wire into pin A of row 1 and then plug another wire into pin E of row 1, these wires would be connected because they're touching the same metal strip.
If you were to plug a wire into pin A of row 1 and then plug another wire into pin F of row 1, these wires would NOT be connected because they're touching different metal strips. Remember that the terminal strip rows on the left and right sides are separate from each other.
If you were to plug a wire into pin A of row 1 and then plug another wire into pin A of row 2, these wires would NOT be connected because they're touching different metal strips. Remember that the terminal strip rows are separate from each other.
If you were to plug a wire into a pin of the positive (+) column of the left power rail and then plug another wire into another pin in the positive (+) column of the left power rail, these wires would be connected because they're touching the same metal strip.
If you were to plug a wire into a pin of the positive (+) column of the left power rail and then plug another wire into a pin of the negative (-) column of the left power rail, these wires would NOT be connected because they're touching different metal strips.
If you were to plug a wire into a pin of the positive (+) column of the left power rail and then plug another wire into a pin of the positive (+) column of the right power rail, these wires would NOT be connected because they're touching different metal strips.
Certain inputs or outputs can be connected directly to pins on the Photon circuit board. However, in most cases, you'll need to use the breadboard to help connect some (or all) of your inputs and outputs.
Each input or output has at least 2 wires that must be connected (one for positive and the other for negative). Some inputs or outputs have additional wires used for sending or receiving signals.
The wires for inputs and outputs connect to the pins of different terminal strips. Then jumper wires are used to connect each of these terminal strips directly (or indirectly) to its corresponding power pin or I/O pin on the Photon circuit board.
Here are two basic rules for connecting inputs and outputs to the breadboard:
Different wires for the same component should NOT connect to pins in the same terminal strip. For example, the temperature sensor has 4 wires that should connect to different terminal strips.
Jumper wires are the only exception to this rule: a jumper wire is supposed to share a terminal strip with a wire of an input or output in order to connect it directly (or indirectly) to its corresponding power pin or I/O pin on the circuit board.
Wires for different components should NOT connect to pins in the same terminal strip. For example, the wires of a push button and LED light should connect to different terminal strips.
Resistors are the only exception to this rule: a resistor is supposed to share a terminal strip with a wire of an input or output because the purpose of the resistor is to limit the amount of electric current flowing through the input or output to prevent damaging them. The LED lights and photocell (light sensor) in your Photon kit require the use of resistors.
Think of each power rail like a power strip you might use at home or school: you first have to plug the power strip into an outlet, and then the power strip can provide power to other devices plugged into it. Since your breadboard has two power rails (far left and far right), it's like having two power strips.
Some IoT devices won't need to use either power rail on the breadboard. However, most IoT devices will use one of the power rails. A few IoT devices might need to use both power rails (e.g., if your device has multiple components needing 3.3V as well as multiple components needing 5V).
In order to use a power rail on the breadboard to supply power to inputs or outputs, you must first use jumper wires to connect the power rail to power pins on the Photon circuit board:
The positive (+) column of the power rail would connect to a positive (+) pin on the Photon board (such as the 3.3V pin, V-USB pin, or VIN pin – do NOT connect a power rail to an I/O pin).
The negative (-) column of the power rail would connect to a negative (-) pin on the Photon board (i.e., any one of the GND pins).
Sometimes you might only need to connect the negative (-) column of a power rail. This is because every input and output needs to connect back to GND (and there are only 3 GND pins available on the Photon board). Since certain inputs and outputs use their I/O pin as their voltage source (+), sometimes it might not be necessary to connect and use the positive (+) column of the power rail.
Once a power rail has been connected to power pins on the Photon circuit board, you can use jumper wires to connect multiple inputs and outputs to this same power rail:
Use a jumper wire to connect the terminal strip for the ground (-) wire of the input or output to any negative (-) pin in the power rail.
For inputs or outputs that don't get power from their I/O pin, use a jumper wire to connect the terminal strip for the power (+) wire of the input or output to any positive (+) pin in the power rail (as long as the power rail is supplying the correct voltage required by the input or output).
All of this information about using jumper wires and the breadboard to connect inputs and outputs to the circuit board will really only make sense once you have hands-on experience building some practice devices. Tutorials 2, 3, and 4 will help provide that experience.
SparkFun has tutorials that provide more information about circuits and breadboards:
GOAL: Understand the features of your Photon circuit board (pins, ports, buttons, LED lights)
TASK: Review the information below as you examine the circuit board in your Photon kit, and answer the questions in this document.
The SparkFun Photon kit contains a printed circuit board (PCB) that incorporates the Particle Photon P1 microcontroller, which will act like the “brain” of your IoT device. This circuit board also has various pins, ports, buttons, and LED lights. SparkFun refers to this circuit board as the Photon RedBoard (because of its color).
You can connect various inputs (such as: sensors, buttons, etc.) and outputs (such as: motors, lights, etc.) to the pins on the circuit board to create a device. Then you can control your device by programming an app that will run on the Photon microcontroller.
Photon P1 Microcontroller
Input/Output Pins
Power Supply Ports and Pins
Buttons
LED Lights
A microcontroller is a small computer on a single integrated circuit that contains a processor (CPU), memory, storage, and programmable input/output pins. The Photon microcontroller also has an integrated Wi-Fi chip and antenna, which makes it great for IoT devices.
CPU: 32-bit 120Mhz ARM Cortex M3
Memory: 128KB RAM
Storage: 1MB Flash
Wi-Fi: 2.4GHz 802.11b/g/n
Compared to the tech specs of a "regular" computer, a microcontroller is much less powerful – it has a slower processor, less memory, and less storage. This is because microcontrollers are used in devices that have dedicated functions (such as: automobile engine control systems, medical devices, office machines, appliances, etc.). These dedicated devices typically don’t require as much computing power.
A microcontroller is controlled by its firmware, which acts as its operating system. Periodically, your Photon will need to update its firmware. If this is necessary, the firmware update will occur automatically when you download a new app to your Photon over Wi-Fi.
A microcontroller is designed to store only one app, which will run automatically. If you need to change your Photon device's app, the new app has to be downloaded over Wi-Fi (and will replace the old app). You will have to code the apps for your Photon – though you'll get some practice and help to do so.
When the Photon is powered on, it will automatically try to connect to Wi-Fi (using a programmed list of Wi-Fi network logins). Once the Photon is connected to Wi-Fi, it will automatically try to connect to Particle Cloud, which is a cloud service that Particle provides for all of its microcontroller devices. All of the Photon's internet communications are routed through Particle Cloud.
Particle Cloud can be used to:
Code and store all your different Photon device apps (using online Particle Build code editor)
Update the app stored on your Photon device
Update the firmware on your Photon device
Send and receive data between your Photon device app and your web app
Manage your Photon device remotely
The Photon circuit board has numerous I/O pins used to connect various inputs (such as: sensors, buttons, etc.) and outputs (such as: motors, lights, etc.). These I/O pins have small plugs that allow you to easily connect (and disconnect) the wires for inputs and outputs.
The circuit board has a set of digital pins labeled as: D0, D1, D2, D3, D4, D5, D6, D7. Digital pins are used to connect inputs or outputs that use binary values (such as: HIGH or LOW, etc.). For example:
Digital Input: A motion sensor detects either "motion" or "no motion."
Digital Output: A LED light can be set to be "on" or "off."
The circuit board has a set of analog pins labeled as: A0, A1, A2, A3, A4, A5. Analog pins are used to connect inputs or outputs that use a range of values (such as: 0-255, etc.) For example:
Analog Input: A photocell can detect a range of values based on the amount of light measured.
Analog Output: A speaker can produce a range of tones that have different frequencies.
TWIN PINS: Analog pins A2, A3, A4, and A5 are each represented by two pins on the Photon board. The duplicate pins are labeled as: SS/A2, SCK/A3, MISO/A4, MOSI/A5.
If you use one of these pins, you should not use its twin. For example, you could connect a part to either A2 or SS/A2 (choose only one), but you could not connect two different parts to these twin pins at the same time.
Any analog pin can be used for analog inputs. However, only certain pins can be used for analog outputs. (Confusingly, some of the pins capable of analog output are labeled as digital pins.)
The Photon uses pulse-width modulation (PWM) to make a digital output signal (which has only two values: HIGH or LOW) act like an analog output signal (which has a range of values). Certain outputs (such as: speaker, servo motor, etc.) require a connection to an I/O pin capable of PWM.
These Photon pins can be used as analog outputs using PWM: A4, A5, D0, D1, D2, D3, RX, TX, WKP.
The circuit board also has I/O pins with "special" labels. Most of these "special" pins are used to connect with parts that require specific data communication protocols:
SPI Pins: SS/A2, SCK/A3, MISO/A4, MOSI/A5
SPI stands for "Serial Peripheral Interface"
For example, a Micro OLED display would be connected using the SPI pins.
I2C Pins: SDA/D0, SCL/D1
I2C stands for "Inter-Integrated Circuit"
For example, an accelerometer would be connected using the I2C pins.
UART Pins: RX, TX
UART stands for "Universal Asynchronous Receiver-Transmitter"
For example, a fingerprint scanner would be connected using the UART pins.
However, any of these "special" pins can also be used as "regular" I/O pins.
The Photon circuit board must receive power from an external power source (such as: USB, battery, or outlet). The Photon circuit board will then supply power to any connected inputs and outputs.
The Photon circuit board can receive power through either one of its power supply ports:
Barrel Jack: A barrel jack adapter can be plugged in to provide power from an external supply such as a battery, outlet, etc.
Micro-USB: A Micro-USB cable can be plugged in to provide power from a computer's USB port, USB charger, etc.
POWER ON/OFF: The Photon circuit board does not have an "on/off" switch. As soon as a power source is connected to the USB port or barrel jack, the Photon will power on and start running. To turn off the Photon, you have to disconnect its power source.
The Photon circuit board can supply power to connected inputs and outputs through these pins:
I/O Pins: These pins can supply 3.3 volts (by reducing the incoming voltage from the USB or barrel jack power source). Certain inputs and outputs (but not all) get their power from an I/O pin.
3.3V: This pin supplies 3.3 volts (by reducing the incoming voltage from the USB or barrel jack power source).
V-USB: If a power source is connected to the Micro-USB port, this pin supplies ~5 volts.
VIN: If an external power supply is connected to the barrel jack, this pin supplies the same voltage as the external supply (which could range from 4.5-15 volts). For example, if a 9V battery adapter were plugged into the barrel jack, this pin would supply 9 volts. If a USB adapter were plugged into the barrel jack, this pin would supply ~5 volts.
GND: This pin acts as the ground (negative terminal) when powering inputs and outputs. The Photon circuit board has 3 available GND pins.
A breadboard can be used to connect multiple inputs and outputs to the same power supply pins. Section 1.3 of this tutorial will explain how this works.
The Photon circuit board has two built-in buttons used for special purposes:
Mode: This button is used to switch your Photon between different modes such as: Connected, Listening, Safe, and Device Firmware Upgrade. Normally, you will not need to use this button.
Reset: This button can be used to restart your Photon – forcing it to reconnect to the internet and restart its device app. Occasionally, you might use this button to restart your app.
The Photon circuit board has three built-in LED lights:
Power: This red LED indicates the Photon is receiving power (from the barrel jack or USB). If this LED is off, then no power source is connected (or the Photon device is damaged).
RGB: This LED changes its color and activity pattern to indicate the current mode and connection status of the Photon device.
D7: This blue LED is connected to the D7 pin and can be controlled by your Photon device app, which can be helpful for testing purposes.
Whenever you connect a power source to the Photon (or restart it using the Reset button), the Photon should power on, connect to Wi-Fi, connect to Particle Cloud, and start running its device app.
During this startup process, the RGB color will change from green to cyan (light blue) and the RGB activity will change from "blinking" (fast blinking) to "breathing" (slow blinking).
Whenever the device app or firmware on the Photon is updated, the RGB will blink pink during the download and installation. Once the update is complete, the Photon will automatically restart itself.
If your Photon device displays one of these other RGB patterns, then the Photon has encountered an issue or has been placed into a different mode. Consult your teacher to troubleshoot your device.
The SparkFun Photon RedBoard Hookup Guide provides more details about this circuit board.
RGB Color
RGB Activity
Photon Device Status
Green
Blinking
Trying to connect with Wi-Fi
Cyan (light blue)
Blinking
Connected to Wi-Fi + Trying to connect with Particle Cloud
Cyan (light blue)
Breathing
Connected to Wi-Fi and Particle Cloud (device app running)
Pink
Blinking
Receiving new device app or new firmware over Wi-Fi
RGB Color
RGB Activity
Photon Device Status
Green
Breathing
Connected to Wi-Fi – but could not connect to Particle Cloud
Blue (dark blue)
Breathing
Could not connect to Wi-Fi
Blue (dark blue)
Blinking
Listening Mode (ready to add new Wi-Fi login)
Pink
Breathing
Safe Mode (does not run device app)
White
Breathing
Device's Wi-Fi module has been turned off
Orange-Yellow
Blinking
DFU Mode (ready for manual device firmware upgrade)
Red
Blinking
Firmware crash error