{"_id":"563cfe55d8f2d20d00448d14","__v":30,"version":{"_id":"56009c571503430d007cc954","__v":1,"project":"56009c541503430d007cc951","createdAt":"2015-09-22T00:09:59.421Z","releaseDate":"2015-09-22T00:09:59.421Z","categories":["56009c581503430d007cc955"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"56009c581503430d007cc955","__v":41,"project":"56009c541503430d007cc951","version":"56009c571503430d007cc954","pages":["56009c591503430d007cc957","56009c7f0c703d19009531c6","56009c911503430d007cc958","56009c9c1503430d007cc95a","56009ca697f69f1700f21a55","56009cb81503430d007cc95c","56009cc80c703d19009531c8","56009ce18c0c9d0d00dcaef8","56009cf21503430d007cc95e","56009cfe81a9670d006d146a","56009d0781a9670d006d146c","56009d1d81a9670d006d146e","56009d271503430d007cc960","56009d581503430d007cc962","56009d651503430d007cc964","56009d711503430d007cc966","56009d8d81a9670d006d1472","56009d970c703d19009531ce","56009da197f69f1700f21a5a","56009dae3aa0520d00da0bff","56009db83aa0520d00da0c01","56009dcf81a9670d006d1474","56009ddb3aa0520d00da0c04","56009de597f69f1700f21a5d","56009df80c703d19009531d0","56009e0d8c0c9d0d00dcaefa","56009e213aa0520d00da0c08","56009e2c81a9670d006d1476","5600a4971503430d007cc97d","561c5a6b01e1c417001f54f1","561d9845d712bc0d00777b72","563cfe55d8f2d20d00448d14","563d09d9913e650d00b65f92","566b3b8614c22f1900f00b7b","568ff8529ebef90d00872887","568ff8ed4719c119002ce637","5690922a208b910d00ed77b4","56a93fd311d0390d00a3d29a","56b25cc8a5a1020d00cf4cc3","56b25f02147e900d00d64990","56b291ed4e71701700232ea4"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-22T00:10:00.324Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"project":"56009c541503430d007cc951","githubsync":"","user":"5564f227f0f70f0d00a9ab20","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-06T19:24:05.826Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What are we doing?\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/akYzyfQRO6Kq34AflmcU_Screen%20Shot%202016-03-18%20at%202.52.19%20PM.png\",\n        \"Screen Shot 2016-03-18 at 2.52.19 PM.png\",\n        \"1204\",\n        \"1056\",\n        \"#436171\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n**NOTE: This guide was updated, the Particle.IO API is now natively supported in Octoblu, this will work with any Particle.io product!**\n\nThe Particle Photon is a wonderful $20 WiFi enabled Arduino board. It has a cloud based coding environment that lets you push Arduino firmware to it over the web. \n\nParticle has a nifty API built in to their firmware editor that lets you expose functions as REST endpoints, meaning we can easily trigger them over the web.\n\nIf you put \"Particle.function(\"test_function\", test_function); \" in your Setup function, then you can now use REST to control that function.\n\nExample via a terminal:\n```\ncurl https://api.particle.io/v1/devices/{{coreID}}/test_function \\\n  -d access_token={{access_token}} \\\n  -d params=on\n```\n\nThis tutorial will go over getting your photon set-up and controllable through app.octoblu.com\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Import & Configure the Octoblu Flow\"\n}\n[/block]\n### 1. Sign up for an [app.octoblu.com](http://app.octoblu.com) account and familiarize yourself with the demo flow if you already haven't. [Getting Started with Octoblu](https://www.youtube.com/watch?v=UAT1F8hF-nI)\n\n### 2. Retrieve your **coreID** (also called Device ID) and access_token from** build.particle.io**\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/nzGGbJYkTvSlq26SjoDC_Screen%20Shot%202015-07-28%20at%2011.52.29%20AM.png\",\n        \"Screen Shot 2015-07-28 at 11.52.29 AM.png\",\n        \"358\",\n        \"706\",\n        \"#08aae9\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/KYbk8XtqTxaOelDpWB0r_Screen%20Shot%202015-07-28%20at%2011.52.50%20AM.png\",\n        \"Screen Shot 2015-07-28 at 11.52.50 AM.png\",\n        \"330\",\n        \"293\",\n        \"#f37405\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n###  3. [Add the Particle.IO Channel to your account through the Things Page](https://app.octoblu.com/node-wizard/add/56b383e10ff23fc2acbf477c)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/dFPwf2QwSru5AVDiMSI8_Screen%20Shot%202016-03-18%20at%202.32.39%20PM.png\",\n        \"Screen Shot 2016-03-18 at 2.32.39 PM.png\",\n        \"1002\",\n        \"966\",\n        \"#174c7b\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n### 4. Import and Configure the Sample Flow with your Device ID\n\nhttps://app.octoblu.com/bluprints/import/b97677a6-f1ef-4be3-8e16-5c1f6aab072f\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/l6bzOSGFSOu41ecYZ6qp_Screen%20Shot%202016-03-18%20at%202.35.58%20PM.png\",\n        \"Screen Shot 2016-03-18 at 2.35.58 PM.png\",\n        \"2036\",\n        \"1218\",\n        \"#42a9e4\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n## Deploy!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/utx4VC2ZTV6FPKYXE6um_Screen%20Shot%202015-11-06%20at%2012.51.15%20PM.png\",\n        \"Screen Shot 2015-11-06 at 12.51.15 PM.png\",\n        \"144\",\n        \"125\",\n        \"#14548c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n### 5. Once the flow is deployed, click the trigger named \"on\" , the onboard LED of the Photon should turn on. Likewise, if you click the \"off\" trigger it turns off.\n\nBut how!?\n\nThe value we set in the Particle.IO channel nodes is the string that will be passed to your Photon's function - where it looks for string commands as such:\n\n```\nint test_function(String command){\n    if(command == \"on\"){\n        digitalWrite(led, HIGH);\n    }else if(command == \"off\"){\n        digitalWrite(led, LOW);\n    }\n}\n```\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set-Up Photon and Flash Firmware\"\n}\n[/block]\n1. Follow the Particle [Getting Started Guide](https://docs.particle.io/guide/getting-started/start/photon/)\n\n2. Once your Photon is connected go to [build.particle.io](http://build.particle.io) and login with the credentials you made during set-up\n3. Click \"Create New App\" in the code section \"< >\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/KNpzMRIcSEicbzcfovAZ_Screen%20Shot%202015-11-06%20at%2012.34.55%20PM.png\",\n        \"Screen Shot 2015-11-06 at 12.34.55 PM.png\",\n        \"361\",\n        \"236\",\n        \"#04acec\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n4. Copy this code to your new app (firmware)\n\n```\nint led = D7; // use D7 to control the onboard LED\n\n\nvoid setup() {\n  pinMode(led, OUTPUT);\n  Particle.function(\"test_function\", test_function); \n}\n\nvoid loop() {\n}\n\n// The function exposed in the spark API\n\nint test_function(String command){\n\n    if(command == \"on\"){\n        digitalWrite(led, HIGH);\n    }else if(command == \"off\"){\n        digitalWrite(led, LOW);\n    }\n\n}\n```\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/rxkDgXvWTXWHK3KcuiQm_Screen%20Shot%202015-11-06%20at%2012.35.22%20PM.png\",\n        \"Screen Shot 2015-11-06 at 12.35.22 PM.png\",\n        \"1439\",\n        \"829\",\n        \"#70b1ce\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n5. Click the Lightning Bolt icon to flash your firmware. Note: Your Photon needs to be connected to wifi for this to work.\n6. Your Photon will flash purple for awhile, this means its receiving firmware. When it stops it means you're done with this part! \n\n\n\n## ADAVANCED: Send Messages TO Octoblu from the Photon \n\n\n\nYou can register webhooks as events with the Particle Spark API using the Particle CLI.\n\n[To get the Particle CLI set up go here.](https://docs.particle.io/guide/tools-and-features/cli/#installing)\n\nIf you create a JSON file called hook.json with this..\n\n```\n{\n    \"event\": \"some_event_name\",\n    \"url\": \"https://triggers.octoblu.com/flows/yourTriggerWebHook\",\n    \"requestType\": \"POST\",\n    \"json\": {\n        \"data\": \"{{SPARK_EVENT_VALUE}}\"\n    },\n    \"mydevices\": true\n}\n\n```\n\nThen in the terminal type this ..\n\n```\nparticle webhook create hook.json\n```\n\nAdd this in your Particle Photon firmware...\n\n```\nSpark.publish(\"some_event_name\", String(\"hello world!\"));\n```\n\nYou can now send data to a trigger in Octoblu whenever you please! \n\nThis 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!\n\nFor general codeless IO programming try [The Tentacle](https://www.hackster.io/redaphid/code-free-iot-with-arduino-and-the-tentacle-on-octoblu) which lets you configure pins remotely. Think of it like the tinker app but for Octoblu!","excerpt":"","slug":"particleio","type":"basic","title":"Particle.IO"}
[block:api-header] { "type": "basic", "title": "What are we doing?" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/akYzyfQRO6Kq34AflmcU_Screen%20Shot%202016-03-18%20at%202.52.19%20PM.png", "Screen Shot 2016-03-18 at 2.52.19 PM.png", "1204", "1056", "#436171", "" ] } ] } [/block] **NOTE: This guide was updated, the Particle.IO API is now natively supported in Octoblu, this will work with any Particle.io product!** The Particle Photon is a wonderful $20 WiFi enabled Arduino board. It has a cloud based coding environment that lets you push Arduino firmware to it over the web. Particle has a nifty API built in to their firmware editor that lets you expose functions as REST endpoints, meaning we can easily trigger them over the web. If you put "Particle.function("test_function", test_function); " in your Setup function, then you can now use REST to control that function. Example via a terminal: ``` curl https://api.particle.io/v1/devices/{{coreID}}/test_function \ -d access_token={{access_token}} \ -d params=on ``` This tutorial will go over getting your photon set-up and controllable through app.octoblu.com [block:api-header] { "type": "basic", "title": "Import & Configure the Octoblu Flow" } [/block] ### 1. Sign up for an [app.octoblu.com](http://app.octoblu.com) account and familiarize yourself with the demo flow if you already haven't. [Getting Started with Octoblu](https://www.youtube.com/watch?v=UAT1F8hF-nI) ### 2. Retrieve your **coreID** (also called Device ID) and access_token from** build.particle.io** [block:image] { "images": [ { "image": [ "https://files.readme.io/nzGGbJYkTvSlq26SjoDC_Screen%20Shot%202015-07-28%20at%2011.52.29%20AM.png", "Screen Shot 2015-07-28 at 11.52.29 AM.png", "358", "706", "#08aae9", "" ] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/KYbk8XtqTxaOelDpWB0r_Screen%20Shot%202015-07-28%20at%2011.52.50%20AM.png", "Screen Shot 2015-07-28 at 11.52.50 AM.png", "330", "293", "#f37405", "" ] } ] } [/block] ### 3. [Add the Particle.IO Channel to your account through the Things Page](https://app.octoblu.com/node-wizard/add/56b383e10ff23fc2acbf477c) [block:image] { "images": [ { "image": [ "https://files.readme.io/dFPwf2QwSru5AVDiMSI8_Screen%20Shot%202016-03-18%20at%202.32.39%20PM.png", "Screen Shot 2016-03-18 at 2.32.39 PM.png", "1002", "966", "#174c7b", "" ] } ] } [/block] ### 4. Import and Configure the Sample Flow with your Device ID https://app.octoblu.com/bluprints/import/b97677a6-f1ef-4be3-8e16-5c1f6aab072f [block:image] { "images": [ { "image": [ "https://files.readme.io/l6bzOSGFSOu41ecYZ6qp_Screen%20Shot%202016-03-18%20at%202.35.58%20PM.png", "Screen Shot 2016-03-18 at 2.35.58 PM.png", "2036", "1218", "#42a9e4", "" ] } ] } [/block] ## Deploy! [block:image] { "images": [ { "image": [ "https://files.readme.io/utx4VC2ZTV6FPKYXE6um_Screen%20Shot%202015-11-06%20at%2012.51.15%20PM.png", "Screen Shot 2015-11-06 at 12.51.15 PM.png", "144", "125", "#14548c", "" ] } ] } [/block] ### 5. Once the flow is deployed, click the trigger named "on" , the onboard LED of the Photon should turn on. Likewise, if you click the "off" trigger it turns off. But how!? The value we set in the Particle.IO channel nodes is the string that will be passed to your Photon's function - where it looks for string commands as such: ``` int test_function(String command){ if(command == "on"){ digitalWrite(led, HIGH); }else if(command == "off"){ digitalWrite(led, LOW); } } ``` [block:api-header] { "type": "basic", "title": "Set-Up Photon and Flash Firmware" } [/block] 1. Follow the Particle [Getting Started Guide](https://docs.particle.io/guide/getting-started/start/photon/) 2. Once your Photon is connected go to [build.particle.io](http://build.particle.io) and login with the credentials you made during set-up 3. Click "Create New App" in the code section "< >" [block:image] { "images": [ { "image": [ "https://files.readme.io/KNpzMRIcSEicbzcfovAZ_Screen%20Shot%202015-11-06%20at%2012.34.55%20PM.png", "Screen Shot 2015-11-06 at 12.34.55 PM.png", "361", "236", "#04acec", "" ] } ] } [/block] 4. Copy this code to your new app (firmware) ``` int led = D7; // use D7 to control the onboard LED void setup() { pinMode(led, OUTPUT); Particle.function("test_function", test_function); } void loop() { } // The function exposed in the spark API int test_function(String command){ if(command == "on"){ digitalWrite(led, HIGH); }else if(command == "off"){ digitalWrite(led, LOW); } } ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/rxkDgXvWTXWHK3KcuiQm_Screen%20Shot%202015-11-06%20at%2012.35.22%20PM.png", "Screen Shot 2015-11-06 at 12.35.22 PM.png", "1439", "829", "#70b1ce", "" ] } ] } [/block] 5. Click the Lightning Bolt icon to flash your firmware. Note: Your Photon needs to be connected to wifi for this to work. 6. Your Photon will flash purple for awhile, this means its receiving firmware. When it stops it means you're done with this part! ## ADAVANCED: Send Messages TO Octoblu from the Photon You can register webhooks as events with the Particle Spark API using the Particle CLI. [To get the Particle CLI set up go here.](https://docs.particle.io/guide/tools-and-features/cli/#installing) 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](https://www.hackster.io/redaphid/code-free-iot-with-arduino-and-the-tentacle-on-octoblu) which lets you configure pins remotely. Think of it like the tinker app but for Octoblu!