Connected Devices: 002

My life long technology dream has come true: I made a clap-light.

Using the Philips Hue API and accessing a device’s microphone through the browser, a user can toggle a pair of Hue bulbs on and off. Using p5.js, the browser routinely polls the microphone, checking for a sound reading above 0.1. When loud enough, the page makes an AJAX call to change the on/off state. The new state is then saved so it can be toggled.

The full code is available on Github; a snippet below shows the web-interface component.

 

Connected Devices: 001

In preparation for one of my planned 100-day exercises, I set up a server to store and provide environmental data: light, sound and temperature recorded on my roof. All of the data is stored in a simple JSON object maintained on the server itself. I plan on moving the data storage to MongoDB so that the data is preserver in the event that my server goes down. The full code is available on Github, while snippets are provided below.

Server:

Get Requests:

  • /latest  returns the latest environmental reading.
  • /all returns all the readings.
  • /sensor/:sensor (light, sound, temperature) returns all the readings from a particular sensor.

Post Requests:

  • /addReading creates a new timestamped reading with data point for each sensor.
  • /resetReadings erases all existing readings.