Measure water level remotely using Micro:bit

Micro:bit 28-11-24
38 0

Tutorial Plan

1- Water measurement objective

2- How does the Micro:bit card measure water level ?

3- Materials Needed

4- System wiring diagram

5- Programming Micro:bit with Makecode

6- Develop a mobile application to receive a message from Micro:bit board

 

 

Water measurement objective

Water measurement refers to the process of quantifying the flow, volume, or level of water in various settings. It is essential for managing water resources, ensuring efficient usage, and maintaining environmental sustainability.

The objective of water measurement is to accurately quantify water usage, availability, or flow to support various activities and decision-making processes.

Specific objectives can vary depending on the context but often include:

1. Resource Management

Monitor water availability in reservoirs, rivers, and aquifers to ensure sustainable usage.

Support water allocation for agricultural, industrial, municipal, and ecological needs.

2. Regulatory Compliance

Ensure adherence to water use permits and legal frameworks.

Monitor effluent discharge to meet environmental standards.

3. Efficiency Optimization

Track water usage to reduce waste and improve efficiency in industries, agriculture, and households.

Enhance irrigation systems and water distribution networks.

4. Flood and Drought Management

Measure water levels and flows to predict and mitigate the impact of floods and droughts.

Develop early warning systems based on real-time water measurements.

5. Scientific Research

Collect data for hydrological studies, climate change research, and ecosystem monitoring.

Understand groundwater recharge rates and surface water interactions.

6. Economic Planning

Support water pricing and economic policies based on accurate usage and availability data.

Plan infrastructure development, such as dams, canals, and treatment plants.

7. Public Health and Safety

Monitor water quality and supply in urban and rural areas.

Manage drinking water systems to ensure public safety.

 

How does the Micro:bit card measure water level ?

Measuring the water level using a Micro:bit, wires, a bottle, a smartphone, MakeCode, and App Inventor involves creating a simple water-level sensor and programming the Micro:bit to process and transmit the data.

1- Build the Water-Level Sensor:

Concept: Water conducts electricity, and the conductivity increases with the water level between two probes.

Place two or more conductive wires vertically inside the bottle at different levels.

Connect these wires to the Micro:bit's GPIO pins.

Label the wires (e.g., Pin 0, Pin 1, Pin 2 for different levels of water).

2- Program the Micro:bit using MakeCode:

The Micro:bit will use its pins to detect whether water bridges the circuit at various levels. If water touches a wire, it will complete the circuit, and the Micro:bit can register this as "HIGH".

3- Transmit Data to the Smartphone:

Enable Bluetooth in the MakeCode program.

Use the Micro:bit's Bluetooth UART feature to send data to the smartphone.

 

Materials Needed

Materials Needed

Micro:bit board (The main microcontroller board to control the system)

Micro:bit board

The GPIO expansion card for the Micro:bit card

The GPIO expansion card for the Micro:bit card

A plastic bottle (used as the water container).

Wires (e.g., copper or insulated wires with stripped ends).

Fils de connexion

Resistors (to limit current and prevent damage to the Micro:bit).

quatre résistances

Breadboard ( to test electronic circuits without the need for soldering)

Breadboard

 

System wiring diagram

Common Ground Wire:

Insert one wire into the bottom of the bottle.

Connect this wire to the GND pin of the Micro:bit.

Level Detection Wires:

Insert additional wires into the bottle at different heights (e.g., low, medium, and high levels).

Connect these wires to Micro:bit pins (e.g., P0, P1, P2).

Add a resistor (1kΩ–10kΩ) in series between each wire and its respective Micro:bit pin to protect the circuit.

Connections:

Each detection wire acts as an input to the Micro:bit.

When water bridges the ground wire and a detection wire, the Micro:bit senses it.

 

Programming Micro:bit with Makecode

Below is a MakeCode program for measuring water levels using a Micro:bit. This program assumes three water level wires are connected to pins P0, P1, and P2 on the Micro:bit, and a ground wire is at the bottom of the container.

1- Open the Microsoft MakeCode editor for Micro:bit.

2- Create a new project.

3- Go to Adavanced

4- Go to Pins and choose 'analog read pin P0'

5- Add Bluetooth Extension:

Click on the "Extensions" option in the bottom left corner.

Search and add the "Bluetooth" extension by clicking on it.

6- Add code to send a message:

- Use the bluetooth.uartWriteString() block under Bluetooth to send a string message via Bluetooth.

7- Use the blocks provided below to create the program.

Download program

 

Write this program to:

1- Continuously read the analog input from the pins connected to the sensor wires.

2- Display water level on the Micro:bit's LED grid (e.g., as bars or dots).

3- Send the data via Bluetooth to a smartphone.

Develop a mobile application to receive a message from Micro:bit board

To develop a mobile application to receive a message from the Micro:bit using MIT App Inventor, follow these steps:

1- Go to the MIT App Inventor website (ai2.appinventor.mit.edu).

2- Click on "Start new project" to create a new project.

Design the User Interface (UI):

1- Use the components from the Palette to design the user interface of your application. For example, you can add a TextBox for entering the message and a Button for sending the message.

2- Add Bluetooth Functionality:

From the Palette, click on "Connectivity" and then drag the "BluetoothClient" component onto the design screen.

Design the user interface of your app. You might have two buttons to turn on and turn off the two lamps

3- Add the components to your app.

- The "BluetoothLE1" extension indeed refers to a specific extension for MIT App Inventor which allows you to manage Bluetooth Low Energy (BLE) communication in your mobile applications. This extension facilitates the interaction between your App Inventor application and BLE devices, such as sensors, trackers, wearables, etc.

- The "BluetoothClient1" extension in MIT App Inventor allows you to create mobile applications that can connect to Bluetooth devices, such as serial Bluetooth modules (eg HC-06) connected to microcontrollers, Bluetooth audio devices, etc. . This extension facilitates communication with these devices using serial Bluetooth connections.

- The "Microbit_UART1" extension allows you to use UART (Universal Asynchronous Receiver-Transmitter) communication with the Micro:bit card in the MakeCode programming environment.

- The "Notifier1" extension in MIT App Inventor is a component for displaying notifications or messages to the user of an application. It can be used to send pop-up messages, alerts or important information to the user while the application is running. It is a useful component to improve user experience by providing contextual information.

4- Add buttons for pairing and connecting to the Micro:bit.

5- Add HorizontalArrangement element to display the water level.

Here is an example of our mobile application interface:

Program the Message Sending Functionality:

1- Click on the "Blocks" tab to switch to the Blocks Editor.

- Starting with Android 12, Bluetooth permissions have been enhanced to improve security and user data protection. This is why we must declare the authorizations that your application needs in the AndroidManifest.xml file. For Bluetooth, you'll need to include ACCESS_FINE_LOCATION, BLUETOOTH_SCAN, and possibly BLUETOOTH_CONNECT permissions, depending on the features you're using.

2- Use these programming blocks to connect the smartphone to the Micro:bit board via Bluetooth:

3- Set up the blocks which receive and display the measured water level :

Download project Download application

 

Assembly and Testing

1- Place the wires in the bottle and connect to the Micro:bit.

2- Program the Micro:bit using the MakeCode software.

3- Pair the Micro:bit with your smartphone using Bluetooth.

4- Test the system by adding water to the bottle gradually.

5- Observe water levels being displayed on the app.

 

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info