Can Your micro:bit Draw Conductivity? | DFRobot Science Lab

0 743 Easy

Objectives

In our previous class, we checked how conductivity changes when we added more salt in water, and then we drew a graph with the information. Can the computer help us draw the graph automatically this time?

In today's lesson, we'll get to know a tiny computer called the micro:bit. You can make it do fun things by giving it special instructions with computer codes. With the help of the BOSON splitter module, we'll read sensor data and send it to the micro:bit at the same time. After that, we'll ask the micro:bit to display the information on its screen. It's like creating a magical picture with our new friend!

Standards

NGSS - NEXT GENERATION SCIENCE STANDARDS

5-PS1-3 Matter and its Interactions Make observations and measurements to identify materials based on their properties.

Connect Hardware

Attach the soil moisture sensor to the mainboard's input to measure conductivity. Then, at the mainboard's output, connect the splitter module. Divide the output signal into two branches: one links to the OLED display for immediate data presentation, and the other links to the micro:bit for additional processing.

Setup:

1. Connect the soil moisture sensor to the input side of the mainboard.

2. Connect the splitter module to the output side of the mainboard.

3. Connect the 1st branch of the splitter to the OLED display.

4. Connect the 2nd branch of the splitter to the P0 pin of the expansion board.

5. Insert the micro:bit into the expansion board and connect the USB cable.

6. Switch the OLED display mode to i16 Analog Data.

Start Programming

Go to the MakeCode editor to start writing code for the micro:bit: https://makecode.microbit.org/#editor.

Step 1: Read Sensor Data

As the soil moisture sensor produces an analog signal, you can retrieve sensor readings by reading the analog value from the micro:bit's P0 pin.

Use “serial write” to print out the readings.

Sample code:

Select 'Connect to micro:bit' at the bottom left of the page to upload the program or download the file and save it onto the micro:bit. After completing the guided steps, now the code is running on the micro:bit.

Click on "Show data" below the simulator, and you will observe the sensor data being read and the graph being drawn in the editor.

Step 2: Draw the Data on micro:bit

Now, let's divide the micro:bit's LED display into 5 columns and note down 5 different sensor readings. The stronger the conductivity, the more LEDs will light up in each column. Press the B button to record the reading and proceed to the next round of data collection.

Sample Code:

https://makecode.microbit.org/_4836ApLTMA4W

Place the soil moisture sensor into pure water, and you'll notice the first column of LED on the micro:bit lighting up. Once the reading stabilizes, press the B button to note the current conductivity. Add a spoonful of salt to the water, press the B button again, and repeat this procedure four times. Upon completing the five measurements, you'll observe a data chart on the micro:bit's LED display, similar to the one we manually drew in the previous class.

License
All Rights
Reserved
licensBg
0