Build log: coffee container plant IoT — pt 3

Jacob David C. Cunningham
11 min readAug 8, 2020

Disclaimer: not a tutorial

Repo

Tech: Apache, raspistill, CRON, Python

Started writing: 07/24/2020

Updated from 12/30/2020

Look how they massacred my boy

I setup a time lapse camera hopefully to catch it perking back up but no it just kept sinking and sinking… sadness smothers us

Ahh… I overwatered it… tried to save it but its fate is sealed. Planted new ones yesterday only four or five that sprouted.

Update from 12/07/2020

This is the biggest Apple tree I’ve grown from a seed so far. Unfortunately I may have waited too long between the mosquito dunk treatments as one of the smaller ones died recently. I’m fearing for the biggest one, maybe it’s stronger/will recover more. I did have to change the camera mounting/angle due to the “tree” being too big and also it was bending towards the light, figured should go straight up if possible. Also trying to grow some potatoes… probably way too small. I’m not really after it for fruit just want something to grow. Potatoes seem much easier to grow/less finicky. The algae cups are neat… not intended.

Update from 10/09/2020

This has been a bad journey… it took me a while to figure out how to get rid of these white worms that were from these gnats. Someone suggested mosquito dunks to me and that seems to be working finally. I went through several “generations” of Apple seeds that kept dying shortly after they grew some leaves because their roots were getting eaten. The gif below is an 8-day sequence. The 50W growth light is on almost 12 hrs a day.

8 days in October — the soil does look nasty it has rotten potatoes, apple slices in it, methods to try and drive away the beasts. It is amazing though like why do plants grow?

What’s in here:

Planted first few Apple seeds that sprouted. Started writing the web interface but lost interest for now until I have more data. Decided to add gifs in the future. I also decide to turn off the purple light when taking pictures and later added a 1W white LED that turns on to take a photo. I bought a bunch of parts eg. capacitive sensor, a water pump, etc… will do some neat stuff for this project. That’s not in this post, those parts haven’t all come in yet.

Start

Well, got a fresh brain, woke up from a nap, the lamp turned itself off nice.

This Pi only has a 16 GB SD card, the full res images are 3.1 MB or so. I think I’ll use smaller images and then say per week take 1 full res image. I’ll just take 1280px by 960px images for now. Too bad it’s pitch black(night) right now but I can still write the code for the image capture/website. I am curious what happens when you specify a resolution for the camera to take a picture at, does it just chop the image?

13GB free

It would be neat to write some software to make a gif (timelapse) from photos, but probably exists already. Probably add that feature in.

Some design

I don’t want to get too overzealous as I don’t want to sink most of my free time on this. The left panel is showing recent/past pictures and I had a thought about doing “fold” look backs eg. do the most recent 7 days, then show weeks, and then years… which I don’t know what happens if you click on those rows, loads those days/months?

Tasks

  • install Apache
  • add automated screenshot(CRON), move image to folder, allow permissions for Apache to read/display on web
  • store images in some pattern so don’t need to store file paths in db eg. /plant-screenshots/year/month/day … .jpg
  • build basic web interface to view images

I will prototype this stuff on my desktop as trying to develop/send over SSH/Filezilla is terrible. I guess I’ll take the image like middle of the day or afternoon so I have the purple light and ambient light. I can move these images to a remote server, have it “globally accessible” with a domain and all that but no need. I can do that but would take more work. With node/multr other helping libraries pretty easy to move/accept images. What is also cool is modifying your computer’s /etc/hosts file and then being able to route a requested domain eg. mydomain.com goes to your pi’s local ip address eg. 192.#.#.# so then you get a pretty looking url vs. using the ip. I’ve used that before but it wasn’t always successful, I was trying to block certain distracting sites for example and it worked so and so.

Got distracted a bit, back to it

Is it necessary to bust out a ReactJS app for this? Probably not… but I don’t know why not.

It just occurred to me, if the files have to be found to determine to exist… then you won’t know if there are any to look back/show as previous images(without trying).

I guess could add basic code that looks if there are any files found going backwards from current date.

Damn, updating software on the Pi Zero’s is brutal… it takes a while. Oh yeah, I can ssh in more than once.

12:10 AM

Update, so I’ve written the code that takes the picture/moves it. I’m again, cutting initial thoughts/ideals and just building something. I’m currently “plagued” with thoughts of “is this worth my time, is it going to make me money, etc…” I’m “trying” to learn Shopify so I can develop apps for it eg. build API connectors and whatever but that’s a wall too/have to spend time. Scour forums to try and find things to build/solve. Part of that/before that, I’ll be utilizing pretty much a vertical calendar I have in mind to remind me that time is finite and I need to get my shit together/try harder so I can be free of worrying about needing a job etc…

I think I’ll have it use localStorage to store what dates it went to search against/indexed.

I am losing drive to finish this thing, I want a working interface to start with at least /bare minimum. Kind of funny when you know of impending/upcoming danger. I know what I want, freedom. You have freedom by having your own sources of income. I have not tried, so that’s mostly what I’m trying to make myself get into. These random side projects are cool but they don’t help me achieve that goal other than maybe helping me stay savvy/know my stuff for base knowledge where I’m hire-able.

I always like this part, blank, making something out of nothing (let’s not forget the create-react-app boiler plate) standing on the shoulders of giants as they say “Back in my day we mined the ore for our CPUs”

It’s hard though, this feels like a chore. DO IT!!!

1:03 AM still messing around

