|
3 weeks ago | |
---|---|---|
.. | ||
code-notebook | 3 weeks ago | |
README.md | 3 weeks ago | |
assignment.md | 3 weeks ago | |
pi-temp.md | 3 weeks ago | |
single-board-computer-temp-publish.md | 3 weeks ago | |
virtual-device-temp.md | 3 weeks ago | |
wio-terminal-temp-publish.md | 3 weeks ago | |
wio-terminal-temp.md | 3 weeks ago |
README.md
This code extracts the temperature from the telemetry message and gets the current date and time. It then appends a new row to the CSV file with the date and temperature.
- Run the server code and ensure it is receiving telemetry from your IoT device. Check the CSV file to confirm that temperature data is being saved correctly.
✅ Why do you think saving data in a CSV file might be useful for farmers?
Task - calculate GDD from the temperature data
Once the temperature data is saved in a CSV file, you can calculate the GDD for each day and total it up to determine the cumulative GDD for a crop.
-
Write a Python script to read the CSV file and calculate the GDD for each day. Use the simplified GDD formula:
date,temperature 2021-04-19T17:21:36-07:00,25 2021-04-19T17:31:36-07:00,24 2021-04-19T17:41:36-07:00,25
Replace
T_max
,T_min
, andT_base
with the appropriate values for your crop. -
Add code to sum up the daily GDD values to calculate the total GDD so far.
-
Print the daily GDD values and the total GDD to the console.
✅ Why is it important to calculate cumulative GDD for crops?
Task - notify when crops are close to maturity
Once you have the total GDD, you can add logic to notify the farmer when the crop is close to maturity. For example:
-
Set a threshold for the GDD required for maturity based on the crop you are monitoring.
-
Add a condition to check if the total GDD is within a certain range of the maturity threshold (e.g., 90% of the required GDD).
-
If the condition is met, print a message or send a notification to alert the farmer.
✅ How could automated notifications improve farming efficiency?
Post-lecture quiz
Review & Self-study
In this lesson, you learned how temperature affects plant growth and how to calculate growing degree days (GDD) using temperature data. You also explored how IoT devices can help farmers monitor and predict crop maturity.
✅ Research other environmental factors that can be monitored using IoT devices to improve farming practices.
Assignment
-
Use your IoT device to measure temperature data for a few days.
-
Save the data to a CSV file and calculate the GDD for a crop of your choice.
-
Determine how close the crop is to maturity based on the GDD calculation.
-
Write a short report summarizing your findings and how this data could help a farmer. This code opens the CSV file and appends a new row at the end. The row includes the current date and time formatted in a human-readable way, followed by the temperature received from the IoT device. The data is stored in ISO 8601 format with the timezone, but without microseconds.
-
Run this code as before, ensuring your IoT device is sending data. A CSV file named
temperature.csv
will be created in the same folder. If you open it, you will see date/times and temperature measurements:date,temperature 2021-04-19T17:21:36-07:00,25 2021-04-19T17:31:36-07:00,24 2021-04-19T17:41:36-07:00,25
-
Let this code run for a while to collect data. Ideally, you should run it for an entire day to gather enough data for GDD calculations.
💁 If you are using a Virtual IoT Device, check the random checkbox and set a range to avoid getting the same temperature every time the temperature value is returned.
> 💁 If you want to run this for an entire day, make sure the computer running your server code doesn’t go to sleep. You can do this by adjusting your power settings or using something like [this keep system active Python script](https://github.com/jaqsparow/keep-system-active).
💁 You can find this code in the code-server/temperature-sensor-server folder.
Task - calculate GDD using the stored data
Once the server has captured temperature data, you can calculate the GDD for a plant.
The steps to do this manually are:
-
Determine the base temperature for the plant. For example, the base temperature for strawberries is 10°C.
-
From the
temperature.csv
file, find the highest and lowest temperatures for the day. -
Use the GDD formula provided earlier to calculate the GDD.
For example, if the highest temperature for the day is 25°C and the lowest is 12°C:
- 25 + 12 = 37
- 37 / 2 = 18.5
- 18.5 - 10 = 8.5
Thus, the strawberries have received 8.5 GDD. Since strawberries need about 250 GDD to bear fruit, there’s still some time to go.
🚀 Challenge
Plants need more than just heat to grow. What other factors are necessary?
For these factors, investigate whether there are sensors that can measure them. Are there actuators to control these levels? How would you design one or more IoT devices to optimize plant growth?
Post-lecture quiz
Review & Self Study
- Learn more about digital agriculture on the Digital Agriculture Wikipedia page. Also, read about precision agriculture on the Precision Agriculture Wikipedia page.
- The full growing degree days calculation is more complex than the simplified version provided here. Learn about the more detailed equation and how to handle temperatures below the baseline on the Growing Degree Day Wikipedia page.
- Food scarcity may become a problem in the future if we continue using the same farming methods. Explore advanced farming techniques in this Hi-Tech Farms of Future video on YouTube.
Assignment
Visualize GDD data using a Jupyter Notebook
Disclaimer:
This document has been translated using the AI translation service Co-op Translator. While we aim for accuracy, please note that automated translations may include errors or inaccuracies. The original document in its native language should be regarded as the authoritative source. For critical information, professional human translation is advised. We are not responsible for any misunderstandings or misinterpretations resulting from the use of this translation.