##Send Command to Photon from Octoblu
The Particle has an awesome API that lets you expose functions within the firmare to the API.
You can use the following Octoblu Photon API template and the example code to turn a relay on and off via Octoblu!
https://app.octoblu.com/bluprints/import/bc3b126e-fd7b-41cd-b74c-f187c092b892
int relay = D3; // use D7 to control the onboard LED
void setup() {
pinMode(relay, OUTPUT);
Spark.function("relay", relay);
}
void loop() {
}
// The function exposed in the spark API
int relay(String command){
if(command == "on"){
digitalWrite(relay, HIGH);
}else if(command == "off"){
digitalWrite(relay, LOW);
}
}
You can register webhooks as events with the Particle Spark API using the Particle CLI.
To get the Particle CLI set up go here.
If you create a JSON file called hook.json with this..
{
"event": "some_event_name",
"url": "https://triggers.octoblu.com/flows/yourTriggerWebHook",
"requestType": "POST",
"json": {
"data": "{{SPARK_EVENT_VALUE}}"
},
"mydevices": true
}
Then in the terminal type this ..
particle webhook create hook.json
Add this in your Particle Photon firmware...
Spark.publish("some_event_name", String("hello world!"));
You can now send data to a trigger in Octoblu whenever you please!
This enables you to create complex electronics projects with the added benefit of simple two-way communication between Octoblu and your Photon. Add this to existing code and now your boring old IoT-less project has access to all the things!
For general codeless IO programming try The Tentacle which lets you configure pins remotely. Think of it like the tinker app but for Octoblu!