Outils pour utilisateurs

Outils du site


issue98:tutoriel_arduino

Ceci est une ancienne révision du document !


For my latest project, I thought I’d try to create an Arduino-powered automatic chicken feeder.

Initially, I had visions of great things for this, but it ended up being whittled down to something more basic. My initial plan was to have it loaded with sensors, hooked up to the Internet (WiFi/cable), and be able to control the feeder via internet and see the current conditions such as temperature.

Well, that idea died quickly. For one, I was out of WiFi range, so I’d have to use a powerline adapter (if you’ve never seen/used a powerline adapter, see last month’s article on powerline adapters and IP cameras). Easy enough, but then I was running out of power sockets. In the end I dumped the idea of using the Internet, kept the sensors, and have them display on a colour LCD instead.

Basically, here’s how it works: at certain times of each day, the servo should turn 90 degrees, thereby letting pellets drop for a short time, then turn back by 90 degrees to block more pellets from dropping. Meanwhile, the screen should show the current temperature, humidity, light level, current time, and time of the next automatic drop. It also has a button for a manual feeding.

Here’s the circuit I ended up going with:

We’ll get to code next month, but I had many hiccups along the way: • Time - I was using the DS3231 RTC (real-time clock) which is a great module, but is hellish to set. Initially when you first get it (from your supplier), it will inevitably be set to the wrong time and date. I tried many different things to set mine and just couldn’t get it. I ended up using a DS3231 I had used in a previous project, but it was set to -1 hour. So I had to keep adjusting for that in my code. • Alarm - Thankfully. the time library from the Arduino site comes with an alarm function, so that was a blessing. Otherwise, I’d have to keep checking the time to see if it was time to drop yet, and that would have been a nightmare! • False Positives - I’ve no idea why it kept happening, but it suddenly stopped. The servo would randomly trigger and open/close when it shouldn’t have been. For some unknown reason it fixed itself. • Screen Updates - There’s still a bit of a ‘bug’ on my display. The RTC, by default, returns values of single digits for 1 through 9, so when it displays (for example) 3 minutes past, it just displays 3 rather than 03. It means my time display is a bit weird-looking at times, and I couldn’t fix it… because… • Space - I wanted to use an Arduino Nano. Initially everything was fine, but as I was nearing the end of the project, I was really cutting it fine for space. My current code leaves only 200 bytes of space in the Nano’s memory. • Power - How would I power this thing when it’s nowhere near my laptop? Luckily I had an old power adapter that did 12V, 0.9A which would do just fine when wiring it up to the Arduino’s VIN pin.

Next month I’ll show some of the code and discuss what it does.

issue98/tutoriel_arduino.1435655090.txt.gz · Dernière modification : 2015/06/30 11:04 de auntiee