While I designed it with a sidebar in mind, I’d rather not have it displayed by default. I’ll toggle it to show up with a menu on top-left. I had a thought, the initial load/first thing you see will be looking for files if it hasn’t been done before. I used to use patterns a lot from subtlepatterns (before it was acquired) but that’s hard to pick a good one that makes sense.

I think I will have better drive on this when I have pictures to work with.

1:27 AM

Stopping for now, switching interest elsewhere

12:54 PM

Just woke up, let’s see if it took the pic. Also this looks like it’s working, my Avocado is sprouting new roots underneath. Oh yeah it’s there. This won’t be eventful until the Apples are planted, they are the main focus.

Resonance by Home plays…

Wednesday July 29, 2020

I’m feeling impatient/antsy. I want to plant the Apple seeds that have already started to sprout. So I will. I still have not worked on the interface at this time that organizes/pulls/displays/cycles the images. It’s not really a challenge, just haven’t had motivation to do so.

In the past I just dumped these under some soil and they sprouted right up. Now I’m delicate, because last time I had a whole batch die eg. 6 apples worth. This is only 4 seeds right now, rest are still germinating.

I’m also concerned as my cat has discovered the camera ribbon cable.

Planted 07/29/2020 4.5 hrs of light left for the day. The right-most image is what the time-lapse will be that’s a photo from the pi cam.

Sun Aug 2nd, added four more seeds

Kitty

I’m doing a mod to the code where it turns the growth lamp off for the photos so they look normal/not purple. The green of the leaves will be more apparent. Good news is at least two of the seeds are green/about to pop up their first round non-leaves. I don’t know if I over watered the pot, it has no drainage.

Yeah I will have to omit the initial shots as the time lapse will look bad transitioning from purple to normal colors.

Tuesday 08/04/2020

Ooh look at this, actual green. I did the mod to turn off the growth lamp for the picture. I had seen the left leaves but it was hard to tell/see the obvious green under the purple light.

It is a little dark… but better than purple

Last thing I’m waiting for is a time lapse. This will also be the last post I’ll do where it’s the full thing/thought for thought. I’ll still do that, use my time-logging html input thing but will provide that as an optional full dump somewhere like pastebin(mostly so not docked negatively as duplicate content for SEO).

Feature had a thought, add a little indicator every now and then just based on a daily interval saying “water me senpai” or something dumb like that heh.

Friday 08/07/2020

So I did not realize till now that you’re not supposed to keep seeds in the fridge if you’re trying to germinate them… I think I got lucky before because the seeds were already rooting.

I do have some good news, I bought more stuff eg. a capacitive sensor, a peristaltic pump, and other stuff so this will truly be a little automated garden. I’m also going to add a white LED that turns on for the camera since the ambient light is not reliable for good timelapse pictures. Unfortunately each day the seeds grow so fast it’s hard to see a smooth progression the leaves almost immediately appear within a couple days. The progression between each day is a lot. I guess not a bad thing, it’s working.

For the web interface/code will also add automatic time lapse generator(just gifs from images) and add ability to manually control stuff like the water pump… at some point may work in live video feed by webRTC not sure. I’ve worked with web feeds before but usually the device is attached to the browser I’m working on eg. webcam or phone.

From 08/07/2020 the one on right looks great, this is why I need that white LED to turn on while taking a photo, it’ll just run off GPIO

There is some exciting stuff though, I’m pretty sure I’ll be using a mosfet to run the pump. You can do a relay but I think the mosfets are fine eg. rating exceeds max current draw… have to use a flyback diode as someone suggested though.

Saturday Aug 8, 2020

I’m attaching the little white LED for the photos. It’s super lazy/easy, one of these 1W LED’s attached to a metal rod. I’m using GPIO to turn it on/off. I was trying to a put a resistor on it but it wouldn’t even light up after that… so I guess it’s fine. The voltage from the GPIO pins is within range though on the upper end.

I have to figure out what pins to use based on the available pins, the stepper use some already.

There was a project I was working on with automated Robinhood trading where the premise was the socket server had this red/green light to indicate if I was winning or not and I called it the depressed LED because it would always be red heh.

I have to figure out the pins that I have available still so I can just stick the pins in and have it work. I’m stealing code from my unfinished Robinhood trader python code ha, I don’t know how to read stocks so yeah it didn’t really go anywhere, not to mention the day trader thing/low funds at the time, I may get back into it at some point but idk.

Oh… I intend to use an MCP3008 ADC at some point, hopefully I still can.

I’m using 18/23/24/25 GPIO pins for the ADC, that’s based on the Adafruit MCP3008 tutorial btw. So I’ll just stick by the stepper pins and use GPIO5 for the white photo LED.

Jank City

Video of it working, I also decided to just take images at full res, which it turns out that’s why the photos kept looking blurry despite the lens being focused as best as possible. It’ll be an excuse to finally use say Open CV to crop the images before making a gif.

I think this post is getting long. I’m working on writing better, more condensed stuff, but I will still write in “time-stamp” format but it will not be the main thing you see.

I’m still not at the point where I want to build the interface code yet… maybe when I get more images/the rest of the parts eg. the sensor/pump.

There’s a lot of cool stuff I can do, like with the pump since it just comes out of a little 2mm tube, you can’t really spread that around nicely… you could build a basic little disk thing with wholes(3D print) and the tube goes into that… but… BUT you could make it super complicated using a pan/tilt servo and a programmed sweep pattern to evenly distribute/pump water.

But yeah… I’m also eventually going to leave this platform just because, my own content. I’ll probably finish this build up on here and then that’ll be it, although I still have to setup my own blog and what not… deal with hosting images and what not.

--

--