Example Code for micro:bit-MakeCode-Remote Watering System

This article provides a step-by-step guide to using micro:bit with an Easy IoT expansion board to automate a remote watering system. It includes hardware and software preparation, wiring instructions, and sample code using the Makecode platform. Readers will learn how to control the watering system based on soil moisture levels and remote commands via Easy IoT, making plant care efficient and tech-savvy.

Hardware Preparation

  • micro:bit board: Quantity 1
  • Micro: IoT expansion board: Quantity 1
  • Soil moisture sensor: Quantity 1
  • Servo (S1): Quantity 1
  • DFRobot Easy IoT platform access: Quantity 1

Software Preparation

Wiring Diagram

  1. Connect the soil moisture sensor to the module's P1.
  2. Connect the servo to pin S1 of the Micro: IoT expansion board.
  3. Plug the micro:bit board into the Micro: IoT expansion board.

Other Preparation Work

  1. Open the Easy IoT website:http://iot.dfrobot.com.cn/
  2. Sign up/Sign in to Easy IoT.
  3. Add a new device to match your micro:bit, get the device topic.

Sample Code

makecode programs: watering system

Result

  • Watering plants by remote control: when connected with WiFi, the servo rotates 100 degrees, and the watering system is closed. Send commands to micro:bit via Easy IoT, if the micro:IoT received the command "ON", the servo rotates 10 degrees to enable the watering system. When the micro:IoT received the command "OFF", the servo rotates to 100 degrees, or the humidity is larger than 550, the system will be disabled.

Note: when the servos turns to 100 degrees, the watering system is closed, servo to 10 degrees, the system opened.

Was this article helpful?

TOP