First attempts

A project log for Project Fat Cat

An automated pet feeder to keep my fat cat out of my skinny cat's food.

RowanonRowanon 09/18/2016 at 07:530 Comments

I've been messing with this for a bit, and here's the current state of affairs:

I'm having 2 main problems with the data.

First, if I just use the example code for the magnetometer and leave it alone, I get consistent baseline data. If I move a magnet close to it, the data changes in the appropriate way. But when I remove the magnet, the data never returns to baseline. To be honest I'm having trouble coming up with possible causes for this problem. If it was a strong magnet or if it was there for a long time, it may magnetize nearby metal to cause this, but it's a weak magnet only near it for a few seconds.

Second problem: I want to establish a baseline, poll the data every 1-2 seconds, then use a simple if statement to move the servo motor if the data deviates from the baseline. To do this I need to get multiple readings and compare them. Every time I write a sketch where it reads the data more than once, I get a pattern: first read gets good data, second read gets mystery numbers that are NOT real data, third read good data, and it alternates like that. It does this even if I use different variable names for the first and second sets of data. It does this even if I reset the variables to 0 before the end of the loop. Pretty sure this has to do with bit math, somehow, which I'm 100% ignorant of.

Next steps: Learn more about the raw data that the magnetometer sends, learn more about the bit math it uses to convert it into the serial output I see, probably find out what 'registers' are because that seems important.