On a Particle Photon, expose a cloud variable that shows whether a gate/door is open or closed. The PHP script grabs that variable and shows it on a webpage.StepsStep 0: Setting UpStep 1: Getting your Access Token and Device ID
Make an access token. In a terminal with the CLI installed, run
particle token create --never-expires. Take note of the token it outputs, like putting it into a password manager.Find your device ID: In a terminal, run
particle list. The value in
[square brackets] is the device ID. Take note of this too.
Paste the code into the Particle web IDE and click ⚡ to flash the code.Upload the PHP page to your web server. (As this process can vary between providers and computers, I won't provide exact instructions.) Replace
YOUR_DEVICE_ID with your device ID and
YOUR_BIG_LONG_ACCESS_TOKEN with your big, long access token. Leave everything else as is unless you want to customize the page.
- Connect a door sensor to pin D2 on your Photon and any GND pin. Give the board power, and you're done!
Using a configuration profile, you can make a "app" with the webpage! Here's how:
There are two things you need to change:
- On line 29, change the URL to point to where you deployed the webpage.
- On line 35, change the ID to a random UUID, to ensure that updates overwrite the existing profile. You can generate one at https://uuidgenerator.net.
- Download the profile file.
- Open it in any text editor.
- Get the profile to your device. You can do it via email, a webpage, or by deploying it through Apple Configurator.
- If it asks if you want to allow downloading a configuration profile, click Allow.
- Open Settings.
- Under your name, you should see a "Profile Downloaded" option. Tap it.
- Tap "Install" in the corner.
- Enter your passcode.
- Tap "Install" twice more. Note that the app icon will be the iOS default app icon, unless you customize it.
If you want to edit the profile more, such as customizing the name or adding an icon, open it in Apple Configurator.