Sunday, November 1, 2020

Halloween project: A safe non-contact automated candy dispensing device.

    Our neighborhood never has a large number of trick-or-treaters, even on a normal year, but I do always make a point of having candy on hand for the dozen or so kids that we get. This year, I wasn't certain we would get any at all, and I wasn't sure I'd feel safe handing out candy face-to-face with them if any did come by. I had for a while been planning to just shut the outside lights off and lock the door, but decided, a few weeks before holiday, that I could hand out candy in a safe, no-contact way after all.

    I saw how some people were setting up delivery tubes for safe remote candy delivery. I had a cardboard shipping tube on hand that I could use for that, but I realized that I could do better than just dropping candy in by hand. I designed a carousel mechanism based around a FIT0441 blushless gearmotor, which would have compartments for up to 10 loads of candy.

About a 28 hour long print on my printer, one of the largest single pieces I've ever printed.

Room for 10 loads of candy, although one will always be empty due to being over the dispending hole.

    A microswitch acts as a position sensor, telling the motor when to stop after rotating to release the next load of candy. The carousel mechanism was mounted at the top of the tube, so that candy would slide down the tube after being released.

Quick assembly of the mechanism.

    To control the system, I used some old Arduino Pro Mini clone boards left over from another project a few years back. I ran into a significant problem with these, as the power supplies on the board failed, and in once case literally exploded, as I tried to run them off the 12VDC power supply I had on hand. The Arduino Pro Mini has an on-board power regulator which is supposed to handle a 12VDC input, but every one of these boards failed when powered at 12V. This was especially surprising as I had powered these exact same boards off this exact power supply when I first bought them a few years ago. I can only assume that they somehow degraded while in storage, but I'm still baffled. Perhaps this is just a lesson that I should be using actual Arduino boards rather than cheap clones.

    I eventually resorted to desoldering the failing power supplies from the boards, and using an external 5V regulator to power them instead. This worked with one of the three boards I had on hand, the other two seemed to be completely dead.

    At this point, it was getting fairly late on the day before Halloween, after spending a full day on getting the Arduino board to work, so the remaining wiring is a bit of a mess. Driving the motors was easy since the FIT0441 has a built-in motor control circuit. It has one wire for direction, and another which is used as a PWM speed control line. There's also a feedback line indicating motor rotation, but I didn't end up doing anything with that signal. Position control came from a big old microswitch out of my junk box which would be pressed to stop the motor after rotating.

Somewhat messy wiring in the final assembly, but it worked. The motor is driving the carousel through an inside ring gear built into the underside of the carousel. I made spaces for three motors, but only one was needed.

    I could at this point have made the device dispense candy with a button push, but I wanted it to be truly non-contact, not requiring either the visiting kids or myself to have to touch anything. I had on hand an IR emitter/detector assembly from a broken hands-free paper towel dispenser. This was fairly easy to hook up to the Arduino Mini. The IR receiver this module was using to sense reflected light was originally designed for TV remote control use, and was only sensitive to light pulsed at 38khz. Getting the Arduino to output a 38khz signal requires my directly writing to the timer 2 registers, as there doesn't seem to be any clean way that I could find through the Arduino libraries. Once I figured out how to do that, it was easy to get the proximity detector to sense when someone was holding their hands, or a bag or basket, under the end of the tube.

Downward-facing IR LEDs and sensor on the board at the bottom. Big red LED at top.

    As a final touch, I added a blinking red LED to attract attention to the end of the tube. My wife drew up an instructional sign, and sacrificed one of her old pairs of tights to cover the tube and all the exposed wiring.

Finished candy dispenser.

    We ended up getting about half a dozen kids, in two groups. The dispenser worked well, and with some guidance from their parents and me calling out instructions from inside, all the kids were able to get candy from it. I did determine during testing that Twix bars would sometimes jam in the cartridges due to being just the right length to get caught diagonally, but once I pulled those out the mechanism worked well enough.

    This was a fun project for Halloween, built entirely with parts I had on hand. I'm not sure if I'll bother with something like this again next year, though if I do I'll probably redesign it from scratch, as the rotating carousel mechanism for dispensing candy was really crude and could be made a lot more reliable.

Wednesday, April 15, 2020

Building my quarantine garden

This year I began an experiment in indoor micro-gardening, which I came to through a comvoluted path that started last year due to my wife's chronic medical issues. My wife is chronically ill, and among other problems has trouble regulating her blood electrolyte levels. Last year, after taking a careful look at her diet, she decided to start eating daily meals of foods high in potassium, especially roasted sweet peppers and mushrooms. This had a notable effect on her energy levels, to the point where she was able to actually start cleaning and shopping and doing other physical chores several days a week again.

Her favorite variety was a type of sweet pepper from Snyder's Farm, a local farm which had a weekly market near us. I'm not a big fan of sweet peppers, but I loved the hot peppers from the same farm for use in chili and marinades. We went through a lot of peppers that summer.

One day, as an experiment, she took some seeds from their sweet peppers and buried them behind a bush in our front yard. Astonishingly, despite being planted in terrible red clay soil and lacking any direct sunlight, the pepper seeds sprouted and grew. I transplanted them to a proper put with better-quality soil, and added a few dozen more seeds from other farm-market peppers. Many of those also sprouted. We didn't get any actual peppers out of those plants, of course, as they were planted late in the season, overcrowded and not at all growing under ideal conditions, but it starter me thinking about whether we could actually grow these same peppers ourselves with some care.

