Showing posts with label ThingHTTP app. Show all posts
Showing posts with label ThingHTTP app. Show all posts

Thursday, December 8, 2016

Artwork Brought to Life with Photon Sensor Data (#IoT)


Art Brought to Life with Photon Sensor Data


I'm making progress toward my goal of creating a wifi-connected book that uses data to help tell a story.  As a test of concept, I created a Thing HTTP app and a "React" app in ThingSpeak to trigger a Particle function (on one Photon) based upon readings from a Photocell (attached to a second Photon).  To get started, I created a ThingSpeak channel and a Particle web hook by following this tutorial.

Once I created the web hook and connected my Photon to a light sensor, the Photon started logging the data on ThingSpeak.  In order to make the data more useful, I modified the Photon code in the tutorial by adding the following lines to the loop, just above the line containing the Write API key for the ThingSpeak Channel.)

value = map(value, 0, 4096, 0, 255); //maps values
value = constrain(value, 0, 255); //constrains values between 0 and 255.  


Next, I uploaded this code to a second Photon, connecting the Photon to a paper circuit using alligator clips. Lastly, I created the ThingHTTP and React apps.


The React app allowed me to set up a trigger related to the data.  I set it up so that a reaction happens any time the sensor picks up a value of 150 or greater (when it's cloudy or dark and the resistance increases) or 50 and under (when it's bright or sunny) . The ThingHTTP app allowed me to post an HTTP request to Particle, triggering the Particle function that illuminates the owl's eyes and the candle flame.



I later added LEDs to simulate falling snow.




Friday, October 28, 2016

Photocell Data in ThingSpeak Can Trigger a Servo on Photon (#IoT)



In the process of learning about how the Internet of Things works, as I attempt to create a wifi-connected book, I wanted to figure out how to get sensor data from a ThingSpeak channel to trigger a Particle function, even if the data I'm using isn't super juicy.

In an earlier post, I set up my own private ThingSpeak channel and connected it to the Particle API via a web hook.  Since then, I've updated my code so that it maps the value of the analog data, constricting the readings within a range of 0-255 instead of 0-4095.
While playing around with ThingSpeak this time, I used the React and ThingHTTP apps to use the data from the photocell to trigger a servo connected to a Photon. The React app allowed me to set up a trigger related to the data.  I set it up so that a reaction would happen any time the sensor picked up a value of 30 or under (or when it was sunny and the resistance dipped).  Then, the ThingHTTP app allowed me to post an HTTP request to Particle, in much the same way you would if using the Maker Channel on If Then Than That (IFTTT).

This breakthrough is exciting, because I have figured out how to control a physical object using my own data.  Now, if I wanted to, I could use the data from a photocell to trigger a piezo tune, a servo, or an LED light show, based upon whether it's sunny or dark outside.  I'm not yet sure how I'll use this new knowledge, but it's mine nonetheless!