Programmer gardener

Build an automated smart garden that measures soil moisture, temperature, and light. Learn to program irrigation, collect sensor data, and control outputs - an ideal tool for teaching science, computer science, and home crafts.

Description

The Gardener Programmer is a practical and expandable kit for learning automation, programming and the basics of electronics. It allows you to build a smart flower pot or other project with controlled irrigation, sensors and LED indicators. It uses a micro:bit and an MB2 expansion board, which allows you to control a pump, read data from humidity, temperature and light sensors and easily connect other modules.

The kit is suitable for home DIY and school teaching. Thanks to the included instructions with tasks, it develops technical thinking, creativity and skills in the fields of computer science, natural science and physics. It supports programming in MakeCode and Python and is ideal for beginners and advanced users. The project can be further expanded according to your own ideas - for example, with a display, an alarm or more complex irrigation control.

LED display TM1637

A seven-segment display is used to simply display numbers - for example, time, temperature or other measured values. It is suitable for projects where a clear numerical output is needed.

The display can be easily connected using dupont wires and connected to any OMG Robotics expansion board. Simply insert the micro:bit into the expansion board and connect the display according to the diagram. To display longer numbers, multiple displays can be connected in series.

Connection

  • CLK – clock signal, connects to yellow bar on the extensions. It is necessary to set which pin we connected this signal to.
  • GOD – data pin, connects to yellow bar on the extensions. It is necessary to set which pin we connected this signal to using the dupont cable.
  • VCC – positive voltage (connects to the white bar).
  • GND – earth (connects to the black bar).


Warning:
When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

First, we need to create a new variable, which we will name display.

Then we need to download the extension for our display. In the extensions section we find the library for the TM1637 display and add it to the makecode.

Now we have everything ready and we can start programming. The first thing we do when starting the program is to add a display to the program and turn it on. The display is set using the variable block “set display to 0”, which we place in the “at startup” window. Next, we select the initialization block from the TM1637 block to tell where the display is connected.

Once the display is set up, we turn it on using the “turn on” block and select the “display” variable.

Then we can test the correctness of the connection and programming using the “show number” block, which can be found in the TM1637 tab.

Tasks

Task 1: Writing out the number

To work with an external display, we need to use the blocks from the bookmark TM1637, which we will install first.
Using the appropriate blocks from the TM1637 tab, we then display various numbers on the display.

Task 2: Changing the display brightness

Find the block that can be used to change the brightness settings of the LED display.
Think about when we should change the intensity or even reduce it completely.
Find out what the highest and lowest intensity values ​​are.

Task 3: Simple stopwatch

If we already know how to display numbers, we can use simple variable work and program a stopwatch.
We will create a new variable named numberWe will repeatedly add the value 1 to this variable and display its value on the display.
However, we find that the counting is going too fast - what do we need to add to the program so that the stopwatch measures time accurately?

Temperature sensor

The DS18B20 digital thermometer allows you to measure temperature with an accuracy of 9 to 12 bits in degrees Celsius. It is equipped with a temperature alarm function, where you can program the upper and lower limits.

The sensor communicates over a 1-Wire bus, which requires only a single data wire and ground to connect to the micro:bit or other microprocessor. In addition, the DS18B20 can be powered directly from the data line (so-called parasitic power), which simplifies wiring.

Each sensor has a unique 64-bit identifier, allowing multiple sensors to be connected to a single bus. This allows for easy temperature measurement in multiple locations simultaneously – for example in HVAC systems, environmental monitoring in buildings, machines or manufacturing processes.

Connection

  • Sig – the digital output of the remote control is connected to yellow bar, e.g. to pin P0. It is necessary to set in the program which pin it is connected to.
  • VCC – sensor power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.


Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

If everything is connected and programmed correctly, the current temperature will be displayed on the micro:bit display.

Tasks

Task 1: Measuring the temperature in different parts of the room

Connect the temperature sensor according to the diagram and monitor the readings on the micro:bit display. Place the sensor in different parts of the room - for example, by the door, window, in the shade or near a heater.

  • Record the measured temperatures.
  • Compare where it is warmer and where it is colder.
  • What differences did you find?

Task 2: Recording temperature changes over time

Place the sensor in one spot and measure the temperature every 10 minutes for one hour.

  • Were there any changes during the measurement? What could have caused them?
  • How quickly does the environment heat up or cool down?
  • Try drawing a graph showing the temperature over time.

Task 3: Comparing the temperatures of different objects

