[OBSOLETE] Particle Photon (Spark Core) Relay

So I wanted to put together a relay set up to control some outside things (strobe lights, triggering the talking ghost) for Halloween. I was going to use the ST shield but I hate having to do a device type and smartapp to run it. I put together some code for intergrading a Photon (which is only $19) and ST.

3 Likes

Here is the smartapp I wrote to go along with this relay. Its late and i wrote it quick for tomorrow. I will take a video once i have it set up and will make the code look nicer after i get some sleep, let me know if someone sees and issue as well. But here it is for anyone looking for something like this.

Heres what happens with the app.

  1. The motion sensor will be on the stairs leading up to my door to start the event
  2. Switch3 (my security light and front porch) will turn off
  3. Switch1 (my talking ghost and strobe lights, ran by Photon Relay) will activate
  4. Switch2 (my talking tombstone, ran by Photon Relay) will activate 4 seconds after switch1
  5. Once door is open switch1 and switch2 will turn off and Switch3 will turn back on
  6. next event wont run if door is open, once it’s closed the next sequence can take place.

Have fun and be safe tomorrow.

Last thing for me tonight. I made some eagle projects for my Photon, one for the 8 Relay Switch if anyone is looking for something simple, its not for high voltage but for triggering things like push buttons (like all my cheap Home Depot and Big Lots holiday things).

https://oshpark.com/profiles/TomForti

Here’s the video. Works great, scares the kids perfectly!

2 Likes

Updated Code. Now i am using an eagle board.

Hey @Tomforti, I’ve forked your code to set up a ST relay of my own for the Christmas Lights this year, and have noticed that your code has no battery status indicator.

According to Particle, it’s possible to get the Voltage, State of Charge (Percentage), and alert status of a battery attached via the Battery Shield, using the SparkFunMAX17043 Library.

https://learn.sparkfun.com/tutorials/photon-battery-shield-hookup-guide

I’m a total noob when it comes to programming in both Particle, and in SmartThings, so would be interesting to know if you or anyone else has done anything like this since you originally posted the thread last year.

Obviously, if I’m running a 3v string of christmas lights through the Photon with a LiPo battery, it would be nice to know if that battery needs a charge before it dies for good.

So far, I’ve combined the two codes on the Particle build, so that I can trigger the Photon Outputs from ST, and I can also view the battery percentage over the API, but I have no understanding of how to get that value back into SmartThings via the Device Handler.

My battery percentage value is:

double soc = 0; // Battery State of Charge (Percentage)

Can also be obtained on an API call: https://api.particle.io/v1/devices/[deviceid]/soc?access_token=[accesstoken]

{
“cmd”: “VarReturn”,
“name”: “soc”,
“error”: null,
“result”: 85.33984375,
“coreInfo”: {
…removed…
}
}

Just in case anyone would find this useful, this modified version of tomforti app.

This poles the relay state and makes sure the device is online, and shows when its offline, same install procedure. This uses particle web variables to report back to the device handler, I’m Sure the code can be improved but works fine!

Also would be relatively easy to expand to include sensors/switches/battery monitoring on the cores Analogue pins to report back to ST, via particle variables.

2 Likes

@kn1ght1 nice work. I’ll have to pull this into my photon fan code too.