CxD Archive
Internet of Things Project
Internet of Things Project
  • IoT Project Background
  • IoT Project Challenge
  • IoT Project Outline
    • 1-1 Smartphone Research
    • 1-2 Smart Thermostat Research
    • 1-3 Smart Device Research
    • 1-4 Introduction to Photon Kit
    • 1-5 Build Smart Lightbulb
    • 1-6 Generate Project Ideas
    • 1-7 Build Smart Thermostat
    • 2-1 Evaluate Project Ideas
    • 2-2 Plan User Research
    • 2-3 Compile Research Data
    • 2-4 Construct Personas
    • 2-5 Construct Journey Map
    • 2-6 Define Value Proposition
    • 2-7 Define Design Requirements
    • 3-1 Generate Solution Ideas
    • 3-2 Evaluate and Refine Solution Ideas
    • 3-3 Create System Model of Solution
    • 3-4 Create Wireflow for Web App
    • 3-5 Create Storyboard for Solution
    • 3-6 Evaluate Solution Design
    • 3-7 Present Project Proposal
    • 4-1 Track Progress and Issues
    • 4-2 Build Smart Device
    • 4-3 Create Photon App
    • 4-4 Create Web App
    • 4-5 Conduct Integration Testing
    • 4-6 Create Product Demo Video
    • 4-7 Create Product Marketing Website
    • 5-1 Evaluate Smart Device and Web App
    • 5-2 Evaluate Product Marketing Website
    • 5-3 Improve Solution Based on Evaluations
    • 6-1 Create Project Poster
    • 6-2 Present Project to Public
    • 6-3 Write Personal Reflection
  • References for Wiring & Coding
    • Creating Circuits
    • Wiring Programming Language
    • Particle Cloud
    • Hello World App for Photon
    • LED Light
    • Push Button
    • Micro OLED Display
    • Humidity and Temp Sensor
    • Speaker
    • Servo Motor
    • Motion Sensor
    • Magnetic Switch
    • Potentiometer
    • Photocell
    • Moisture Sensor
    • Accelerometer
    • RFID Reader
    • Fingerprint Scanner
    • GPS Receiver
    • Camera
    • Microphone
    • Force Sensitive Resistor
    • Keypad
    • Continuous Rotation Servo Motor
  • Glossary
  • Updated Project Guidebook
  • Updated Code Guidebok
Powered by GitBook
On this page
Export as PDF
  1. IoT Project Outline

4-3 Create Photon App

Previous4-2 Build Smart DeviceNext4-4 Create Web App

Last updated 6 years ago

Your team needs to create a Photon app that will run on your smart device to perform the functions envisioned in your team’s solution design.

You will need to use online references (such as: , , , etc.) to figure out how to program a Photon app that will read data from your device’s inputs, analyze the data to make decisions, send commands to your device’s outputs, and interact with your device’s web app by sharing data through the Internet (via ).

The Photon app will be created in the online code editor using the . You will need to plan out your Photon app, and then program it in stages, testing and revising the code as you go.

YOUR TASK

  1. Plan out Photon app

      • If your team's system model does NOT clearly and correctly describe the functions and interactions of the parts, then revise your system model to be accurate.

  2. Code Photon app - Part 1 (add libraries, declare global variables, code setup() function, test each part)

    1. CREATE NEW APP: Login to your team's Particle Build account. Create a new app, and give it a title that makes sense. Particle Build will automatically insert a blank setup() function and blank loop() function for your new app.

    2. LIBRARIES: Determine whether any parts (such as: OLED display, servo motor, etc.) need a special code library added to the Photon app. If so, then search for the necessary library in Particle Build, and add the library to your Photon app. Particle Build will insert an #include statement for the library at the very top of your app code.

    3. GLOBAL VARIABLES: Declare (create) global variables near the top of your app (after any library #include statements but before the setup() function). Each variable must have a unique name. You get to decide what the names are, but try to use names that will make sense to someone else reading your code. Remember that variable names cannot have spaces (and cannot be a keyword in the programming language).

      • Create global variables for each part’s I/O pin. This I/O pin number should have been recorded by the person who wired and connected the parts. If necessary, visually verify the I/O pin number used by the part on your Photon device.

      • Create global variables for any object variables that are needed. Parts that needed a special code library usually require an object variable.

      • Create global variables to store any other data (numbers, text, etc.) that your app needs to track or needs to share with your web app.

    4. SETUP( ) FUNCTION: Within the setup() function, add code needed to prepare your device for use. Remember that the setup() function runs only one time when the device is first started (or is reset).

      • Set the pinMode() for each input or output. Be aware that some parts do not need a pinMode() statement.

      • Parts that needed a library (such as: OLED display, etc.) may need certain commands added within the setup() function. For example, the OLED display needs oled.begin(); added within the setup() function.

      • Add any other commands that you want to occur one time when the device is first started. For example, if you are using an LED light, you may want to either turn it on (or turn it off) when the device is first started.

      • Later (in step 3 below), you will add Particle Cloud statements within the setup() function, so your Photon app can send data to your web app and/or receive commands from the web app.

    5. TEST EACH PART: Within the loop() function, add temporary code to test each part, in order to verify the part is wired correctly and working. This "test" code should make the part do something simple that you can observe or verify in some way.

      • OUTPUT examples: turn on LED (or make it blink), have speaker produce a tone, make servo motor rotate, display message on OLED screen, etc.

      • INPUT examples: turn on built-in D7 LED when button is pushed (and turn off when button is released), turn on built-in D7 LED when motion detected (and turn off when no motion detected), display measurement from accelerometer on OLED screen, etc.

      • After adding the "test" code, "flash" (download) the app onto your Photon device to run it. If the part doesn't work properly, then first check your code in the Photon app to make sure it is complete and accurate. For example, does the pin number you listed for the part's global variable match the actual pin that it is wired to? Did you set the correct pinMode() for the part? If necessary, revise the code, and re-flash the Photon app to your device. If you've verified the code is correct but the part is still not working, then check whether the part is wired correctly to the Photon device.

      • Once the parts are tested to work properly, the "test" code can be removed from the loop() function (but do not remove the libraries, global variables, or code in the setup() function) – or the "test" code can be turned into comments by typing two forward slashes at the beginning of each line of "test" code: //

  3. Code Photon app - Part 2 (code loop() function, code any custom functions, add Particle Cloud statements)

    1. LOOP( ) FUNCTION: More details coming soon...

    2. CUSTOM FUNCTIONS: More details coming soon...

    3. PARTICLE CLOUD: More details coming soon...

Use your team’s to identify all the inputs and outputs connected to your smart device, the function of each part, and the interactions between parts of the system.

Answer these . Don't worry about creating "code" for the answers – answer in plain English.

Once the smart device, Photon app, and web app have all been completed, to verify they work together properly.

system model
questions to help plan out your Photon app
conduct integration testing
References for Wiring & Coding
Photon Experiment Guide
Wiring Framework Reference
Particle Cloud
Particle Build
Wiring programming language
Photon App