I am interested in Habits lately. A good book on the topic is Power of Habit. There exists a fantastic platform Habitica (formerly known as HabitRPG and open source) to help gamify habit forming. Something that I feel is missing from Habitica is the real world elements. To bring Habitica out of virtual space I integrated it with AWS IoT platform to connect real world devices!

What it does

With vanilla Habitica you can setup simple habits you are trying to curb or improve upon. Good habits like cleaning up your room each day, or bad habits like eating unhealthy snacks. My modified version of Habitica talks with AWS IoT platform. This new integration allows an end user of the modified Habitica to connect real world devices to both trigger habits or trigger the rewards or penalties from doing a habit or task. Imagination is the limit on the type of devices you can now connect to Habitica because of how easy AWS IoT is. For the demo I created a couple devices: a lockable candy dish to try and curb unhealthy snacking, a light bar to show users current health stats and provide optical feedback upon completion of tasks, and a simple script to lock a video game down making it unplayable until the user has completed enough tasks for the day.

How I built it

Habitica is an open source project already, so it was easy to take what was there and add in AWS IoT support. All I had to do was upon user creation add IoT Thing, certificate and security policy. Whenever you update the Habitica user the app updates the IoT Thing's Shadow. The Shadow is just a block of data that all connected devices can listen for updates from.

For the real world devices I used a raspberry pi because it is very cheap and easy to use. I used node.js and javascript to control the GPIO on the raspberry pi. I used an existing npm package called aws-iot-device-sdk which makes it trivial to connect to the AWS IoT mqtt topic using a certificate. Once connected to the mqtt topic its pretty easy to wait for updates on the Shadow and perform some action on the GPIO.

Challenges I ran into

AWS IoT integration was absolutely simple. Connected to a candy dish over GPIO on a raspberry pi is a bit harder! I ran into the challenge of how to intercept the sensor on the candydish and be able to turn it off.

I do wonder how scalable it is to create a new AWS IoT certificate for each user. I think there is a soft limit of 100 certs per aws account, but I'm not sure what the hard limit is.

Accomplishments that I'm proud of

Having a candy dish that is connected to the 'cloud' which prevents unhealthy snacking because you've had too much is pretty neat!

What I learned

How absolutely simple and quick it is to take advantage of AWS IoT!

What's next for Helping change habits using Habitica and AWS IoT Platform

Perhaps reach out to the Habitica core team and see if AWS IoT integration would be something worth while for the live production version for everyone to use.

Built With

  • aws-iot
  • habitica-(open-source-project)
  • node.js
  • rapsberry-pi
Share this project: