Agricultural Robot: IoT simulator + Data Tracking
You are developing the control software for a stationary agricultural robot. The robot is
responsible for monitoring a single high-value crop during a work shift. Since the system does
not yet have a database, it must process sensor data in real-time and provide immediate
feedback for each hour of operation.
The Mission
Create a Python program that simulates a robot monitoring a greenhouse for a specific duration.
The program must collect environmental data, make logic-based decisions to protect the plant,
and provide a summary report at the end of the shift.
Technical Requirements
1. Shift Setup:
○ Ask the user (the operator) to input the duration of the shift in hours.
○ Convert this input into an integer.
2. The Monitoring Loop:
○ Use a for loop and the range() function to iterate through each hour of the
shift.
○ For every hour, the program must ask the user to input:
■ The current temperature (Float).
■ The current Moisture Level percentage (Integer).
3. Robotic Decision Logic:
○ Inside the loop, use conditionals to determine the robot's action:
■ If the temperature is greater than 30°C: The robot should print:
"Action: Activate Cooling Fans."
■ Else if the moisture level is less than 20%: The robot should print:
"Action: Activate Irrigation Sprinklers."
■
Otherwise: The robot should print: "Action: System Idle.
Environment Stable."
4. Data Tracking:
○ Create a variable before the loop starts to act as a counter.
○ Every time the "Irrigation Sprinklers" are activated, increment this counter by 1.
5. Status Reporting:
○ Use f-strings to display a status update at the end of every hour (e.g., [Hour
○
3] Temp: 32.5°C | Moisture: 45%).
After the loop finishes, print a Final Shift Report showing the total number of
hours monitored and how many times the sprinklers were needed.
The "Programmer's Challenge" (Research Tasks)
To complete this project like a professional engineer, you must research and implement the
following:
●
●
Input Protection: Research how to use a basic if statement to check if the user
entered a negative number for the shift duration. If they did, the program should print an
error and stop.
The Random Factor: Research Python’s random module (specifically
random.uniform() and random.randint()). Try to modify your code so that
instead of typing the temperature and moisture manually, the "robot sensors" generate
these numbers automatically each hour.