Saturday, October 29, 2016

Launitor - Laundry Monitor

The LED and button on the left is for my washing machine, the LED and button on the right is for my dryer

Launitor - a combination of 'laundry' and 'monitor'...ok, so maybe it's a silly name, but it's nice to name your projects, and that's all I've come up with at the moment.

At the Jamreb household, our laundry machines are in our garage. They were purchased many years ago, and they were cheap. They don't give any kind of notification when they are done. Worse, our dryer is not working too well at the moment. We have to run it 3 times before our clothes are fully dry.

I don't know about other people, but sometimes we forget to move the laundry from the washing machine to the dryer. If you've ever done this, you know it's not pretty. The clothes get all nasty smelling and need to be washed all over again. We also forget about the clothes when they're in the dryer sometimes, which also ends with unpleasant results.

I remember seeing a few laundry monitor devices on one of my favorite sites, Well, I wanted to build one of my own and start saving water/energy/time/money! But first a little planning...

As usual, there were some requirements I had:
  • It should be portable for if/when we get a new washer/dryer
  • No permanent changes/modifications should be made to the machines
  • Should be cheap
  • Should require as little user-intervention as possible
  • Easy to use, and have visual cues as to what's going on with them

1 of my challenges
When I first started this project, I was using an Arduino and trying to use some cheap piezo elements from Sparkfun to detect the vibrations of the washer/dryer. It seemed to have worked o-k, but the piezo wasn't quite sensitive enough. Also, I had problems with the wires breaking right off of the piezo too easily when working with them. And I had to tape them real tight to the washer/dryer to get them to pick up the vibrations of the washer/dryer. Lastly, when removing the tape from them (to bring back into my 'lab'), it tended to damage some of the film on the piezos.

After giving up on the piezos, I came across these cool little Adafruit triple-axis accelerometers. It took me a while to figure them out and how to use them. Thankfully there is a great little tutorial on Adafruit's website for them though. So I read through the tutorial several times, and finally was able to get them working.

Once I had the accelerometers working (enough), I then switched over from the Arduino to Adafruit's Huzzah ESP8266 breakout board. This would allow me to IoT-enable this project a lot simpler and a lot cheaper than using an Arduino and a Wi-Fi (or Ethernet) shield.

Throughout the course of development, I ran into many issues/problems along the way and learned a lot. If you want to know about the challenges/problems that I ran in to (and how I overcame them), check out my Laundry Monitor challenges post.

So how does this thing work, anyway?
This is a very simple device to use - when nothing is going on, the LEDs are off. If it detects enough vibrations in a certain amount of time (both amount of vibrations and time are easily adjustable in code), it starts blinking the corresponding LED to visually show that the washer (or dryer) is running. When it realizes that the machine is done running, it turns the LED solid, and sends you an email. If you have the option enabled in the code, it will keep sending you an alert via email every X (also adjustable in code) amount of minutes. After you remove your clothes, just push the corresponding button to reset it so that it will start watching for the next load!

Just a quick note - if you decide to do this project, keep in mind that you will most likely have to 'calibrate' the sensitivity for your own washer/dryer. This involves adjusting 1 or both threshholds and testing. And maybe changing some of the counting/timer constants in the code. (I explain this more the code's comments)

Last photo - this just shows the final placement of the accelerometers on my washer and dryer:

Below are some links for you to use if you want to make your own Laundry Monitor. The various Fritzing files are so you can see how to hook everything up. The bill of materials gives you a complete list of parts, including pricing, and direct links to the items:

Arduino code on GitHub
Fritzing file (actual .fzz)
Fritzing file, exported to .png image
Fritzing file, exported to .jpg image
Fritzing file, exported to .pdf file
Bill of Materials (Open Office) 
Bill of Materials (Excel)

There's no proper schematic because I'm being lazy again. Between the 'Bill of Materials' file and the Fritzing file however, you should be able to make your own. ;)

Cool, I want to build one - what do I need, and what do I need to do?

Note 1 - I'm not going to go into every little detail of what you need here. This list is basic and is just a high-level overview. It also assumes you have at least a little experience in soldering and necessary hardware to attach the sensors to your washer/dryer and the rest of the electronics to something (like a wall). Lastly, it assumes you have basic electronics stuff like wire and wire strippers.

Note 2 - This list isn't necessarily in chronological order

  1. About $40 depending on what you have already, and how you 'mount' the sensors to your washer/dryer. And how you 'mount' the enclosure if you use one.
  2. Check out the BOM (linked above), and figure out what you need to buy and what you already have. Note - if you don't have an FTDI cable (like this) to program the Huzzah, you'll need one of those too (or some other way of programming the Huzzah)
  3. Sign up for a free account at smtp2go
  4. Solder everything together if you're brave, or breadboard it 1st for testing/calibration and then solder everything together
  5. Update the sketch to use your own Wi-Fi, IP, email, (encoded) smtp2go credentials
  6. 'Calibrate' the sensitivity of the accelerometers you're using for your washer/dryer in the Arduino sketch

Of course, I'll be happy to answer any questions about it - just ask in the comments section!

Lastly, here's a quick video of mine in action:

Thanks for visiting!

Launitor - Laundry Monitor - Challenges

As I mentioned in my main post about my Laundry Monitor project, I had a lot of issues/problems  along the way. In this post, I'm sharing with you most of those problems.

Ok, let's jump in:

