Thursday, December 8, 2016

Progress with Light Sensor Concept (Week 12 Continued)

In a previous post, I played with code and created a Particle function that made LEDs flicker like a candle whenever the function was called. While experimenting, I had the idea of creating a flickering paper circuit fireplace, or a candle, that might be triggered by data connected to a light sensor.  Ultimately, I wanted to figure out a way to do this as a step toward creating a wifi-connected book containing artwork brought to life with real-time data.

1.  ThingSpeak channel documenting light sensor             2.  Photon connected to a paper circuit

Unlike the Goofy Photon Servo Notifier which used the Particle.subscribe feature (linked to data in my Google Calendar) the function illustrated below is triggered via a web hook that I set up in ThingSpeak, which only calls the function if a sensor on another Photon reports a low light level.

PROOF OF CONCEPT (Video demo)

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, my Photon started logging the photocell 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). 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.


Friday, December 2, 2016

Circuit Idea and Photon Progress (Week 12 Reflection)

Week 12 Reflection and FINAL PROJECT

As my previous posts have explained, I'm in the process of learning about the Photon in hopes of creating a wifi-connected book that will use paper circuitry triggered by data to help tell a story.  This won't be completed until the spring.  Since we were required to create some sort of project and video for this class, I took a detour from the work I'm most interested in to focus on another application of the Photon.

Rather than creating a formal lesson plan, I created an instructional video and a functioning model of a project that might be adapted for use in a classroom or other venue.


Before I launch into my final project, here's a teaser of what the circuit in my wifi-connected book might look like.  This is only a prototype to help me think about where the leads need to go, as I begin to plan my book's layout.

I'll need to overlay the copper tape with conductive fabric in areas where the circuit will continue between the pages of the book.  I'll also need to determine precisely where I'll be poking the holes that I'll be sewing through, to bind the signatures between the covers.  My first book model will most likely be constructed from binder's board.  Once I've received some feedback and determined that everything works the way I want it to, my hope is to create wooden covers with recesses engraved with a laser cutter or CNC router.


FINAL PROJECT:

While thinking about how I might be able to use a servo in my book, I hunkered down and created a gadget that I'm calling the Goofy Photon Servo Notifier.  I've designed a basic paper pop-up book structure that folds flat once the servo is removed.

The pop-up structure folds flat.

In theory, I could add something similar to the inside of the pages of the wifi-connected book I'll eventually make and a reader could pop the servo in.




VIDEO DEMO


QUICK OVERVIEW:

Taking inspiration from this "Study Budy" project, I started experimenting with the Particle.subscribe feature.  The basic premise of the project is to have a new event on a Google Calendar trigger a servo connected to a Photon, in order to alert a student that there is something they should be working on.

Basically, Particle.subscribe is a piece of code that tells a Photon to listen for an specific event that you can give a very specific name to; a unique name will reduce the likelihood of other people subscribing to your event (and triggering your device). When the Photon receives word that the event is taking place (a new task added to your Google Calendar, for example), the Photon carries out a unique function referred to as an "event handler" that basically uses data to trigger an action on a physical object. (Note:  In my earlier servo exploration, I used a different method to trigger a servo.)

To start, I logged into my If Then Than That account.  I created a new Applet, selecting Google Calendar as my If THIS.  I selected the first box depicted below, which reads "Any event starts".

I selected "Particle" for my Then THAT.

The trickiest part was figuring out what to put into the configuration boxes.  I named my event something rather unoriginal:  New_Event.  I will be changing this name in my Applet and in my code to make it more unique.

I left the box below this (for optional data) empty.  After saving the Applet, I uploaded my code and added a new event to my Google calendar to test it out.

CODE

While the "Study Budy" project got me going in the right direction, helping me to explore a new way to trigger events on my Photon, the code I wrote for my project was completely different.

For starters, my code requires only one Photon.  My code also periodically detaches the servo to reduce jitter, and resets the servo to a zero position after 45 seconds.  If a user didn't want the servo to reset automatically, they could comment out the code and manually press the reset button.  Here is a screenshot of the code I wrote.  Here's the link to my code.


RESOURCES TO LEARN MORE:

One juicy resource that I found this week was Daragh Burn's IoT course outline. a plan for an Internet of Things class that will be offered by Carnegie Mellon starting in January 2017.  It was there that I got a useful explanation of the differences between Particle.publish and Particle.subscribe that I'd only just begun to understand.

To view more Photon resources, please visit my Diigo bookmarks tagged "Photon."

STANDARDS/ ASSESSMENT RUBRIC

Here are the standards that my wifi-connected book project (and this project) will address.
Here is a corresponding rubric that could be used.

NEXT STEPS:

I plan to continue experimenting with Particle functions to animate artwork in a book, based upon sensor data.

My next step is to log in to the Particle-Raspberry Pi beta in order to see whether I can get my Photon to interact with data pulled from a Raspberry Pi  I'm not certain that learning how to do this will actually help me create my physical book, but it will help me continue my investigation into the Internet of Things.