Case 13:The Smart Farm
15. Case 13:The Smart Farm#
To build a smart farm with the Smart Agriculture Kit and the Carton models.
Auto-irrigation: Control the movement of the servos with the level of the soil moisture. Reference: Auto Irrigation in Farmlands
Temperature and Humidity Detection: Detect and display the value of the temperature and humidity in the farm. Reference: Temp.&Humidity Monitoring in the Greenhouse
Fish ponds detection: Monitor the water level and display the water temperature. Reference: Water Level Monitoring in Fish Ponds 、Water Temperature Detection
Farmland protection device: Protect the farmlands from people to get in, set to flash the lights when people get close for warning. Reference: Farmlands Protection Device
15.3. Materials Required#
Smart Agriculture Kit
Smart Agricultural Carton Model
Double-sided tapes: Fix the sensors and the postion of the models.
Step 1: Take out the cardboards and splice the baseboard.
Step 2: Fold the cardboards with the crease and fasten the buckles.
Finished models after the assembly：
2.The fish pond
Step 3: Put the models on the baseboard
Tip: Please can glue the models with the double-sided tapes.
15.5. Hardware Connections#
Connect the soil moisture sensor to P1 on IoT:bit; the 180 degrees servo to P2; the DHT 11 to P3; the rainbow LED to P4; the water level sensor to P10; the DS18B20 sensor to P13; the infrared sensor to P14; the sonar:bi to P15; and the OLED display to IIC on Iot:bit.
15.6. Add Extensions#
Click the “Advanced” in the MakeCode drawer to see more choices.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “servo” in the dialogue box to download it.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “neopixel” in the dialogue box to download it.
For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer and search with “iot-environment-kit” in the dialogue box to download it.
Initialize the OLED screen and disable the LED functions on the micro:bit, initialize the rainbow LED.
Get the values from all sensors and display them on the OLED screen.
If the returned value from the soil moisture is below the threshold, make the servo rotate to 0 degree to simulate the opening of the water valve; or make it rotate to 180 degrees to simulate the closing of the water valve.
If there is any obstables detected among 4~400cm by the sonar:bit, detect if there is any movement with the infrared sensor, if yes, program to light on the red light or program to light on in green.
Reference link: https://makecode.microbit.org/_eYRf5hcaDEeR
The values of the soil moisture, the temperature and humidity of the farmland, the water level and the water temperature shall be displayed on the OLED screen. If the value of the soil moisture is below the threshold, the device would turn on the water valve for irrigating; or it’s in the close status to save water. If there is any one getting closer, the rainbow LED lights on in red for warning; or it light on in green.
Tip: As the models are made of paper, please prepare with water-proofs solutions if your project needs water. For example: we can put a plastix box inside of the fish ponds for protection.