Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Serial+Monitor: A Powerful Tool for Arduino Projects
Introduction: Serial communication is an essential feature in Arduino projects, allowing the exchange of data between the microcontroller and a computer or other devices. The Serial Monitor tool, available in the Arduino IDE, plays a crucial role in debugging and analyzing the behavior of your program. This article aims to provide a comprehensive guide on the Serial+Monitor feature, including examples of code and a list of components used.
Project: For this example, let's consider a temperature and humidity monitoring system using the DHT11 sensor. The project's objective is to read sensor data and display it on the Serial Monitor. Additionally, we will implement a threshold check and send an alert if the temperature exceeds a predefined value.
List of Components:
Examples: Below is an example code that demonstrates how to use the Serial+Monitor feature to read data from the DHT11 sensor and display it on the Serial Monitor.
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
if (temperature > 25) {
Serial.println("Temperature exceeds the threshold!");
// Additional code to send an alert
}
delay(2000);
}
Explanation: