Raspberry Pi Zero W and Mi Flora plant monitor

Share on:

The new Raspberry Pi Zero W is the perfect pairing to go with the Xiaomi Mi Flora. The Flora is a bluetooth stick you push into the soil next to a plant and can be polled over Bluetooth LE for the sensor data - soil moisture, temperature, light and soil conductivity.

Part list

Raspberry Pi Zero W. I used Pimoroni (£9.60 + £2.50 postage) as they’re great and ship fast. You shouldn’t need the Adapters kit if you’ve the necessary adapters already, or you might get away with setting up the Pi headless without them anyway.

Xiaomi Mi Flora aliexpress ($9.79) banggood ($14.99). Took about 20 days for aliexpress to ship this to the UK.

Total costs are only around £20 / $30, which is really good value for the ease of setup and sophistication.

Setup

I’m assuming you have a working Pi installation of the flavour of Linux of your choice. Personally I’m an Archlinux fan. To get bluetooth working on Archlinux it’s worth checking my instructions here.

Scan bluetooth for the MAC address of your Mi Flora:

$ sudo hcitool lescan

It should come up as Flower mate :

C4:7C:8D:XX:XX:XX (unknown) C4:7C:8D:XX:XX:XX Flower mate

Download and build my command line tool (do this on a desktop with Go installed):

$ go get github.com/barnybug/miflora/cmd/miflora $ env GOOS=linux GOARCH=arm go build github.com/barnybug/miflora/cmd/miflora

Copy the executable miflora onto your Pi, then run:

$ ./miflora C4:7C:8D:XX:XX:XX hci0 Reading miflora... Firmware: {Version:2.6.2 Battery:88} Sensors: {Temperature:11.9 Moisture:38 Light:0 Conductivity:114}

You should see the firmware and sensor readings from your Mi Flora. It’s working!

Logging data

I use my own home automation system with data logged in Graphite and displayed in Grafana to provide monitoring of the Flora’s sensors.

If you’re not so keen on home grown, there’s plugins for popular home automation systems like github.com/open-homeautomation/miflora.

Range and power

I’ve not yet experimented with the maximum range possible, but it reliably reads over a distance from inside->outside of at least ~5m. Since Wifi has a greater range than Bluetooth, you can optimally position the Pi (in a garage / shed for example), so long as you can safely run power to it.

A solar powered Pi would be a great way of doing this, but be sure to protect the Pi from the elements with a decent IP rated enclosure.

The Flora is powered by a single CR2032, reading every 30 minutes is a sensible interval and battery life should be roughly a year at this rate. This will likely depend substantially on the effect of temperature on battery life, but your plants are also likely to suffer if it gets below 0C!

Irrigation

It’s a still bit early in the year (mid March), but once the tomatoes are out in grow bags, the plan is to hook this monitoring up to my automated irrigation system - which consists of an electric waterbutt pump connected to Hozelock irrigation kit piped to the plants.

This pumps a controlled amount of water to the tomatoes twice daily (6am and 6pm), which will be dependant on the day’s conditions.

With some experimentation and calibration it should be possible for this to form a feedback loop so it delivers exactly the right amount of water to restore the soil moisture without oversaturating the soil (which tomatoes really don’t like!).

Also the irrigation could kick in on those really hot summer days and deliver more water mid-day if the plants are getting really thirsty, which is when plants in greenhouses/growbags risk getting damaged by dehydration. Something even the most attentive gardener is probably guilty of at least once (ehum)!

Growing out

The system is also easily and cheaply expandable with more Mi Floras (given their attractive price), and you just need to add the MAC addresses for the extra devices to your polling job.