I got the WiFi working on boot on the Raspberry Pi. I'm still a bit of an Arch noob when you get down into the guts and I was mistakenly using both NetworkManager and netctl. Dropping the latter and learning how to use
nmcli to create a system connection and everything came to life. These projects are all about learning.
There are several GPIO crates for Rust. Again, I learned something new - that GPIO is a sort-of core Linux thing, not something Raspberry Pi specific. I will try a few out, but I picked sysfs-gpio more or less at random and gave it a go. I now have a blinking LED driven by Rust!
Next I wanted to get I²C working and read the temperature/humidity/barometric pressure sensor. This was a bit more involved and I admit I had moments of wondering why I am doing this on Arch instead of Raspbian where it all just works out of the box, but again the learning motivation prevailed. As long as I push the edges of my comfort zone and still make progress I'm happy. The basics of getting I²C working are covered in the Arch Linux Arm wiki. The sensor I have is the BME280, which has a rather nice tutorial here, which is in Python but was really useful to confirm the hardware and interfaces working correctly. I'll tackle porting the code to Rust in time.
I also got the moisture sensor to work, on its digital output at least. I decided that a simple wet/dry binary indication is a bit coarse and doesn't lend itself to plotting nice graphs, so I'm going to get the analog output to work. I can measure the voltage on it, which is 3.3V when dry and dropping down to about 1.5V when the sensor is completely submerged in water. The Raspberry Pi doesn't have any analog inputs however so I've ordered an Adafruit MCP3008 which provides 8 channels of analog input readable over I²C. To open the water valve I also ordered some darlington transistors with 1000x amplification, so I can drive that big 12V solenoid with a tiny I/O current from the Pi.
The hardware basics have come together really quickly and I'm feeling the thing that's really holding me back now is comfort writing Rust code. So this week I'm switching my focus to learning Rust. I'm working through the book and will have a stab at the Rust Koans pretty soon.
I'm starting to think about software system design. I'd like to keep it all modular and lightweight (a) so I can remove or turn things off if they prove problematic or not worthwhile and (b) so I can add more in the future. Plus I want to make use of the concurrency features that Rust is famous for, so I'm thinking along the lines of running a thread for each sensor, each reporting its reading(s) at a configurable interval. These reports will all queue up on a single consumer thread which will write records to an sqlite database. The core irrigating thread will wake up periodically and add some water if the recorded moisture is too low. And finally I'll generate and publish graphs of the collected data periodically. Testing such a modular design should be fairly straightforward.
In the would-be-nice region of the priority list is some kind of remote control and tweaking of the parameters. I'll put a camera on the Pi and grab a photo of the plants every day to see how they're doing but that's probably just a shell script and systemd timer rather than anything clever in Rust. Watch this space for updates!