PlantyPi - Raspberry Pi Pico Plant Watering Device.

by leonthorn2001 in Circuits > Raspberry Pi

2363 Views, 31 Favorites, 0 Comments

PlantyPi - Raspberry Pi Pico Plant Watering Device.

20230831_133606.jpg

I had previously written a blog post about my perspective towards IOT (Internet of Things) from the perspective of someone with a disability.

Within it I mentioned about how I wanted to try and create my own IOT device for watering a plant remotely and easily.

I thought I would share the project with you now that I had created it. It uses a WLAN connection to receive the time and activates a pumping mechanism at certain times of the day. I had also experimented with using IOT software such as Blynk OS.

In this fairly inexpensive project, with the use of the cute and powerful Raspberry Pi Pico W, we will be creating a device that will water our chosen plant, by using a WLAN clock.

This require some fiddly parts but its fairly straight-forward. I mean even the programmings been done as well so you have the easy part here!

Supplies

20230730_115054.jpg

What you will require for this project.

  • Raspberry Pi Pico W.

Please make sure its this exact model and not the 'non-wireless' model. I would recommend buying a pre-soldered header for this board as soldering it yourself might be a little risky.

I purchased mine here: https://thepihut.com/products/raspberry-pi-pico-w?variant=41952994787523

  • Raspberry Pi Pico Breadboard.

This is to help stick the jumper wires onto the board. My personal recommendation is to get a board that can hold the wires securely.

One like this one here is perfect: https://www.amazon.co.uk/gp/product/B0BFB53Y2N/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

It is a little more pricey but if you want your wires to be less likely to detach from the board then I would recommend it. Additionally, it marks out the location of each GPIO pin. So the extra price has it's perks.

  • Plant Watering Components

I bought this set of parts. This contains pretty much everything for this project to work, including the pump, tubing, power cable and a battery pack, which we will be deploying for powering the pump, meaning only one cable is required to plug in. We won't be using the moisture sensor but its optional for you to use if you so desire.

This can be found here: https://www.amazon.co.uk/gp/product/B088T64ZT2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

  • Jumper Wires.

Now this part is completely optional but it gives you some extra wires play about with. I found them very handy to extend the wires of the pump and the battery pack to the circuit.

This can be found here: https://www.amazon.co.uk/gp/product/B06WV7XHJ9/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

  • A computer with Thonny or equivalent.

Duh. How else will you be able to code this thing...

Set Up Pico W to Code

8b39160a-a69b-4fd2-992e-960e3b68a107.jpg

Before we can program on this thing, we will firstly need to install MicroPython and CircuitPython to allow us to access the GPIOs. This shouldnt be too difficult. But I will tell you how to do it, don't worry.

Lets start by installing MicroPython.

I will put the link to the set up page on the official Raspberry Pi website, incase my instructions comfuse you at all.

Here: https://projects.raspberrypi.org/en/projects/get-started-pico-w/0

  • Before anything else, make sure Thonny is installed onto the PC.

Plug one end of the micro USB cable into the Pico, and while holding down the BOOTSEL button, plug the USB into your computer. It should open up like a USB drive.

  • Install the Micropython.

When you open Thonny, the version of python should be appearing in the bottom right corner. Click that and a menu will appear. This is from the set up page i linked at the top.

Select the version of Micropython for the correct model, in our case the latest for Pico W.

Let it install. The device will disconnect but don't panic its all normal. Once that has been installed, your Pi is now ready to run Python scripts...yay!

Now lets install the PicoZero package. Go to tools, and then Manage packages...

  • Lets install the PicoZero, plug in.

Search for 'picozero' in the search bar. Click on it and hit install.

That's it! We are now ready to program on the Pico...yay!

Now unplug the device from your computer and lets get our circuit built in the next step.

The Circuit

20230831_133625.jpg

Here are the parts we will be requiring for this step.

  • The newly set up Raspberry Pi Pico W.

And from the kit:

  • The relay module,
  • Battery pack.
  • Pump

Dont forget our jumper wires.

Pre Step One: I would strongly recommend hooking up the battery pack and pump to some jumper wires to allow them to be more securely attached to the components.

  • To do this, sacrifice a jumper wire by cutting one end of it off and stripping part of the rubber casing off to expose some wire. Strip some casing off the battery pack and pump if you with, twist these wires together and secure with solder, or electrical tape. Tapes fine.
  • With jumper wires attached to these components, they will be easier to fit everything together.

