Monthly Archives: August 2016

StatsD And Anomalies

Anomaly Detection

I had been looking for a tool to detect anomalies in data. I stumbled across two libraries from Twitter:

 

 

These are R libraries for analysis of data. I have written a quick script to take data exported from StatsD and plot a graph with the interesting parts highlighted.

 

I was writing R code in a text editor but then someone suggested RStudio which I would highly recommend.

 

Below is the graph I was able to generate with 28 days of data.

 

Spot the issue.

Spot the issue…

 

The circled areas are available in code as well:

> print(res$anoms)
            timestamp anoms
1 2016-08-24 22:25:00 419.4919
2 2016-08-24 22:55:00 546.4654
3 2016-08-24 23:00:00 276.6360
4 2016-08-26 16:15:00 106.3696

 

The code to make this is StatsDAnomalyDetectionconvert_json.py will convert your raw data and output it into format the Twitter library can read.

 

Conclusion

This is a basic set of scripts for doing some analysis of StatsD data. I would recommend learning some R if you want to do some serious data analysis.

The Internet Gong

The Idea

A while back I wanted something that made a noise to notify me of an event. The original plan was to replicate Andy Rubin’s gong doorbell. The large gong and mallet was a little bit out of my price range but a good idea is a good idea. I ordered one from Amazon and combined with a servo and a Arduino Nano clone I set about the same idea.

 

Gong

Gong

 

With a little bit of tape it was finished. The design is basic but functional. The beater is attached to a 9g servo which acts as the human arm. An Arduino Nano clone is used to to move the servo.

 

In action:

https://www.youtube.com/watch?v=-vFhrOvHxIs

 

Triggering the Gong

Communication to the gong is done over serial. Sending “gong\n” over serial, triggers the beater/mallet to strike the gong and then move out the way to avoid a second gong strike. The code for the Arduino is below:

Conclusion

For a mini project this is perfect for getting servos and Arduinos to work together. Mine is currently connected to my Google calendar to alert me five minutes before a meeting.

 

The door bell will have to wait.