SOCI: Social Alarm Clock

Group: Jess and Maria Paula

What it is:
Sometimes we want to send special messages to the ones we love but they are sleeping. Soci Alarm Clock allows you to record a message from your browser and send to your beloved’s alarm clock. They just have to put it near bed, with the soft mat under the pillow.

soci

bed

How it works:
Soci Alarm Clocks runs in a node server. There is a browser interface in which users can login and see if their partner is awaken or not. The web interface talks to the actual device, which consists of speakers, arduino Yun and a soft switch (to be placed under the pillow). The awaken user records the message in the browser – for this, we used webRTC and we save the audio recording in the server. The arduino is constantly making get requests to the server as it was a client, and when it receives a “y” (from yes, there is a new message!) as response, it downloads the audio file and plays it in loop while the other user is still laying down. The sound stops when the user raises the head from the pillow.

There is a light status indicator:
blue – it is not time to wake up but user is not in bed
off – it is not time to wake up and user is in bed
red – it is time to wake up but user is still in bed (that’s when the alarm plays)
yellow – it is time to wake up and user is not in bed anymore.

sensor

We have discussed whether the user could send a message before it is actually time to wake up that person. We didn’t get to a common sense, but decided to prototype the version you can only send the message right before the person wakes up because it would avoid problems like what if I want to send a second message. So, before it is time, the user can’t send the message. Below is the interface step by step:

login page

not available

send message

Process:
Soft switch was built with conductive thread in both sides. Since the fabric is thick, the thread only touches itself (and closes the circuit) when is pressed. A problem we found: sometimes, if it is pressed really strong, there is a bit of delay, until the fabric goes back to its original shape. But otherwise, it works pretty well!

soft-sensor

Inside the box – that we built with laser cut acrylic -, there are speakers, an Arduino Yun, a hi-speed USB to sound adapter, a RGB led, a ON-OFF switch and a battery case (which we didn’t use because the Yun only runs up to 5V). Instead, we could have added a 5V power supply and make our device wired to a power plug, or if we really wanted it with no wires, add a 5V regulator before the power reaches the circuit. We followed this instructions to get madplay up and running in the Yun.

inside soci

The arduino code would make the Linux act as a client, and make get requests to the node server. This is done as in the HTTP Client example in the Arduino 1.5.4 Examples>Bridge folder. When it is time, it downloads the audio file and plays it in madplay. This happens through the Process class in the Bridge Library. It is possible to run shell commands from arduino code. We had a bit of difficulty to send commands to the Linux when madplay was playing. The solution was to add –tty-control as a parameter before running the process. This should be done when the primary input is not from the keyboard (which was our case, from the arduino).

Another problem we encounter with the shell commands was downloading the audio file. Since we stored it in S3 amazon server, it wouldn’t download due to security issues. We solved it by adding –insecure right after the curl command. I also learned that I need to call -o for output, followed by the file directory and name and url. I saved it in a micro SD card, which is located at /mnt/sda1. That’s the final command: “curl –insecure -o /mnt/sda1/filename.mp3 https://s3.amazonaws.com/folder/filename.mp3”

While we didn’t have any problems to make the client side work with Express.js and make all the get requests needed, we did have a lot of issues recording and saving the file. Mainly because Recorder.js saves audio as a WAV format and madplay couldn’t read it (Why would you use mpeg audio decoder (madplay) to play a WAV file? – Google told us). So we figured out we had to convert it in the server side, before saving it to the S3 amazon server, from where the arduino downloads it. Node-lame and node-wav were used to accomplish this. But then we realized this process of converting wouldn’t work with Heroku, where we hosting the webapp – something related to the available dynos – but it does work running locally.

Client side parts:
node-express to manage HTTP requests: http://expressjs.com/
recorder.js for get recording file from web stream data: https://github.com/mattdiamond/Recorderjs
node-lame to convert to mp3: https://www.npmjs.org/package/lame
node-wav to read wav file from local folder: https://www.npmjs.org/package/wav
AWS sdk to save at amazon s3 server: http://aws.amazon.com/
Apigee API platform for user management: https://apigee.com/about/

Documentation:
The code is available in our github: https://github.com/imagest108/cd-soci and below there is a video of the interaction!

6 thoughts on “SOCI: Social Alarm Clock

  1. Pingback: The Idea | on time

Leave a Reply