Wednesday, November 03, 2021

Revised 3D Printed Stargate, now with blue LEDs!

A couple years ago I started diving into the world of 3D printing, and also electronics, in order to produce a 3D printed Stargate from the TV series, Stargate SG-1. You can read about that journey on my original blog post here: https://jeremygustafson.blogspot.com/2019/10/3d-printed-stargate-journey.html

After publishing my Make on Thingiverse and posting a video of the gate on YouTube (https://www.youtube.com/watch?v=J1-aj0O4Irc), many folks commented that I should add a strip of blue LEDs in the center ring to make the wormhole effect more, well, worm-hole-y.

It took a while for me to get around to it, but I tweaked Dan/Boogle's original circuit board design to add an additional connection (and transistor) for the LED light strip, as well as tweak a couple other things about the board that had confused me as a newcomer to electronics, so hopefully now it's ever-so-slightly more beginner-friendly. I also spent a lot of time verifying and updating my instructions for the latest Raspberry Pi software, until I could successfully start from scratch and copy-paste my own instructions to set up a fully-functioning Stargate Pi.

My new circuit boards arrived from China this past summer-ish and there they sat, waiting for me to get over a weird energy hurdle required to "just start." As I've discovered about myself, avoidance is my preferred coping mechanism, and it takes being in a healthier emotional/mental place in order to get my bum in gear and start working on a project I'm nervous about. Why was I nervous? Because I'm terrified of failure. I'm working on getting over that.

One of these failure hurdles mentally blocking me from working on the stargate was that I still hadn't fixed my 3D printed warp core, which developed some flaky wiring issues almost immediately after I wrote about it. If I literally pushed on the whole warp core stack in a particular direction, all the lights worked, but if I let go or pushed it the other way, the bottom section of lights went out. I put that one off for ten months, then in October thought of a different, more reliable way I could wire the lights. I disassembled the whole thing, completely re-wired three quarters of the lights (one of the four sections still seemed sound, so I left it as-is), and re-assembled, all in less than a week. It was done in time to put on display when we had friends over for Halloween.

Succeeding at one project seems to give an energy boost, so I took advantage of that and jumped into the Stargate re-wiring. I hit some roadblocks with bringing the code from python2 (old, unsupported) to python3 (new, supported), namely that the new software drivers for the stepper motors somehow made the gate movements more... "chunky" is the best word I can describe it as. It sounded really horrible. I tried tweaking any number of settings but it just wasn't as good as the previous software. And, without wanting to bore you too much with programming details, there's one annoyance that can be easily explained: in the old software, you could say "move this many steps, and at this particular speed" and the stepper motors would move that many steps and at that particular RPMs. Easy. In the new software, they removed both of those features; you could only ask it to move one step at a time, and there was no speed control. Seems stupid. So I wasted a lot of time adding for-loops and "sleep"s to try to get the motors to run like they did before, to no avail.

Eventually, I said "this new software sucks, lemme see if I can get the old version of this to run under python3." Fortunately, it ended up being easy. When I tried doing this before, I only paid close enough attention to see the software throwing errors, and I foolishly assumed I wasn't smart enough to debug those. As it turned out, the only - and I do mean only - issues in this particular code, was that some of the formatting changed between python2 and python3. For instance, instead of something like this:

print "Some message"

It now needed to be formatted like this, with parentheses instead of a space:

print("Some message")

Once I understood that was literally the only issue, updating the old code to work was easy, and I was pretty much done. All that was left was polishing my documentation, uploading the new code, making a new video for YouTube, and writing about it (here, and also on Thingiverse). And with this project complete, now I can move on to finally finishing my 3D printed Stargate Atlantis.

But for now, I'll leave you with this video of the revised SG-1 gate in action:

Sunday, June 27, 2021

Aquaponics

A few years ago, Alissa and I saw an aquaponics display at the State Fair (in the hexagonal "hunny building" as I call it, though I'm sure it has a real name). As I often find myself saying, I exclaimed "that looks neat, let's do that!" Alissa agreed, and thus began a multi-year journey.

For the uninitiated: aquaponics is simply using fish poo to feed bacteria (and optionally worms), which produce nitrates to feed the plants, which then filter the water before it gets returned to the fish tank. You can grow pretty much any veggies or other plants you want, as well as edible fish such as tilapia. This can make aquaponics appealing and useful in extreme food deserts, since the only "input" you really need is sunlight and fish food.

Since we are lucky enough not to suffer from food scarcity, our aquaponics goals were much less ambitious; basically we just wanted a "free"1 source of fresh veggies for our bunny rabbits, Luke and Daisy, during the winter months when our outdoor garden is frozen.

To that end, I started researching. Somewhere along the way, I discovered Sylvia Bernstein's book Aquaponic Gardening, A Step-By-Step Guide to Raising Vegetables and Fish Together, which was, I must say, the most amazing and helpful resource I could have possibly imagined. It was exactly what I wanted. Each chapter discussed a new aspect of system design, and listed the pros and cons of each option you might choose. For instance, the choices between a basic flood-and-drain system vs a bell-siphon; whether to have a sump tank, and if so, having one or two water pumps; what grow media to use; which type of fish to raise; what kinds of lights to use; and so on. Each chapter simultaneously revealed to me how much I didn't know that I didn't know ("unknown unknowns," you might say), yet also gave me the confidence to make an informed decision. As I read, I collected quite a lengthy set of notes for later reference when I reached each step. My favorite piece of advice from the book was the reminder that water weighs a lot (8.33 pounds/gallon), as can your growing media, and so she advised locating your aquaponics on the lowest level of your building, so that your system doesn't start on the second floor and end up relocating itself to your basement.

After finishing Aquaponic Gardening, I drew a pencil and paper sketch of what I thought our system should look like. In fancy lingo, it would be a slightly modified "CHIFT-PIST" design, which stands for "Constant Height In Fish Tank - Pump In Sump Tank.” ("slightly modified" in that we have an additional pump in the fish tank, too). The main benefits of this design are that the fish tank water height remains constant (changing water height can stress the fish), and both pumps are constant-on (turning a pump off and on can shorten its life). If you're really into the nitty-gritty details, you can also read this footnote: 2

It's been long enough that I forget exactly what came first, but among our first tangible steps for physically creating this thing were: hauling over one of my parents' old fish tanks that they'd been saving for us (a 46-gallon bow-front, with display pedestal), purchasing a heavy-duty wire-frame shelving unit from Menards, and ordering two of these hefty grow beds (they weigh a figurative ton - shipping alone was $100 for the two beds!). I also scoured the internet to find the best price on hydroton, a clay-pebble growing medium for the plants; I eventually found Greener Gardens in Richfield had a good price, and Alissa and I had a fun outing there to purchase 400 pounds of the stuff.3

Alissa's sister Abby helped us rinse all the hydroton as we added it to the grow beds on January 4, 2020. (Er, excuse me, Winnie reminded me he actually was the one who did all the work. My mistake.) By this time I'd also made countless trips to Menards to acquire various PVC pipe fittings in order to assemble the plumbing, as well as spent countless hours researching grow lights.4


With the hydroton and plumbing in place, on March 14, 2020 I connected a hose to our utility sink and added 100 gallons of water to the system and turned the pumps on. It was very exciting to see water flowing through everything for the first time! As expected, I needed to tweak things, all the way from realizing I should probably use a food-safe PVC glue, to more minor adjustments of the water valves leading into the grow beds. My two most frustrating challenges over the following months were getting the siphons to stop after draining each grow bed (eventually solved by altering how far down into the sump tank the drain pipes went), and removing a super-annoying gurgling noise from one of the pipes coming into the grow bed (solved by running more water through it, rather than less, I think resulting in less empty space for air to come back into the pipe).

Once water was flowing, I started "cycling" by adding Ammonium Chloride (in the absence of fish waste) to encourage bacteria colonies to take up residence, and somewhere in here we added our first plants, too. I tested the water almost daily to watch for nitrites (which would indicate the presence of ammonia-eating bacteria), and then waited not-so-patiently for nitrates to appear, indicating that the tank was fully cycled and ready for fish. After days then weeks of testing but not seeing any nitrates, I kept adding more and more Ammonium Chloride, to no avail. I was baffled.

I bought some cheap water test strips from Amazon and was shocked when I dipped the strip into the water and saw a nitrate reading off the charts (like, 140+ or something). I went back and re-read the directions in my original water test kit, and realized I'd been testing for nitrates completely the wrong way; while with the pH test you just have to invert the test tube a couple times, for the nitrate test you have to shake one of the solution bottles for 30 seconds before adding to the test tube, and then shake the test tube a full 60 seconds afterward. I'd done none of that. Once I actually followed the directions, the test tube clearly showed an overabundance of nitrates.

This was both good and bad news. Good in that it meant the tank was, indeed, fully cycled, but bad in that we couldn't add fish until the nitrate level was back under control (down into the 10-20 range or lower). It took several months of partial water changes, adding plants, and adding a canister pump/filter with nitrate-reducing pads, before the nitrates decreased enough so we could add fish.

From the beginning Alissa has insisted that "fish are friends not food," so we opted for fancy goldfish (specifically, Shubunkin), which are not edible. We made an outing to Aqualand on February 7, 2021, and brought home three fish we named Huey, Dewey, and Louie. Sadly, one fish died within a few days after being sucked into the pump (I immediately added a grating cover around the pump to prevent that happening again). Another developed "fin rot," which, had we known the warning signs, we might have been able to treat, but because we didn't know to look for it, we didn't realize something was wrong until it was too late.

We worried about our water quality but after re-testing (and bringing a sample to the pet store to test, too), there didn't appear to be anything obviously wrong. We went back to Aqualand and bought one more goldfish, whom we named Silver (because he was all silver), and enjoyed his presence for about a week before he disappeared. There weren't many hiding spots in the tank, but we spent over an hour trying to find him. At one point, I turned off the pumps and a whole bunch of biologic-looking "stuff" came out of the fish tank pump, so we assumed he must have gotten sucked into there, or died/was eaten by Dewey and these were the remains. I used the canisters pumps suction to get most of the debris out and then turned everything back on.

A day or two later, I went down to feed Dewey and... there was Silver! We determined he must have been hiding in the fish castle (I could have sworn I saw a fish tail in there when we pulled it out of the tank, but then when we looked again we didn't see anything, so he must have been hiding way up in the tower spire or something). He was looking quite worse for wear, with his top fin gone - presumably torn off in trying to escape the castle decoration's interior. I put him into a bucket with tank water and medicine and a bubbler, and he died a few hours later. To the degree you can emotionally bond to a fish, I was really sad to lose yet another one. And we did remove the castle ornament so if/when we get yet another fish, there's no risk of it getting stuck in there.

Separately from the fish and water quality adventures, this project wouldn't be a Jeremy-project without me wanting to over-complicate things. My ambition from the beginning was to set up a Raspberry Pi with sensors to monitor pH, oxygenation, temperature, light, and water-level, that could email and text us within minutes if something started going "out of whack." While I planned for (and purchased) plenty of redundancy (two water heaters, spare water pumps, multiple air stones, and a UPS for the air pump), I also knew stuff could still go wrong.

Ultimately I've been able to achieve three of my five sensor goals. Let's talk about the successes, first. Once a minute the Pi checks for water temperature, lights on/off, and water height, and logs those values into a MySQL database. If the temperature goes out of bounds, or one of the grow lights is off for more than 15 minutes during the day (perhaps because we went to harvest kale and forgot to turn the light back on when we were done), or if the sump tank's water height falls below a certain level for an extended period of time (due to overall evaporation from the system), then the Pi emails me so I know something needs attention. I've also added a small LCD display to the front of the Pi box that will print warning messages.

Water evaporates surprisingly quickly, which is why I spent a lot of time thinking about the water height sensor. I think it's quite interesting, so I'm going to risk boring you with what I consider some fascinating details. I bought this expensive liquid level sensor from Adafruit, allowing the Pi to measure the water height in the sump tank. Unlike the fish tank (which maintains a constant height of water), the sump tank water level is quite variable. As both grow beds fill with water over the course of 5-10 minutes, the sump tank will slowly get emptier; when a grow bed is full, it will dump all its water back into the sump tank in less than 30 seconds. So, looking at the sump's water height at a single point in time isn't very helpful, because, for instance, if both grow beds are nearly full of water the sump tank water height will be fairly low, but that doesn't necessarily mean we're short on the total amount of water in the system, it just means the grow beds are full and about to siphon their water back down. So instead, I have the Pi look at the past 12-hours of water height data and find the highest water level during that time. I make an assumption that both grow beds will have emptied near-simultaneously at least once during that timeframe. After adding a "fudge factor" and doing some math based on the dimensions of the sump tank, I can know that if the highest water level was below 9 inches, that means we need to add 5 gallons of water. If I ignore the warning messages for a couple days and the highest measurement dips below 7 inches, that means add 10 gallons. And so on. By design, the Pi gets more insistent / annoying about it's warnings the longer I ignore them.

As for the sensors I couldn't get working, there's not a whole lot to tell other than... spoiler... I couldn't get them working. Oxygenation sensors run around $200 and once I discovered that price tag it was easy to say "hard pass." (I have enough air stones and water movement - particularly from the splash bar - that I'm not worried about oxygenation, and especially not $200's worth.) The pH sensor, on the other hand, cost only about $40 (though I later found a cheaper source)... plus hours and hours of frustration. While the small pamphlet included a list of common household items and their respective pH's, there was no guide on mapping the sensor's voltage reading to specific pH values. Nor could I find any help online to that effect. So, I sat down at the dining room table with a spreadsheet, and glasses of orange juice and distilled water and eye-droppers of pH Down and pH Up and so on. I wrote a short loop that simply printed the sensor's voltage reading once per second, and then I stuck the sensor into the various liquids and started recording values for each. The values were frustratingly not 100% consistent, and unfortunately because I wanted to measure pH's specifically within the 6.5-7.5 range, there wasn't a lot of "room" between the voltage readings in that narrow range. So, I didn't have a high level of confidence. Nevertheless, I thought I'd gotten it "close enough" and went ahead and stuck the sensor into the aquarium.

Apparently the sensor requires the water around it to be still, instead of swirling with currents like there are in the aquarium, because I got readings that were all over the place (one minute it might say 4.3, the next 2.6, and the next 11.5). I toyed with the idea of buying some little pumps that would every-so-often pump water out of the fish tank into a small testing container, take the measurement with the pH sensor, then pump the water back out and pump distilled water in. But, honestly, that seemed like over-engineering a solution that wasn't a huge hassle just to do manually. Using the test tube kit it takes 1-2 minutes to test pH and clean up, and it only needs to be tested every few days or once a week, so... I gave up on the pH sensor idea.

Overall, I'm pretty happy with how things have turned out. It's a fun bragging thing to say we've got an aquaponics setup (though I wonder what the neighbors think at night when they see this purple glow emanating from the basement windows). We are able to harvest some amount of kale and basil and parsley and so on, though still working through some possible nutrient deficiencies (I've been adding phosphorus weekly to try to help the plant leaves grow better). And our wanna-be-vegetarian dog Robin loves going downstairs to bark at her kale vending machine until Mommy or Daddy dispenses some kale into her mouth.



Footnotes


1 "Free" like a puppy. When you add up the cost of electricity, water refills, various pH balancing chemicals, etc, it's probably more expensive than just going to the grocery store.

2 In this design, water (and fish poo) is pumped constantly from the fish tank into the two grow beds (and also through a splash bar back into the fish tank, to help with aeration). Each grow bed has a bell-siphon, which means when the water in a grow bed reaches a depth of 10" or so, physics happens and the water gets siphoned down the drain to the sump tank (underneath both grow beds). Once the grow bed has drained, air enters the pipe, breaking the siphon until the grow bed fills up again. A pump in the sump tank, meanwhile, is constantly pumping water from the sump back into the fish tank. To prevent the main fish tank from overflowing, there's an overflow box hanging off the back which drains excess water back to the sump tank; the overflow box also has a small, self-priming pump attached so it never loses siphon. Lastly, the fish and sump tank pumps are each connected to mechanical water level sensors that will cut power to a pump if the water level drops too low in that tank, thus avoiding dry-pumping which would damage the pump.

3 Regular readers might recall our puppy Winnie writing about "Clifford kibble" in a previous blog post.

4 One wonders what Google makes of my search history sometimes. I'm sure they think I'm growing pot; for the record: we're not, but I will say the marijuana farmers on the internet know a lot about what are the best grow lights for indoor plants.