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

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:

  1. Arduino Uno
  2. DHT11 Temperature and Humidity Sensor
  3. Jumper Wires
  4. Breadboard

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:

  • We first include the DHT library and define the necessary pins and sensor type.
  • In the setup() function, we initialize the Serial communication and the DHT sensor.
  • The loop() function reads the temperature and humidity values from the sensor and prints them on the Serial Monitor.
  • If the temperature exceeds 25°C, an alert message is displayed on the Serial Monitor.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.