This document outlines two tasks for an IoT lab project: the first task involves designing an automatic fan speed control system based on temperature readings using a TMP36 sensor and a rotary motor, while the second task focuses on creating an irrigation system that activates water pumps based on soil moisture levels from three sensors. Each task includes detailed algorithms for initialization, reading sensor data, controlling outputs, and continuous operation. The document also mentions the use of serial communication for monitoring and debugging purposes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
5 views
lab4
This document outlines two tasks for an IoT lab project: the first task involves designing an automatic fan speed control system based on temperature readings using a TMP36 sensor and a rotary motor, while the second task focuses on creating an irrigation system that activates water pumps based on soil moisture levels from three sensors. Each task includes detailed algorithms for initialization, reading sensor data, controlling outputs, and continuous operation. The document also mentions the use of serial communication for monitoring and debugging purposes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6
ICS 423 Internet of Things
Lab 4 Name: Anish Halder Roll No: 2021BCS0034
Task 1: Assume that three blades of a fan are connected to a rotary
motor. Design an IoT system that automatically controls the speed of the fan based on the input temperature.
Algorithm for Automatic Fan Speed Control based on Temperature
1. Initialize: o Define TMP36 sensor pin (A0) and motor driver pins (ENA, IN1, IN2). o Start serial communication and set pin modes. o Set motor direction (IN1 = HIGH, IN2 = LOW). 2. Read Temperature: o Read analog value from TMP36. o Convert to voltage and then to temperature (°C). 3. Control Fan Speed: o Map temperature (20-40°C) to PWM range (0-255). o Constrain PWM value within 0-255. o Apply PWM to motor driver (analogWrite(ENA, fanSpeed)). 4. Repeat: o Wait 2 seconds, then repeat the process. Code:
Output: Serial Monitor:
Task 2: Assume a DC motor is used to pump water. Design an irrigation
system that pumps water to three water channels based on the soil moisture content of those locations. Algorithm for Soil Moisture Sensor with Three Motor Pumps: 1. Initialize Pins: o Set the pins for the water pumps (Pin 13, Pin 12, Pin 11) to OUTPUT. o Set the pins for the moisture sensors (Pin A0, A1, A2) to INPUT. 2. Start Serial Communication: o Begin serial communication at 9600 baud to monitor the moisture levels on the Serial Monitor. 3. Loop Through Sensors: o For each moisture sensor (3 total): 1. Initialize a variable to store the accumulated sensor readings. 2. Take 100 readings from the corresponding moisture sensor. 3. Accumulate the readings and compute the average value. 4. Control Pumps Based on Moisture Level: o For each sensor: 1. If the moisture level is less than or equal to the threshold value (limiteInferiorHumedad), turn the corresponding pump ON by setting the respective pump pin to HIGH. 2. If the moisture level is greater than the threshold value, turn the pump OFF by setting the respective pump pin to LOW. 5. Display Moisture Values: o Print the moisture levels of all three sensors to the Serial Monitor for debugging or monitoring. 6. Repeat: o Add a delay of 400 milliseconds before reading the sensor values again and controlling the pumps. 7. End of Loop: o Repeat the process continuously. Code: Output: