This project is about the internet of things and how we can start making simple things that can make us understand how fast are the technologies developing that can make that futuristic thing become reality. I love my hamster, was a gift of the creator of the original running ham, with the challenge to make ir running again. I have been working on it and I have found out an easier way to do it, and I want to share it with everyone.
Step 1: BOM
Step 2: The Hardware
First of all, you need to set up a Particle account and connect your Photon to the internet. This is pretty simple stuff. You can try the tinkering to check that your connection and Photon is OK.
We are going to mount this simple circuit, using our Hall Effect sensor as a bike wheel spedometer does, activating it with a magnet attachet to our hamsters running wheel. You need to attach the output pin of the your hall sensor to D0 pin of photon. Also, be aware that you may have to use a 10K resistor between your output and input pins of your hall sensor (see the datasheet of your sensor). To attach the magnet you can use hotmelt glue, a superglue or something like that. By the way, for a better result you can use a solder-able protoboard and some stackable headers to make a permanent circuitry.
Step 3: The Software
Now you have your circuit mounted, we are going to make some testing. Download my code and go to Particle online IDE. If you are new on this IDE you have a really nice guide to start with (is really similar to arduino’s classic offline IDE). You have to create a new APP on your panel and then flash it to your new online Photon. Also, I suggest you to change your device name to make it easier to recognize it when working with it.
Once you have flashed your device, go to Particle dashboard and login in. Go to the LOG tab. This tab gives you the posibility to monitor “on real-time” your devices, to see how they interact with the particles cloud server. You will be able to watch the “device goes online/offline” events and your data publishing. In this case, we are going to monitor with our simple code publishes how many meters have the hamster made for each run.If you read my code, you can see how it works: it get the pulses of the hall efect sensor and converts them to meters, then it sums up how many meters have the hamster did for a running period. For that task, it waits for 20 seconds from the last stop and if there is no run in that period of time, it publish it and restarts the counter.
Step 4: Charts
For anyone that is making a IoT (Internet of things) project, or also a IoP (Internet of Pets), charts are really usefull. In my opinion, D3JS is the most powerfull online chart creating library, but for most people creating a server of JS with D3JS and conneting a chart to a DB is a very complicated stuff to do alone. In this case, I would have liked to use Plot.ly service that runs Phyton and Django with a D3JS, CSS and HTML frontend with a really easy to use web interface. This service already haves a library for Arduino but it doesn’t work on our Photon (yet).
So, I have used Thingspeak that is really simple to use. Create an account, then create a channel and finnaly create 4 chanel fields to stream data. Follow this tutorial to do that (is old but usefull). Then, at API keys tab, select and store at a notepad your Write API Key and channel number (at URL). Go to my code and chage the chanel number and the api key with yours. If you have done right, it will work :). If you see the photon publishing meters on the dashboard, your are doing it right.
Step 5: Connecting to Twitter/FB
Now, we are going to use the super intuitive IFTTT service. This guys made a really cool stuff and we are going to use it for our task. First, create and account. If you are noob, IFTTT means If This Then That, and and this is how it works: you create a recipe that connects two internet services, using a trigger of one service to create a response on another service (like automating things). For making things easier, I have already created a recipe that you can simply modify (Event name as the one of the code = Ham) and add as a personal recipe. You have to connect to your particle account giving your credentials as so with twitter, and then select your device on the recipe trigger. Or you can also create a new recipe that connects it to facebook, google drive, wordpress, spotify, philips hue light, wemo light or whatever you can imagine.
Voilà, now the photon is connected to your twitter account. Every time photon publishes a event it will publish it on twitter. Now you can stay tune to your hamsters runs, that simple. You can follow my hamster Ham.
Step 6: IP Cameras
A nice way to monitor your hamsters activity is using IP cameras to have a real time viewing server and twitter and facebook photo updates. In my case, I used a variety of cameras and services to make this happen. In fact, I use my Synology’s surveyllance APP to monitor all my cameras activity and IFTTT to push this activity photo updates. I know that buying a 200$ NAS just for monitoring your 10$ Hamster can sound a little bit crazy, but I also use my NAS for automating torrents donwload, as a media center, as my personal file cloud and much more. If you wanna make this cheap, you can also follow the next steps because I’m explaining some of the cheapest systems I found.
The first and cheapest way to do this is using and old Android phone that you will almost certainly have at home (you need to power it with a continuous power supply). I use IP camera android APP that works extremely fine and you cant connect it to the powerfull Ivideon web service. This service is free up to 2 cameras and you can connect it to IFTTT.
The next cheap way is to buy a regular/chinese ONVIF compatible IP camera and connect it to Ivideon too. Easy peasy.
Thirth option is to buy the famous Xiaoyi smart camera. This is not working with Ivideon so you will have to use Xiaomi’s mobile APP’s to watch your pets. If your are setting up the Synology Surveillance Station, you may hack it installing a new firmware and following some steps.
The last option is to buy any comercial branded IP camera such as DLINK, Belkin… camera.
I hope you like my project, and Ham. =)