Now lets actually make the circuit.

I have created a bare bones circuit diagram here.

I have tried to colour coordinate everything to each component. Lets start by attaching the Pico to the breakout board and wiring the relay to the board.

Firstly, place the VCC onto GP20 it should say 3V3 on the board and is above VREF which is also marked on this board, shove the wire in and screw it in.

The second, ground wire, goes to the lowest GND port on the right side.

Lastly is the AO of the relay going to GP16. Secure those wires in

Next up, the battery pack, attach the positive wire of the battery pack into the COM part of the relay and screw that in place.

The battery pack's negative wire will go fit onto the pump's negative wire.

Finally, plug the pump's positive wire into the NC. Completing our circuit.

You can place the GND and VCC of the breakout board anywhere really, just keep in mind that the AO will have to be changed in the script to whatever number pin you plugged it into.

Now then, lets get the script onto the device.

'Programming'

Technically, YOU are not programming at all. You are more, copy pasting a script in. No worries, I will explain how the code works anyway.

To create this script I had the help of some lovely people on the Raspberry Pi forums.

It can be downloaded here.

THIS MUST BE CONFIGURED FIRST, which is why we have Thonny or an equivalent.

You will need to put in your WIFI credentials into the 'ssid' and 'password'.

Additionally you can set up the scheduled times, duations and what specific hour, minute, or second you want the pump activating.

If you put the pump elsewhere on the breakout board, the value can be changed in the pump_pin setting.

One other thing is at the bottom of the script, where I add an extra hour onto the time being received, I wasnt sure how to make it use the BST instead of the GMT but that was my fix, You can add or deduct time from the value in this line here. (on line 101 specifically).

Apart from that, you can also add extra scheduled times if you want to in this area.

Just uncomment it here or even add another scheduled time if you feel like it, just make sure you specify the hours and minutes to be at 0 otherwise it will keep turning on and off for an hour, drowning your plant. Not good!

Other than that...

Lets explain how it works a little bit.

  • Firstly is connects itself to the internet. It will attempt to connect to whatever SSID and Password has been provided in the script.
  • From the information given, it will constantly update itself with the time value we are asking the device to get. I am using the hour value to add an hour onto it to get a more accurate time for BST, as I couldnt figure it out. (Please do tell me how if you know!)
  • Once the hour, reaches the scheduled value and is at minute zero and second zero specifically, the pump function will activate, turning on the pump for the allotted time we provided. (in my case, 5 seconds) and then will switch off until the time reaches the scheduled time again.
  • And thats it! It repeats this indefinately. Until we unplug the circuit anyway.

Downloads

Switching the Device On

20230831_133657.jpg

Lets plug everything in.

  • Make sure the pump and battery pack are plugged into the correct places.
  • Place some batteries into the battery pack, make sure its off for the time being too.
  • Plug the micro USB cable into a wall socket of appropriate power source.

The relay will make a 'tick!' which means the pump is off (the default state).

  • Once you hear that sound, switch the battery pack on.
  • Place some tubing onto the output of the pump, and place the pump into a container of water.
  • Place the tubing onto a plant or another container if you want to test it first.

Now the pump will power on at whatever time you specify, without you having to even think about it. Just make sure you check on the moisture levels so you don't flood the plant.

And there you go, one internet connected plant watering IOT device. Using a WLAN clock! For the last part of the guide I will put some other useful information.

Optional Stuff

20230831_133644.jpg
  • A battery pack doesn't have to be used to power the pump, and a 6V DC cable can be used instead which can go into a power source of your choosing. If you do I would recommend obviously a 6V DC cable but one of these little input output plugs.
  • Buy those here: https://www.amazon.co.uk/gp/product/B019HAC6V4/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1


  • If you find your plant is being over-watered, you can adjust the duration of the pumping at the top of the code.


  • If you find its being underwatered, schedule more times or increase the duration, same place in the script.
  • The time zone might have to be changed, depending on where you life, which can be done be adding or deducting hours.


  • You can add a moisture sensor, but some programming will have to be done by yourself.


Thats about it from me and this guide. It should just work as intended with little to no trouble shooting.

If you DO run into problems, there are some very nice people on Raspberry Pi forums, and other instructable websites.

And if your circuit explodes, not my problem! (It wont explode...I hope!)



Thank You!

Thank for discovering this project and have fun building it!

Leon.