Challenge/problem #1 - I wanted to use just an ESP8266 module instead of an Arduino + ESP8266 with piezos
I learned that the ESP8266 has only 1 analog (ADC) pin, and if you have the ESP-01, it's 'hard to access'. I needed 2 analog pins because I needed to interface with 2 piezos (1 for the washing machine, 1 for the dryer). I did come across this cool little device, but it seemed like it would be a lot of trouble though. This whole challenge was going to be too much for me, so I abandoned the idea of just using a single ESP-01 module. I decided to go with an Arduino + ESP8266 (for Internet/network connectivity)

Challenge/problem #2 - Another problem with working with the piezos
If you read my main post, you'll know that I had a couple issues with the piezos. There was another problem that I didn't mention in that post. During the beginning of my developing this project, I would test things with my Arduino plugged into the USB port of my computer. However, when I would move everything to my washer/dryer to test without a computer (so when the Arduino ran 'standalone'), the piezos would behave strangely. They basically seemed like they weren't sensing any vibrations. If you want to know more, I posted about this problem on the Arduino forum:
In a nutshell, I tried several things - such as changing voltages, power supplies, using the AREF pin on the Arduino, etc with the help of the good people at the Arduino forum. Additionally, I was having problems also because of a loose resistor from moving things around too much. Eventually I just decided not to use piezos.

Challenge/problem #3 - 2 I2C devices with the same address?
Ok, this wasn't really a challenge or a problem so much, but I wanted to mention it briefly. When you're using I2C devices (like the accelerometers I used), you can't have 2 devices with the same address. With the particular accelerometers I was using (the Adafruit LIS3DH Triple-Axis accelerometers), you can change the address of it in hardware by connecting 'SDO' to 3.3V. This changes the address from 0x18 to 0x19.

Challenge/problem #4 - Button debouncing
There is some button debouncing of course because this project has buttons. However, when I had a delay(250); at the end of the sketch, the buttons didn't really seem to need debouncing strangely enough. In fact, when I did have debouncing code with that delay, the buttons became very unreliable. But, when I took out the delay completely, the accelerometers seemed to have been hyper-sensitive. So, I played with the delay some more, and found that 50 seems like a good number - good for the debouncing/button code, and for the accelerometer sensitivity.

Challenge/problem #5 - Text alerts
This one was a really annoying problem I had, and one I did not see coming. It should have been simple - having ATT for my cell provider, it should have just been a matter of sending an email to for example. Not!

Sending an email to an address such as the above works just fine if you're actually in the Gmail interface, but never goes through when using the Huzzah/SMTP2Go combo. I'm not good enough to write my own code to send an email, so I was at the mercy of someone else's code which requires the free SMTP2Go service. It actually works great, but just has that issue of not being able to send through to addresses like I mentioned above for email-to-text. I looked into, and tried many different alternatives such as:

  1. Sending from a 'real' email address such as The problem with this is the same as with the Gmail - it doesn't actually go through (no error message, the text message just never comes through)
  2. Using a distribution list such as Google Groups. I didn't fully try this - it was going to be too much of a hassle such as setting up a new account, the group, etc.
  3. Using a distribution list such as MailChimp. The problem with this is they don't accept recipients with texting domains (such as
  4. Set up an email forwarding address with my hosting company. Same problem - never went through.
  5. GMail filter/forward - this was the winner. It wasn't exactly simple/quick - you have to set up rules to forward, and create a new forwarding address, but it works. So when my GMail email account receives an email with certain words in the subject line, it forwards to my texting address. Again, not exactly ideal, but it wasn't complicated and it works.

I'd like to find a better/easier solution, but at least for now, it's working. Oh, by the way, I'm not sure why the texts never come through in the circumstances described above, but when I did some searching, it sounds like that it's a combination of the way that the code sends an email and the fact that I'm not really sending through a real domain - there's no proper reverse DNS, so the mail servers are rejecting it.

Challenge/problem #6 - Static IP
I had problems with the Huzzah not letting me assign a static IP, even though I had the code in there to set the IP (at least I thought I did). It would just keep using DHCP for assigning itself an IP. The fix was a bit strange - the line WiFi.config(ip, gateway, subnet); needs to be AFTER the line WiFi.begin(ssd, password).
I didn't even have the WiFi.config(ip, gateway, subnet); line in the code at all. Additionally, I had the one line in the function that sends the email so I wasn't getting the static IP until it would send an email. Priorly it just uses DHCP. I moved both of the aforementioned lines into the setup() loop and it started working - it gets the specified IP right off the bat.

Challenge/problem #7 - No 'CC' in the email function
This one wasn't a big deal really, but I thought I'd mention it. I thought that in order to send the email to a 2nd recipient, you just add a 'CC' line of code. Wrong. Just add another one of these lines:
client.print("RCPT To:");

Challenge/problem #8 - Bug!
For some reason, sometimes after sending the email notification, the LED would turn itself off. This is not supposed to happen - it's supposed to only turn off with the user pressing the 'reset' button. I tried changing all kinds of code all over the place but it wasn't helping.
It took a long time for me to figure it out. I posted the problem on the Arduino forums, and a very smart person said to add serial.print(); lines in EVERY location where the LED is turned off and/or on. So after more testing, I finally found the problem - there was a 'blinkLEDWhileMachineIsRunning' immediately after the 'notifyRepeatWasherOrDryerIsDone' line. Well, I never intended this line to run after sending the email, so I added a 'return' to jump out of the current 'if/else' block of code!
Moral of the story? Don't use serial.println(); sparingly - use them everywhere! And don't underestimate the power of those lines when writing/debugging code.