With the next batch of peppers we bought, I carefully removed and cleaned the seeds, then wrapped them in paper towels and set them aside. I also harvested some seeds from jalapeno and habanero peppers from the grocery store as an additional experiment. After drying them for a week, I discarded any that were discolored or mouldy, and packed the rest away over the winter.

Jalapeno, Habanero, Snyder Sweet, and Hungarian Hot pepper seeds.

At this point I didn't have anything other than vague plans for what I was going to do with these pepper seeds. I have nearly zero experience with gardening. I grew up in a house with a vegetable garden in the back yard, but as a child I had zero part in actually tending to those plants. My sole plant-keeping success prior to this was keeping a snake plant alive, which isn't much of a challenge as snake plants are only slightly harder to keep than a plastic plant would be.

We also are not living somewhere good for gardening. My wife and I live in a condo, and we aren't actually permitted to plant anything outside.  We own everything from the walls in, but the grounds belong to the condo association, and they really aren't happy when residents try to turn patches of yard into vegetable gardens. We can generally get away with putting planters on the patio, as long as we don't overdo it, but setting up raised beds would be out of the question.

Our second problem with growing anything is that our particular condo unit is on the northeastern side of our building. We get a few hours of direct sunlight through our east-facing windows, which is only really strong during the early spring until the line of trees that shade the side of the building grow proper foliage. We've always been grateful for not having to spend much on air conditioning, but it's not a great place to try and grow full-sun plants.

I didn't have great expectations for these seeds beyond throwing a few of them into a planter and maybe getting a few stunted peppers eventually. I marked down a good time on the calendar to try and sprout them, and then didn't think about them further for a while.

March eventually rolled around, and the world was getting concerned about this Coronavirus thing. My wife and I went on a cruise in early March, which turned out to be one of the last cruises that didn't turn into a quarantined ship, making it home just in time before everything got really bad. I bought a seed started kit, deciding to splurge on the 72 cell model. Following the instructions, I soaked the seeds in hot water overnight, then placed about 3 in each cell. I put the seed starter in front of an east-facing window, where it would at least get a few hours of direct sunlight per day. I still didn't have great expectations of results, thinking that maybe a handful of the seeds would actually sprout, since I knew they weren't getting as much light or heat as they should.

Pepper seeds, hopefully sprouting soon.

And then the plague got worse. Our state went into mandatory lockdown. My job was still considered essential, but the company decided to have everyone work from home if at all possible. I moved my entire engineering development setup home to our living room, and learned to teleconference with my co-workers several times a day.

This had the side effect of letting me check on the pepper seeds a few times a day, making sure they were optimally placed to get the meager sunlight available. And those pepper seeds sprouted, doing far better than I had expected they would. The Hungarian Hot peppers from Snyder Farms sprouted first, followed by the sweet peppers that my wife so loved.

Happy little pepper seedlings

The Habanero peppers sprouted slowly and reluctantly, only after being moved to a warmer spot with more consistent sunlight. And the Jalapeno seeds never sprouted at all. I don't know if they were a non-viable hybrid strain, or had been picked immature and ripened in transit, or some other cause entirely. The peppers from local farms were the ones we were most interested in growing, and every single one of those sprouted.

With far more pepper seedlings than I expected, the realization that fresh groceries were getting harder and harder to find, and the overwhelming urge to use the time I was stuck at home to do something, I decided to scale up my gardening plans. We still couldn't plant anything outside, but I decided to take the fullest advantage possible of our few hours of direct sun to try to grow peppers. We bought a cheap portable greenhouse, a handful of planter boxes and some planter soil. I took the grow-light that had previously been keeping the snake plants alive and set that up in the greenhouse to give the pepper seedlings a bit of extra light until they were ready to transplant.

Making the most of what little sunlight we get.

After a few more weeks of this, the pepper seedlings were large enough to transplant.  All except the jalapenos, which never sprouted at all.

True leaves are coming in, and it's getting crowded in there.

Finally, on a warm mid-April day, I filled the planter boxes with planting soil and transplanted the seedlings into them. I chose the best developed-looking plants, putting them into the soil spaced at about 4 inches. This is still more crowded than is generally recommended, but I expect that some won't survive being transplanted, and if they do I'll likely cull the smaller ones to thin them out.

Cramming in as many planter boxes as I can fit in there.

I fit a total of seven planter boxes in the greenhouse. Three full of hot peppers, three of sweet peppers, and one of the grocery-store habaneros that I still don't have great expectations of getting anything from.

I still don't have really great expectations for this garden.  I'll consider a single meal of peppers to be a success, and I'll be ecstatic if this garden means one less trip out to the grocery store (and therefore reduced chances of either my wife or I getting COVID-19). But victory gardens are essentially symbolic in nature anyway, born out of the need to be doing something even if minor. And having something living to take care of and nurture has been tremendously helpful to my mental state during this trying time.

Top boxes still get supplemental light from the grow-lamp.

And now that I have the peppers in their hopefully permanent homes, I'm thinking about enhancements. I have most of the parts on hand to set up a Raspberry Pi based monitoring and automatic light and water control system. Since I'm going to be stuck at home for the forseeable future, that will be a fun project to occupy my time.  Stay tuned for updates here.