Case 07: Crops Height Detection
8. Case 07: Crops Height Detection#
The height of the crops is an important factor in determining crop yield. Deducing plants height could increase plants fertilizer tolerance and lodging resistance, and increase harvest index and final yield. This also fully shows that plants height is an important selection indicator in the breeding process.
Detect if the height of the crops is exceeding the standard with the sonar:bit.
8.5. Hardware Connection#
Connect the sonar:bit to P1 and the OLED display to IIC on IoT:bit.
8.6. Software Programming#
Click “Advanced” in the MakeCode to see more choices.
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.
Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.
Initialize the OLED display as 128×64.
Set the ultrasonic sound sensor to connect to P1 with unit in cm, save the returned value as the variable “ultrasonic_distance”.
Clear the OLED display and display the value from the ultrasonic sound sensor.
Judge if the returned value is in the scope of the threshold, if yes, it means the height of the plants is over the standards, prgram to display “x”; or program to display “√”.
Detect if the height of the plants is over the threshold with the sonar:bit.