Challenge/problem #9 - Accelerometer orientation
Sometimes when in my 'lab' and also in the garage (where my washer/dryer is located), one or both accelerometers would go crazy sometimes and act like it's picking up very fast constant vibrations. I eventually figured out that it seemed to be dependent on their orientation. If it was leaning too much to 1 or more sides, it would go nuts. If it was orientated correctly (the top of it was actually the top, and not leaning too much to 1 side), it would be ok.

Challenge/problem #10 - Accelerometer sensitivty woes
This is the worst one I think because it took so long to figure out. During all my testing, I had problems with the sensitivity of the accelerometers. When adjusting the sensitivity on 1 or both, It was like I didn't adjust one of them. For example, if I adjusted the threshhold for the dryer, it seemed to have made no difference. I banged my head against the wall for a couple of months on this one, but you know what?! It turned out to be me - I was the problem! I had the accelerometers mixed up in code like a doofus. Once I had corrected it, the 'calibration' of sensitivity for both accelerometers went wonderfully!

Challenge/problem #11 - Cramped space
I wish I had a larger project box because trying to stuff all the circuitry and wires into the box was not working too well. I ended up shortening several of the wires, and swapping out some of the wires with stranded (more flexible) wire. I originally used all solid core wire. In the future, I will probably use stranded wires for projects that need to fit in a box.

Well, that's about it. I hope this set of challenges/problems helps you for either duplicating this project or some other project you may have.

Sunday, October 2, 2016

My new RC Transmitter - FlySky FS-T6 - not exactly what I expected, but it is now

Recently I purchased an RC Transmitter - more specifically a FlySky FS-T6 on eBay. It was a killer price - less than $50, and it has 6 channels.

To my surprise however, I discovered that the left throttle stick does not bounce back when moving it up or down. Everything else springs back - side to side and the right stick springs back when moving up and down and side to side.

Here's a little demo of the transmitter. It shows that the left stick just stays put when you move it up/down. For my application, I was expecting/wanting it to bounce back to vertical center.

I started searching and reading about RC transmitters. Then I took my little question/issue to the appropriate section of the RC Universe forums. So apparently what I bought was a cheap (as in $$$ and quality) airplane/helicopter transmitter. The behavior of the left stick is by design - you don't want the left (usually throttle) stick to bounce back to center when flying a helicopter/airplane.

