Raspberry Pi Pico Water-level-indicator Using Potentiometer

by PRO in Circuits > Raspberry Pi

9128 Views, 37 Favorites, 0 Comments

Raspberry Pi Pico Water-level-indicator Using Potentiometer

Untitled Photo (10).png

Hello, I am a school student from Germany and this is my first Instructable. I‘m excited to show you how to make a water-level-indicator using Raspberry pi Pico and a Potentiometer. My parents gifted me the Raspberry pi Pico for Christmas and immediately I started trying out what it can do. It is a simple Project and maybe someone has done it before, but I made it all by myself, so let‘s get started...

Supplies

  • Raspberry pi Pico and Micro USB Cable
  • PiperMake (https://make.playpiper.com/)
  • Breadboard
  • Jumper-cables
  • 3 LEDs, Red, Yellow and Green
  • Buzzer
  • 10k Ohms Potentiometer
  • Stick
  • Something that floats

Connecting Potentiometer

Screenshot 2022-01-22 144307.jpg

Start building the Circuit.

First connect the potentiometer to the pico as shown in the image above: Connect the middle pin of the potentiometer to the pin 31/ GP26 / ADC0. Then connect one of the remaining pins of the potentiometer to any of the grounds (GND). The third pin of the potentiometer has to be connected to pin 36 / 3v3 OUT.

Adding LEDs

Screenshot 2022-01-22 145430.jpg

Now connect the three LEDs to the pico.

The positive pin of the Green LED has to be connected to pin 17/ GP13. The positive pin of the Yellow LED has to be connected to pin 19/ GP14. The positive pin of the Red LED has to be connected to pin 20/ GP15. Connect the negative pins of all LEDs to any of the grounds (GND) of the pico.

Adding Buzzer

Screenshot 2022-01-22 145526.jpg

Connect the positive pin of the buzzer to pin 20/GP15 (same as red LED ) and the negative pin of the buzzer to any of the grounds of the pico.

Complete Circuit

Screenshot 2022-01-22 193554.jpg

When all components are in place, the circuit should look as in the picture above:

Circuit on the Breadboard

WhatsApp Image 2022-01-22 at 14.55.33tthfffghfgh.jpeg
WhatsApp Image 2022-01-22 at 14.55.33.jpeg

On my breadboard, the circuit looks as in the picture above:

Attaching Lever Arm

stick.jpeg

Attach the lever arm to the potentiometer with hot glue.

Attaching Float

fix float 1.jpeg
float.jpeg

Attach a float to the other end of the stick.The float can be a block of styrofoam or a plastic ball. I have used a plastic ball as in the image above.

Attaching Everything to a Bucket

all.jpeg
bucketfix.jpeg
bucket.jpeg

Attach the potentiometer to a bucket, which at least should be as deep as the stick and the float together.

Start Programming

my_Instruc.png

The Water-level-indicator works by reading the values of the potentiometer and turning the LEDs on when a certain value is reached. Everything is programmed in PiperMake. Let‘s start with an simple ``repeat forever`` loop:

Reading Values

my_Waterlevelindikator using a Potentiometer (2).png

Read the values from the potentiometer by using the `` print (read from pin ADC0)`` block.

If/Else If Loops

my_Waterlevelindikator using a Potentiometer (4).png

Add 4 ``If/ Else if `` loops into the ``repeat forever`` loop below print.

Adding Pins

my_Waterlevelindikator using a Potentiometer (5).png

Add the pins to the if and else if loops, as you connected them in the circuit

GP13 = Green LED

GP14 = Yellow LED

GP15 = Red LED

Adding Values

my_Waterlevelindikator using a Potentiometer (6).png

The values depend on your construction.To get the values for your setup, we used the ``print`` block. The values will be shown in the console at the bottom of pipermake page.

Try out which values will be perfect at which water-level . Add the correct values in the program. The values may change after final calibration

Circuit Python Code

The Circuit Python code:


## ---- Imports ---- ##

import time

import board

from piper_blockly import *

## ---- Definitions ---- ##

GP26 = piperPin(board.GP26, "GP26", "Analog")


try:

set_digital_view(True)

except:

pass


GP13 = piperPin(board.GP13, "GP13")

GP14 = piperPin(board.GP14, "GP14")

GP15 = piperPin(board.GP15, "GP15")


## ---- Code ---- ##

while True:

print(GP26.readVoltage())

if GP26.readVoltage() >= 0:

GP13.setPin(1)

elif GP26.readVoltage() < 0.35: ## ---- Values can change ---- ##

GP13.setPin(0)

if GP26.readVoltage() >= 0.35:

GP14.setPin(1)

elif GP26.readVoltage() < 0.35:

GP14.setPin(0)

if GP26.readVoltage() >= 0.7:

GP15.setPin(1)

elif GP26.readVoltage() < 0.7:

GP15.setPin(0)

time.sleep(0.5)

Everything Working Together

My Raspberry pi pico water-level-indicator using a potentiometer

How this project works. Link for above video

End Note

I will submit this project for Raspberry Pi contest. Please like and vote for my entry.

This is only a basic version, so you can extend it with more LEDs for more waterlevels

I also make YouTube videos on programming in Scratch and Raspberry pi. Please subscribe to my Youtube channel PRO :)

https://www.youtube.com/channel/UCVxgyp494aNrQa8jr...