Use the sensor to measure the surface temperature of various materials – e.g. a metal spoon, a plastic cup, a wooden cutting board, or your own hand.

  • Which material is the warmest and which is the coldest?
  • Measure items after they have warmed up in the sun or cooled in the refrigerator.
  • How long does it take for an object to return to room temperature?

Programmable LED strip

The RGB LED strip contains colored LEDs with integrated SMD chips and control circuits, making it easy to control with the micro:bit. Each LED can change color and brightness, allowing you to create moving light effects as well as static color patterns.

The LED strip is suitable for lighting projects - from decorations to light tracks for vehicles to experiments with light for plants. Thanks to the RGB composition, almost any color in the visible spectrum can be set. The strip thus offers a wide range of possibilities for teaching and creative crafting.

Connection

  • GOD – the data pin of the LED strip is connected to yellow bar, e.g. to pin P0. It is necessary to set in the program which pin it is connected to.
  • VCC – power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.


Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

First, in the MakeCode editor, we create a variable called strip that will be used to control the LED strip. In the "on startup" block, we add the command "set strip to", into which we will later insert the block from the NeoPixel extension.

The NeoPixel extension needs to be added first. Click on “Extensions” and type “Adafruit neopixel” into the search engine. Select the extension with the LED strip logo. After adding, a new NeoPixel tab will appear in the blocks menu.

From this tab, we insert the block "set strip to neopixel..." and set three basic parameters: the pin to which the LED strip data wire is connected (for example, P0), the number of LEDs per strip, and the display format, which we will leave as RGB.

Once we have the LED strip added and configured, we can start controlling it. For a simple test, we will use the “strip show color (red)” block, which will light up the entire strip in red. Then we will add a short pause (for example, 500 ms) and display other colors in the same way – green and blue. This will test the basic work with colors and controlling the LED strip using the micro:bit.

Tasks

Task 1: Turning on the RGB strip

Light up the LEDs in the basic colors provided by the NeoPixel library. Try red, green, and blue.

Task 2: Gradual flashing and light effects

Create your own lighting effects using blocks from the NeoPixel library. Try out each command, then program an effect in which LEDs gradually blink and change colors.

Task 3: RGB and HSL – how are they different?

We can change the color of light by adjusting the intensity of the red, green, and blue components (RGB). This also affects the brightness of the resulting color. However, adjusting the intensity in RGB is not always easy.

Therefore, other methods of representing colors are often used, such as HSL (Hue, Saturation, Lightness), HSV or CMYK. The NeoPixel library also allows you to work with the HSL format. Find out how HSL works and find converters between individual color models on the Internet.

Task 4: Clap lamp

Use an LED strip and a micro:bit to program a nightlight that turns on and off when you clap your hands. Use the micro:bit's built-in microphone to detect sound.

Humidity sensor

The moisture sensor is used to measure soil moisture using simple conductivity probes. The data from the sensor can be easily read with the micro:bit and used for automatic irrigation or plant health monitoring.

The sensor is ideal for smart garden projects - it allows you to decide when to water. It is suitable for both home experiments and for teaching science and physics. Thanks to the direct connection to the micro:bit and easy interpretation of values, it offers a practical extension to the real world and develops technical thinking and a relationship with the care of living organisms.

Connection

LED display connection

  • GOD – the display data pin is connected to yellow bar, e.g. to pin P1. It is necessary to set in the program which pin it is connected to.
  • CLK – the display clock signal is connected to yellow bar, e.g. to pin P2. Here too it is necessary to set the appropriate pin in the program.
  • VCC – power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.

 

Connecting a capacitive humidity sensor

  • GOD – the AOUT signal pin is connected to yellow bar, to pin P2. In the program it is necessary to set which pin it is connected to.
  • VCC – power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.



Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

First, we connected the capacitive sensor and LED display according to the instructions. If we have the sensor connected via a cable, we connect it to the expansion board so that the yellow signal wire goes to the yellow terminal block. If we are not sure how to program the LED display, we go to the relevant section with instructions for working with the display.

To display the values from the capacitive sensor in the program, we add the block "display show number 0" to the repeating loop, where instead of zero we insert a block for reading the value from the pin and select the appropriate yellow pin. If the display does not work, we check the wiring of the wires to the yellow strip (CLK and DIO). If the sensor does not display any values, we check which pin the sensor is connected to and whether we have the pin set correctly in the program.

Tasks

Task 1: Reading values from a sensor