The smart people over at the forum though were kind enough to tell me I had a cheap-o transmitter (FYI I'm not being sarcastic) on my hands. So they told me that maybe I should buy a better transmitter. I almost sent it back, but then had some other good suggestions such as 'modifying' the transmitter to install a spring inside which will make that left stick bounce back.

Doing a little more research on this route, I came across this:
The problem is that I don't have a 3D printer (yet). It did give me the idea of designing/making my own part from scratch that could be laser cut.

What I did was remove the existing 'control arm' (the one for the right side), and scan it into my computer. However, it kept coming out terribly no matter what settings I used for the scanner. Then I realized that it was because the piece was black. So I took it outside and sprayed one side of it with some white spray paint, then scanned again...success!

Then with some sign software, I had it perform a 'vectorize' function on the image, and boom! I had a nice new vector file. I did modify it just slightly before I prepped the file for laser-cutting. A couple minutes later and boom! Now I had a nice shiny new part for my cheap RC transmitter:

Original spring, control arm (painted white) on the left; new spring, control arm on the left

The above image is showing the original control arm that I temporarily removed and spray painted white. The original spring is to the left of that. That was my other problem - I needed a spring to go with my new control arm, otherwise that piece is useless. So what I didn't mention yet, I took dimensions of the existing spring, and found a very very similar spring on (part# 9654K942.

When I received the springs (come in a package of 12), I excitedly put my new control arm and spring in there, and tried it out. I had to 'open' the little loop on one end to get it installed correctly, but that was no problem. When done, I was a little disappointed however - the spring is very strong/tight, so there is a lot of resistance when moving the left control stick up or down.

I took the spring back out, and tried to stretch it out a bit. I think I made it better, but it's still tight. I would like to find a better replacement, but I'm going to live with it for now. (I actually ruined 1 spring trying to do that - I stretched it way too much/far so now it's permanently very long)

You can see that it's now installed in the photo below (control arm circled):

Here's a video demonstrating the new behavior of the left control stick moving up and down thanks to the new parts:

Could you tell that the stick doesn't bounce back the same way as the other control stick? That kind of bugs me but I think it will be ok for what I'm doing.

One last thing - if someone wants to make their own custom control arm for this transmitter, here's the .ai file for cutting your own:

FlySky FS-T6 6 channel RC transmitter centering control arm

Well, I hope this helps someone out there. If you have any questions/comments, you know what to do!

Sunday, August 7, 2016

Migrating from a HDD (Hard Disk Drive) to a SSD (Solid State Drive)

My new drive in it's bracket, ready to go in my PC :)

First off, this is not a guide on how to go about doing the 'migration', as there are plenty of pretty good guides out there, such as the following 2:
I recommend you read through both articles and fully understand them before doing your upgrade. And then go ahead and read this article too (it's from one of the maker's of the software that the guides talk about):

So what this is, however, is a little article about my experience, and I will give a couple of my own tips so that you are a little bit better prepared to perform the upgrade successfully should you choose to do this.

Why would one want to upgrade from a HDD to an SSD?
The number one reason you would want to do this is that SSDs are faster than HDDs. But there's a couple of other benefits: your computer may draw a little less power, and it should also be a bit quieter.

Ok, on with it...

I started off by 'cleaning' my system of a lot of accumulated 'junk' which freed up some disk space. You should do the same - you don't want to bring over a bunch of junk to your shiny new drive, do you? I ran CCleaner, and SlimCleaner which gave me a couple of extra gigabytes of space (I don't run them as much as I should). Then I ran a defrag. I only did this because of freeing up a couple of gigabytes. I have Windows 7 so defrag runs automatically every week, so there's not really a need to run it manually unless you do something like I did.

The next thing I did was actually temporarily install the new SSD in another one of my computers, download the software for the drive (my drive is an OCZ), and check to see if there were any firmware updates for the drive...there weren't. Each SSD manufacturer has their own SSD utility software so download the appropriate one for yours. You don't have to do this, but if you have the means, I recommend doing this before. If you don't, then just do it when you're all done.

On to the actual cloning...

The software I chose to use to do the cloning was EaseUS Todo Backup Free 9.2. As the name implies, it's free software. But don't let the name throw you off - yeah it's free, but it's very capable software. Also, it sounds more like a backup tool, but it does cloning too, which is exactly what we need. The biggest thing though, is that it's capable of cloning a 'live' drive - your 'system' drive while your 'system' is running! This is pretty amazing for a free product so I highly recommend it.

When you have the drive installed in your system, and the cloning software installed, you can run the cloning process. I'd like to share 1 thing about the part of actually running the program. During the cloning wizard, it actually presents you with individual partitions besides the hard drives. I was so excited about the software that I only cloned the main partition first time around. This didn't result in a complete clone of my 'old' drive - just the main partition. This isn't enough - you need the 'System Reserved' partition as well, so when you're running the wizard, please make sure you choose all partitions on your old drive, otherwise your system won't boot off of the new SSD.

One last thing - I was originally attempting to do all of this in my cheap (USB 2.0) drive dock. It was giving me issues though - not always fully recognizing the drive, etc. So I would recommend not using one of those as it's just creating another possible point of failure.

Ok, ok, 1 more thing - during the wizard, there should be an 'Optimize for SSD' checkbox...make sure you check that box as I believe it makes sure that your new SSD will be properly 'aligned'.

I have Windows 7, so there is an Windows Experience Index test you can run on your computer. Before this new SSD, the 'Primary hard disk' score I was getting was a 5.9. After the new SSD, I'm getting a 7.7!

If you want to be thorough, I would download an SSD 'benchmark' utility, such as 'AS SSD'. This will tell you if your new drive is aligned properly...see the following thread:
It also will run some performance tests for you too.

When you're all done, you may want to check a couple of things to make sure that your system doesn't prematurely wear out your SSD:

1. Check that your system won't defrag your shiny new SSD. It should have automatically disabled it, but if you want to verify:
Open up disk defragmenter, click on 'Configure schedule', click 'Select disks...'. Your new SSD shouldn't even be in the list.

2. Turn off 'indexing' in Windows...or make sure that it's already disabled:
Open 'My Computer' / 'Windows Explorer'. Right-click on your SSD drive, click 'Properties'. Uncheck 'Allow files on this drive to have contents indexed in addition to file properties'. Click 'Ok'. Done!

Well, I hope that was useful to some people out there. If you have any questions, feel free to leave a comment!

Oh, and in case you wanted to check out more information about the particular SSD (and bracket) I bought, here's the link to it on Amazon:
and the bracket:

Sunday, June 5, 2016

Automatic Cat Feeder - New feature - Summer/Winter Mode

New feature - Summer Mode / Winter Mode

After getting tired of having to pull the chip off the board, bringing it inside, reprogramming it, bringing it back to the garage, and placing it back in it's place, etc., I added a new feature to this thing!

You see that little switch in the picture above (circled in red)? That is a little toggle switch I just added (along with the black wires, red wire, and resistor). When it's to the left, the device is in 'Summer Mode'. Switch it to the right, and it's in 'Winter Mode'. This allows you to have 2 different settings for amounts of food to be dispensed. Our boys don't eat as much in the Summer as they do the Winter, so in the Summer, their bowls were slowly filling up more and more from having 'Winter' settings still.

The little label below the circuit board that says 'SM WM' stands for 'Summer Mode' and 'Winter Mode'.

Here are my updated files:

Arduino code/sketch on GitHub
Fritzing file (actual .fzz)
Fritzing file, exported to .png image
Fritzing file, exported to .pdf file

One last note about this new feature - I also added code to show which mode it's in when you power up the device. So shortly after you plug it in:
LED A will blink 3 times to show that it is in Summer mode OR
LED B will blink 3 times to show that it is in Winter mode

Sunday, February 14, 2016

Wi-Fi upgrade

For years I've used the built-in wireless functionality of my routers for my house. My preferred router for my home for the past several years is the Linksys WRT54GL, with the custom firmware, Tomato. The router is a nice home router, and with the custom firmware, has a ton of features - way beyond the average consumer/home router.

However, recently, I've been having to power cycle the poor thing. It may be on the least the wireless part(s) of it - the router itself is fine - my wired connections still work when I have the wi-fi issues with it.

Instead of replacing the whole router, I decided to try a better solution. I looked into entry-level business Access Points, and Ubiquiti's name kept coming up. They have a ton of wireless products/solutions. After looking into the different options, I decided to go with the UniFi AP ($65).

Installing it was easy, and I love that it came with a PoE injector - those alone aren't exactly cheap. I've only installed it about a month ago as of this writing, but I've had no problem with it. I can't say whether the range is better than my Linksys router because as I mentioned, the Linksys router is in my garage, and I installed the new AP in the middle of my house:

Ubiquiti UniFi AP

As you can see, it looks very nice/modern. Conveniently, it comes with some hardware that allows you to install it on a regular wall, or on a 'drop ceiling' (these are common in offices).

My ONLY complaint is that you have to install their software on a computer in order to set it up and manage it. That obviously wasn't a dealbreaker for me - I can live with that.

Here are some screenshots:

The 'Dashboard'

The 'Devices' list (Ubiquiti devices)

The 'Clients' list - devices connected to the AP(s)

The features in the software are extensive. I have a feeling that the cost of this thing AP just barely covers the cost of the hardware, and the rest goes to the software - the software is amazing. It's definitely overkill for home use, but in a business setting, you'll get more use out of it

No, I do not work for Ubiquiti nor am I affiliated with them in any kind of way. I am just (currently) a very happy customer.

Sunday, October 25, 2015

Automatic Cat Feeder - Electronics

The main electronics

Just a quick note - the green and blue wires you see that are going over and behind the plywood are not going anywhere really - it was just a way to get rid of the 'slack' I had, without cutting the wires to length. I always try to give myself slack when hooking up wires, run cables, etc.

Whenever I start a new electronics project, I break it down into different parts. The reason being is that I do not have a lot of experience in electronics, and therefore do not know much. So, I take the different components that I need to learn about, and proceed to learn about them one at a time.

From my point of view, there's 3 different aspects/components to the electronics for this project:

1. The Arduino parts
2. The motor parts
3. The 'clock' parts

So let's go in a little deeper...

1. The Arduino parts

I actually already knew about the Arduino parts from past projects, so there wasn't much to this part for me this time.

I'm not really going to go into detail about this as you probably already know about Arduino. However, if you are a beginner (like me) and want to know more about how to 'make your own' Arduino, you can check out my Instructable. Basically it shows you how to use your programmed ATMega328 chip on your own circuit. Instead of using up an entire, retail Arduino board ($25-$35) for your projects, you can just use a few cheap electronic components and build it in to your own project, like I did with this automatic cat feeder.

Here's a photo of an 'Arduino' on a breadboard from my Instructable that I just mentioned:

Standalone Arduino on a breadboard

I do want to mention that during the learning/development/testing phase of a new project, I do use an actual, retail Arduino board. I have a couple of older Arduino Duemilanove boards that I always use for prototyping.

2. The motor parts

This ended up being an expensive part of the project. I've never 'driven' a motor from a microcontroller before, and had very little experience with motors in general. Having no idea what the specs needed to rotate the plastic paddle in the food dispenser, I purchased several different kinds and sizes of motors. I tried to keep it cheap, and mostly bought from RS Electronics. None of them ended up being sufficient enough though - they all spun pretty fast which was one problem, and they had very little torque which was the other problem.

What I needed was a motor that spun slow, and had good torque. As I mentioned in the main post for this project, I ended up buying a motor (on eBay) very similar to the one that this guy used. The specs for it:

Rated voltage: 12V
No-load speed: 5RPM
Product diameter: 37mm
Rated torque: 5kg/cm
Stall torque: 30kg/cm
Weight: 190g
Shaft diameter: 6mm
Product dimensions: 37mm (diameter) x 81mm (total length)

Here's a link to an eBay search that may come up with a motor with the same specs.

As I mentioned before, I have no experience with controlling a motor with a microcontroller, so this was all new to me. From what I found, there's a few options - you can buy an Arduino motor shield like this, this, or this. You can build what's called an H-bridge. You can drive it from your Arduino directly maybe (if you want to kill your Arduino). Or, you can go with one of these. It's fairly cheap, and pretty simple to use. It drives 1 or 2 motors (which I needed to run 2), so it worked out great for me.

If you want to use the same motor driver board that I did, check out the Bildr tutorial for it - it's what I used to learn how to hook it up, and run it.

One word of advice though - the last paragraph says that if you set the 2 direction pins HIGH or LOW, the motor will stop. This is not entirely true - you also have to enable standby with:

digitalWrite(STBY, LOW);

Ok, one more word of advice - I think that running a motor at full speed from a stopped position is not a good idea for the motor, so I 'ramp up' the speed in my code. There's a link to the Arduino code from my project's introduction page, but here's a little snippet:

  //Don't spin motor full speed immediately - ramp it up!
  for (i = 1; i < 256; i++) { // loop from 1 to 255
    moveMotorLowLevel(whichMotor, i, 1); //motor A or B, speed from 1 to 255, spin left
    Alarm.delay(10); // give a small delay between each speed change

Regarding dispensing the actual food, I just had to play with how many seconds to run the motor in order to get the desired of food dispensed out - there's no magic formula/equation as far as I know to get it precise the first time.

That about does it for the motor stuff, now on to our last 'component':

3. The 'clock' parts

What good would an automatic cat feeder if it didn't automatically feed the cats? There were 2 ways I could have (that I know of) approached this component:

1. Purchase some kind of automatic switching timer device like this one. There are tons of these on the Internet and brick-and-mortar places like Home Depot, Lowe's, WalMart, Target, etc. Going this route would have simplified the code/software side of things drastically.

2. Add a few components to the circuit to have a built-in clock/timer. This route makes writing the code more involved/complicated, but due to the existence of 'Time'-related libraries, I didn't need to write everything from scratch.

If you haven't picked it up already from reading my other posts, I'll just tell you now - I'm cheap. And, I wanted to learn about building my own clock and implementing 'timers' and the like. Sooo, I went the route of #2.

Turns out that it wasn't that difficult. I actually bought a couple DS1307 Real Time Clock breakout board kits a while back because I wanted to learn about making my own clock, and I knew this day would come where I 'needed' to build one into a project. If you looked at the link, you may have noticed that there are only 6 components including the battery/holder. So for this project, I just integrated those 6 components into my circuit and called it a day!

There was 1 major problem that I ran into doing this however. See Challenge #5 on my previous post, Automatic Cat Feeder - Challenges.

Well that brings this post to a conclusion. Hopefully this information will help someone out there. If you have a question, just leave a comment below.

Sunday, September 20, 2015

Automatic Cat Feeder - Challenges

Below is an overview of the biggest challenges that I had when working on this project. FYI they're not listed in any kind of order.

Challenge #1 - The food dispensing system

My first challenge was what kind of mechanism to make to actually dispense out the food? My father-in-law helped me brainstorm about this and he came up with some pretty good ideas. The one I started pursuing was a system with a 4" diameter polystyrene coupling. I even had a couple of 'discs' laser-cut by Ponoko. They were both shaped like PacMan. One was going to be stationary and the other was going to be rotated by a servo or motor.

If you want to see a video demo of how this was a fail, check it out:

I did come up with the idea of having a small 'vibrating' motor inside of the cylinder, which is to 'agitate'/move the food so that it keeps dispensing instead of getting stuck. I believe this would have worked, but I was having too much trouble with mounting the motor properly centered, and what hardware to use to keep it mounted/stationary without being in the way of the food.

Shortly after I scrapped the idea, I came across this guy's homemade automatic cat feeder system. I loved it, so I based the dispensing system off of his. The actual dispenser is a commercial cereal dispenser. Oh, 1 more important requirement is that it had to be food safe.

Here it is mounted on my 'canvas':

Food dispenser mounted on the 'canvas'

(Note - I'm using the word 'canvas' to refer to the big piece of plywood)
(Note 2 - I use the word 'canvas' very loosely - I am in no way any kind of artist)

Challenge #2 - The food delivery system

This one was probably the 2nd most difficult (the first one was above) part of the project. If you saw the video in my Overview/Introduction post about this project, you may have noticed that I have 3 different food delivery systems in place. The first one was made of regular cardboard. I 'scored' the cardboard and bent/folded wings or rails. I had to play with different angles to make sure that the food doesn't 'bounce' out of the track. It seemed like no matter what I tried, food kept bouncing out. To prevent this, I made a cover much in the same way that I made the base part of the track. Here's what I started with:

Beginning of the first food delivery vehicle - before the cover

I have a generic 'L' bracket attached to the 'canvas' and one of the cardboard 'tracks' is resting on it, and I have a single machine screw with nuts to hold it securely on the bracket. The other track is attached directly to the 'canvas' with a couple of wood screws.

My 2nd method is utilizing a 'core' from a roll of vinyl that I brought home from work (I work at a sign shop so we are always tossing these cardboard tubes).

Vinyl core cardboard tube

As you can probably see, I attached this to my 'canvas' using a couple of carriage bolts (and accompanying hardware of course). On top of the tube is just a cut up plastic Listerine bottle, which just acts as a 'funnel'.

Side view to show a little more of the hardware

The last dispensing 'system' was done out of paper towel tubes, and the chopped-off/top part of a 2-liter soda bottle. The cut-up bottle also acts as a 'funnel' to catch all the food from the dispenser.

Paper towel tubes duct-taped together

I was a little weary about using these cardboard tubes as they're so small and thin, but it actually ended up working quite well. I probably didn't have to use any hardware to 'mount' it to my 'canvas' but I did anyway just to be safe. You see, it fit so tightly behind the 1st chute (the cardboard track), that it doesn't really move. However, I did use a couple of screws anyway:

Can you see the screw through the top hole? (It's too dark to see the bottom one, but there's one in there too)

The way I used screws was just cut a couple of holes out of the tube, drilled a small 'pilot' hole in the cardboard (and canvas of course), and screwed it in. Then I just put duct tape over the holes to cover it to make sure no food comes out:

Holes covered up with duct tape

The only other thing to show as far as the food delivery system is the bottom 'mouth' attachments:

End of the left and center tubes

You probably can't really tell, but for the one on the left, I took a piece of cardboard from a box of Mountain Dew Voltage, rolled it, cut it, duct taped it to the bottom of the vinyl core cardboard tube. For the one on the right in the picture (actually my center one), I just used more paper towel tube, cut a hole in it, duct taped it to the bottom of the chute.

I'm actually not finding any good pictures for the bottom 'mouth' part of the chute on the far right. I just made it out of the same standard cardboard, which I scored, folded, and duct taped.

One of the biggest challenges for all of these was getting it the right angle and the right length. I wanted to make sure that food won't get stuck in there, but didn't want the food to come flying out so fast that it wouldn't stay in the bowl. Additionally, I didn't want it to go too far over the bowl and get in the way of the kitties' heads. So it took some adjusting and testing, gut I finally got it working pretty well.

Challenge #3 - Stationary Bowls

Our cats tend to move their bowls all over the place...sometimes all the way off of the little platform. So my first idea of making the bowls stationary was to 'bolt' them down with a few holes in the bowls, a piece of plywood and some basic hardware:

1st method of keeping bowls stationary

A closeup:

Simple hardware - bracket, screws, washers, wingnuts

I used wingnuts because this is obviously a lot easier to unscrew by hand (as opposed to regular nuts). If nothing else, I knew this would be fairly easy to release the bowls so that we can wash them. Oh, and in case you're wondering why I am using a flathead screw (wrong kind of screw in this application), it's because I didn't have 'panhead' of the right size/length on hand.

Anyway, this seemed to work for a bit, but the screws got loose pretty quick (kind of like my head). I had to come up with something else. I'm not sure where I got the idea, but I thought if they had round (and tapered) bowls, I could make another little platform that would allow them to just 'drop in', so I headed to our local pet store, Petsmart. Found some nice round stainless bowls, so I got to measuring, measuring, then cutting. (Remember - always measure twice, cut once!)

This is what I came up with:

New platform

Side view with it propped up a bit:

Just showing how the bowl sticks down below the main piece of plywood,
but barely just under the entire 'height' of the plaform
I'm much happier with this - better bowls, stays stationary with no hardware, and very, very easily removable (and put-back-able)

Challenge #4 - Button issues

Below are the original buttons that I had put in place. I chose them because they're cheap, and easy to mount:

Original buttons

Well, I had major problems trying to get them to do 'double-click'. You see, I was wanting to have the buttons perform multiple actions - single-click to give the cats a 'snack', double-click to give the cats a bigger snack, and a 'hold' to continuously dispense food until letting go of the button.

I actually had already mounted the buttons before I got to that specific portion of the code. I tried other kinds of buttons and the double-click would work just fine in the code. The Arduino forum came to the rescue again. Someone suggested try using a different 'button handler' (my words, not theirs) - the 'OneButton' library. Well I did some tests with this library and the buttons worked a lot better. However, I had already implemented the 'other' button-handling code, and would have been a huge pain to re-implement the new code. (Remember, I'm a beginner at all of this)

Instead, I bought a couple new buttons and tested them out - they worked a lot better, so I decided to replace the really cheap buttons with not-as-cheap (but still pretty cheap) buttons since they work a lot better:

New/better/current buttons

Challenge #5 - Transferring the DS1307 chip

This was a bit of a strange one. It is purely an electronics problem. The problem is that, during development, I had connected everything up on a breadboard, so it looked something like this:

Circuit on a 'breadboard' (not the circuit for this project...just an example)

The main white rectangular with all the holes is called a breadboard. It allows you to build/prototype circuits, and is a common practice to use them while developing. During the creation of this project, I used a breadboard to build the different parts of the circuit (then finally combining them all).

Ok, so nothing unusual so far, everything worked great on the breadboard. The next step (for me) (I did not want to design an actual circuit board as I was not going to make multiple boards, or sell them.) is to 'move' (or recreate) the circuit on 'protoboard' (a more permanent substrate). An example of protoboard:

One kind of protoboard

Again, no problem, I've done this several times before. But wait a minute...the small chip (the DS1307 - the one that keeps the time) is going to lose power when I move it from the 'breaboard' and onto the 'final' circuit on the protoboard. Uh oh...we have a problem!

How do I move the chip from the breadboard to my actual board:

The eagerly awaiting chip holder on the actual board

Above you can see my mostly complete protoboard without the time-keeping DS1307 chip. Searching on Google gave me nothing. It's probably the search terms I was using. I did have a couple of ideas though. The first one was to build more onto my circuit - the parts that I would need to actually program the microcontroller directly on this board. You see, the way you 'program' the DS1307 chip is through another my case, the Arduino. However, this seems like a waste of time and materials as I'll probably only ever do this 1 time (with this circuit). My 2nd thought was very 'hacky' but would be quick and fairly easy. The idea was to solder 2 wires directly to the chip (sitting on/in the breadboard), hook up a battery (temporarily) to the other end, remove the chip (with the wires and battery in-tow), insert the chip into the 'chip holder' (on the protoboard), desolder the wires, be done.

There was at least 1 possible problem with this approach, so I had to do a test. I was worried that if I had 2 coin cell batteries hooked up at the same time, the voltage would double and fry the chip. However, I was pretty sure that doing that would be fine because they would be hooked up in parallel (as opposed to series), which means that voltage would stay the same, but the run-time would double, which is fine. I did my little test with a couple batteries and my multi-meter, and confirmed my thoughts - it should be safe for the little guy to be transplanted!

Immediately after moving the chip from the breadboard to the proto board:

The chip still has the 2 wires soldered to it after moving the chip to the final board

A closeup:

The 2 wires still soldered to the 2 pins on the little chip

The completed transplant, wires removed:

The 2 wires have been desoldered

As you can see from the above 3 images, I followed the steps I outlined. Then I confirmed that the chip kept the time during this silly process - so we have a successful transplant! Now you can call me Dr. Nerd!

There you have it biggest challenges with this project and how I was able to overcome them. Hopefully this may help someone out there doing something similar.

Next up (and probably lastly for this project) we'll talk about the electronics.

Automatic Cat Feeder - Introduction/Overview

Completed Automatic Cat/Dog Feeder

Above, you will see my latest project - the Automatic Cat Feeder. It is Arduino-based, and built with various off-the-shelf hardware, and some parts that I modified.

How does it work? The Arduino is programmed to dispense food @ 5:15AM and 5:15PM for our cats' daily meals. The Arduino basically turns on the motors (1 at a time) to turn the food-dispensing paddle for a pre-determined amount of time to dispense the right amount of food. The food drops out of the dispenser and down the various chutes you see, and into the 3 bowls.

Before I go any further, I must give credit where it is due. First, I borrowed heavily from this guy for the actual dispensing system. Second, I had a couple of issues on the electronics side of things, but the great Arduino community over on the Arduino forums offered great advice to help get past the hurdles. Lastly, driving the motors was made very simple thanks to Sparkfun's motor driver board

Why I created it
Our cats like to be fed at consistent times of the day, and that's not always easy to do. For various reasons, we can't always feed them at the exact same times daily. Sometimes they may be fed hours later for dinner, and we feel really bad about this.

Now why didn't we just buy an off-the-shelf product? We looked into this and found that they were just too expensive, not very flexible, or were easily defeat-able, allowing the cats to gorge on the food whenever they please. I don't like the idea of an inflexible system that I have little to no control of (yes, I may be a bit of a control-freak). If I build my own, then I have complete control of it, so I can change it, add features, etc. myself.

Before starting this project I had a few requirements in mind:

  • Must be food safe!
  • Must be reliable
  • Must cost less than comparable commercial feeders
  • Must be customizable
  • Must have some kind of audio notification to inform the cats that it's breakfast/dinner time

Is that asking too much? Nah

Ok, ok, I know you want to see a video of it in action, so here you go:

I had in my mind that I would build this with network connectivity to give us the ability to monitor/feed them remotely, but for a couple of reasons I didn't. First, this project already took me a long time to get everything worked out, and just wanted to get it installed for them. Second, an Ethernet Shield or Wi-Fi shield are fairly expensive ($35-$45), especially compared to the new ESP8266 (around $4) that's come out recently. I say recently because I actually started this project a couple of years ago. So why didn't I incorporate the ESP8266? I don't know how to use it just yet.

Ok, I'm sure some of you want to know just how much everything costed me. Price breakdowns are in the Bill of Materials (linked above), but the cost of everything was $190. Yes, that's expensive, and a lot more than I was anticipating. The 2 most expensive items were the motors (about $25/ea) and the cereal dispensers (also about $25/ea). That's $100!. Originally, I was going to come up with my own food dispensing system, which would have saved me over $50. Additionally, I feel that if I would have shopped around and done more research I could've cut the cost of the motors in half. As I'll talk about a bit in future posts, I got impatient and decided to just go the route I did.

Also remember that I'm feeding 3 cats with 2 different kinds of food...your situation may not be as complicated.

In conclusion, I wanted to let you know that there will be more info coming. In the next couple/few posts, I will go over some of the challenges I had with this project, hopefully saving you time in the future. I will also talk about the individual components in more detail (yes there will be videos). I'm not going to do a full tutorial like I did for my Garage Door Controller, but there will be some pretty good detail, hopefully enough for you to replicate if you want to.

Below are some links for you to use if you want to replicate this system, or parts of it.

Arduino code on GitHub
Fritzing file (actual .fzz)
Fritzing file, exported to .png image
Fritzing file, exported to .pdf file
Bill of Materials (Excel)
Bill of Materials (Open Office)

I haven't created a 'digital' schematic yet, but if/when I do, I'll update this post with the link to it.

Well, I hope you've found this post/project useful and/or interesting. Feel free to leave a comment if you have any questions/ideas/suggestions.

Want to know what the challenges I encountered, and how I overcame them? Well, that's exactly what my next article is about

Sunday, May 3, 2015

Source of electronics woes in my garage discovered

It's been around 4 years that I've been having strange problems with 'homemade' electronics devices in my garage.

It started off when I built a (semi) 'automatic cat door'. My little device allowed our cats to push one button (mounted to the outside of the door) when they want to come in, and another button (mounted on the inside of the door) when they want to go outside.

After I built a working prototype that worked flawlessly 100% of the time in my testing, I moved the circuit to a prefboard, installed everything on the door, and thought I had the project completed - (this is a video on my completed project). However, it didn't take long to notice that it was behaving strangely - it would not respond to button presses sometimes, the servo wanted to keep moving even though it hit a limit switch, the servo would go the wrong way, etc. I would have to power cycle it to get it to work properly again. I was never able to figure out what was wrong with it, but the light shone very recently and now I am confident that I know what the problem was...(don't worry, I'll reveal the problem/solution at the end of this post)

A little later in time I purchased this really cool Internet-connected sprinkler system:
But I had a very similar problem with it not behaving properly...see one of my threads about it:!topic/rayshobby/eeiMdxePBUs
Again, myself or the creator of that device was not able to figure out the problem. So I would have to constantly check on the status and make sure that it was working...when it stopped working I had to power cycle it.

Lastly, I developed an automatic Garage Door Controller. It took months and months of development, and I tested it a lot in my 'lab' (read: my very little bedroom in my house), and it worked wonderfully for months before I took it into the garage to test/install. When I did finally install it in my garage, it was so exciting, and it worked great for a couple weeks. Then I started having strange problems where it wouldn't respond to my commands, wouldn't let me connect to it, etc. I would have to power cycle it once or twice a week to get it back working. I took it back into my lab and tested and it would work for weeks with no problem. I couldn't figure out what was different in my garage and my lab. I spent months trying to figure out what it could be, posting on forums, etc. Recently, however, I figured out!

The suspense is killing you, right? Drum roll please:

Ok, so I don't know which one of the above 2 Insteon devices is the culprit. I had them connected together in my garage, and for the test, I pulled both of them out, and haven't tested 1 at a time yet. However, ever since I pulled them, I haven't had any problems with the sprinkler system or the garage door controller (and if I was a betting type of guy I would bet that if I reinstalled the automatic cat door, that would be working great too). It's been about 3 months now, and things are still looking great.

I plan on trying to isolate which device of the 2 is the culprit, then I will try to get in contact with Smarthome/Insteon and see if they know anything or have any useful information about it. I will report back here if there's anything useful I can share.