Do I need to water my plants?
The rationale behind this project was to design a project which could be built in school by students for under £15. I wanted to use a Raspberry Pi Pico, a sensor input and some form of output.
I decided to go for a plant watering monitor using a water moisture sensor as the input and an OLED display for the output. I designed a custom 3d printed watering can case.
The physical build is relatively simple and uses the following GPIO pins.
The OLED display and the water sensor both require 3.3V so I took one wire from the pin and split it to power both boards.
I have used a 132×32 OLED display. If you use a different size one you will need to adjust the width and height in the main code.
If you would like a more detailed set of notes on using the i2c OLED display on the Pico Les Pounder at Tom’s Hardware has written a very comprehensive tutorial here.
To identify the i2c pins you are using you can run this sample code from the Pico Documentation
print(“Freq: ” + str(machine.freq()) + ” Hz”)
i2c = machine.I2C(0)
print(“Available i2c devices: “+ str(i2c.scan()))
Next you will need the Micropython ssd1306 library for OLED driver for both i2c and SPI interfaces. This can be found here and should be saved onto the Pico.
It is worth noting that you may need to calibrate your code for different analogue sensors. Running the code from within Thonny you will get a numerical reading of the ‘moisture level’ which essentially is the analogue reading with the value for completely dry taken off (20500). I wanted to use 15 bars to represent the moisture level so divided this value by 3000. For completely dry this should be around zero. You can tweak the value of 20500 if needed.
value = read_sensor()
scaled = ((value-20500)/3000)
I have designed a custom case which fits the pico perfectly and has a slot for the OLED display. You will see from the STL files that both halves of the watering can are in the same orientation. When you slice the files you will need to mirror image one of the halves (it doesn’t matter which)