Connect the humidity sensor according to the attached diagram. Observe the measured values ​​on the display.

  • Touch the sensor with dry fingers and record the displayed values.
  • Repeat the experiment with moistened fingers and compare the difference.
  • During the experiment, be careful not to get the rest of the electronics or the computer wet.

Task 2: Recording substrate moisture values before and after potting

Choose a potted plant that has not been watered today. Carefully insert the sensor into the soil, taking care not to damage the roots. Write down the current moisture reading. After reading the reading, water the plant and watch the reading change.

  • Record the highest and lowest readings.
  • Monitor changes every 15 minutes.
  • Describe how quickly changes in humidity occur.

Task 3: Comparison of output values in different soil types

Prepare different types of soil – for example, sand, regular soil, clay or gravel.

  • First, take the measurement without adding water. Insert the sensor into each substrate in turn, wiping it with a paper towel after each measurement. Record the results.
  • Then moisten each substrate with the same amount of water and take the measurement again.
  • Evaluate which substrate was the wettest before irrigation and which after irrigation.
  • Record the results and compare the properties of each soil.

Submersible pump and Mosfet module

Submersible pump

A submersible pump is used to pump and distribute water or similar liquids to the desired location. It is not suitable for chemicals that could damage its internal parts.

Inside there is a motor with an impeller that sucks in liquid through the suction hole and pushes it out through the outlet. The pump must be completely submerged in the liquid during operation and must not run empty - only turn it on when it is fully submerged. 

Mosfet module

The MOSFET module is used to safely control the pump using the micro:bit. Connecting the pump directly to the micro:bit could damage it, as the pump requires a voltage of 5-6 V, which the micro:bit itself does not provide. The MOSFET module allows you to separate the power supply of the pump from the control logic, ensuring safe and reliable operation.

Connection

Pump connection via MOSFET module

  • GOD – the SIG signal pin on the module is connected to yellow bar, e.g. to pin P1. It is necessary to set in the program which pin it is connected to.
  • VCC – module power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.


The pump power supply is connected to the module terminals:

  • V+ – red pump wire (positive pole)
  • IN- – black pump wire (negative pole)


Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

First, we test whether everything works correctly. In the "at startup" block, we insert the block "write a logical value of 1 to pin P1" (or another pin, depending on the connection). This block activates the output on the pin that controls the Mosfet module connected to the yellow strip.

After uploading the program to the micro:bit, the pump should start.

Next, we will program the pump control using buttons. Using blocks from the Inputs tab, we will create a condition that when button A is pressed, the pump will turn on and when button B is pressed, it will turn off. This will give us simple manual control of the pump directly from the micro:bit.

Tasks

Task 1: Testing functionality

First, you need to verify the correct connection and functionality of the pump and Mosfet module. Prepare suitable containers, such as laboratory cylinders or larger beakers with a capacity of at least 1 liter, between which you will pump water. Connect a hose to the outlet of the submersible pump - the easiest option is an aquarium hose.

Task 2: We draw and measure

Measure how much water the pump pumps in 10, 20 and 30 seconds. Program the micro:bit to start the pump when you press the button and to turn it off after the selected time. Make each measurement separately and use a graduated cylinder to determine the volume of water pumped. Record the results.

Task 3: Automatic irrigation

Create an automatic watering system for your plants. Use the information on the amount of water you pump and the information on optimal humidity from the previous exercises. Each type of plant has different watering requirements - look up the information online and adapt your schedule accordingly. Your system should only start watering when the soil is dry and the plant actually needs water.

Infrared sensor

An IR (infrared) sensor is used to detect objects or movement at short distances using reflected infrared radiation. It is used in everyday life, for example in television remote controls, but also in industry or automation systems.

IR sensors can be found in automatic doors, barriers, motion-activated lighting, or robotic vehicles, where they help detect obstacles. The advantage is their ease of use and quick response to changing environments.

The sensor usually has two outputs – digital (DO) for detecting the presence of an object and analog (AO) for more accurate measurement of the intensity of the reflected signal. In combination with the micro:bit, the IR sensor can be used in many school projects – from security systems to interactive robots.

Connection

  • GOD – the digital output of the remote control is connected to yellow bar, e.g. to pin P0. It is necessary to set in the program which pin it is connected to.
  • VCC – sensor power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.


Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

First, we test whether everything works correctly. In the "at startup" block, we insert the block "write a logical value of 1 to pin P1" (or another pin, depending on the connection). This block activates the output on the pin that controls the Mosfet module connected to the yellow strip.

After uploading the program to the micro:bit, the pump should start.

Next, we will program the pump control using buttons. Using blocks from the Inputs tab, we will create a condition that when button A is pressed, the pump will turn on and when button B is pressed, it will turn off. This will give us simple manual control of the pump directly from the micro:bit.

Tasks

Task 1: Reading values ​​from an IR sensor

Find out when the digital output of the IR sensor is 1. Cover the sensor with your hand or other object and observe how the output changes. Verify how the sensor responds to the presence or absence of an obstacle.

Task 2: Maximum detection distance

Test how far the IR sensor can still detect an obstacle. You can adjust its sensitivity using the blue rotary element (potentiometer) on the sensor, thereby influencing the maximum detection range.

Task 3: Security device

Design a simple security system using an IR sensor. Think about how it could detect motion and what action it should trigger (e.g., turn on an LED, trigger an alarm, or write to memory).

Light sensor

A photoresistor is a passive electronic component whose resistance changes depending on the amount of light falling on it - the more light, the lower the resistance. Using the micro:bit, we can easily measure the intensity of light and respond to its changes in real time.

In teaching and practice, a photoresistor can be used, for example, to automatically open a chicken coop door according to sunrise or to control blinds that open at dusk.

Connection

  • GOD – the digital output of the remote control is connected to yellow bar, e.g. to pin P0. It is necessary to set in the program which pin it is connected to.
  • VCC – sensor power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.


Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

Basic program

In the program, we monitor the status of the digital output of the photoresistor module.

To increase signal stability and reduce interference, we activate an internal pull-up resistor on the input pin. This ensures more reliable reading of data from the sensor.

Tasks

Task 1: Reading values ​​from a light sensor

Find out when the sensor's digital output is 1. Cover the sensor with your hand and watch how it reacts to the change in light. Verify which state corresponds to illumination and which to shadow.

Task 2: Setting the sensitivity

Use the blue rotary element (potentiometer) on the module to adjust the sensor sensitivity. Try a value at which the sensor reliably detects hand covering.

Task 3: Automatic lamp

Combine an RGB LED strip with a photosensor and program a simple lamp that automatically turns on when the light intensity decreases - for example, in the evening or when it gets dark.

Smart flower pot

This connection uses the principles explained in the previous paragraphs. We will use the display here TM1637, capacitive humidity sensor, MOSFET module a submersible pump.

The capacitive sensor senses the soil moisture. As the moisture decreases, its capacitance decreases and the sensor measures higher voltage values. If the value exceeds the set limit, the program switches on the boost MOSFET module and it starts powering the pump. As a result, water starts flowing into the flower pot, the soil moisture increases, which is recorded by the sensor, its value decreases and thus the MOSFET (along with the pump) is turned off.

Connection

Pump connection via MOSFET module

  • GOD – the SIG signal pin on the module is connected to yellow bar, e.g. on a pin P1In the program it is necessary to set which pin it is connected to.
  • VCC – module power supply (+3V), connected to white bar.
  • GND – ground (–), connects to black bar.

 

The pump power supply is connected to the module terminals:

  • V+ – red pump wire (positive pole).
  • IN- – black pump wire (negative pole).

TM1637 display wiring

  • CLK – connect the clock signal to the pin P14 (set in the sample program).
  • GOD – connect the data signal to the pin P13.
  • VCC – module power supply (+3,3V), connect to the white strip.
  • GND – ground (-), connect to the black bar.

Connecting the capacitive humidity sensor

  • AUGUST – analog signal of the measured voltage level (the higher the value, the less moist the soil), connect to the pin P0.
  • VCC – module power supply (+3,3V), connect to the white strip.
  • GND – ground (-), connect to the black bar.

Warning: When connecting, the expansion board must be turned off and the micro:bit disconnected from the power supply.

Programme

First, we will test whether everything is working properly. We will prepare a damp cloth to test the humidity sensor.

At the beginning, we set the pins to which the display is connected, turn on the backlight and clear it.

In the loop, we then read the sensor value and display it on the display. Then we check whether the value exceeds the level we set (here 500, set as needed). If the value is higher, it means that the soil is dry. Therefore, we turn on the MOSFET module and thus the pump (here we turn it on fully, set the pump speed as needed). If the soil is sufficiently moist, the pump turns off. Finally, we wait 100ms.

Tasks

Test the wiring with the program. Take a damp cloth and place it on the sensor. If everything works as it should, implement this wiring in a real flower pot.

Gallery