In summary, the use of the oscilloscope allowed us to perform extensive testing and obtain accurate measurements, giving us greater confidence in the quality and performance of the servo motor.
The multimeter is like the electrical detective of our circuit. It helps us make sure everything is working as it should.
For example, we can use it to check that the power source is supplying the correct voltage for our circuit to work smoothly. It also helps us measure the voltages in different parts of the circuit, such as those going to our temperature and humidity sensors, as well as the OLED screen.
Program OLEDDISPLAY
To make sure I got accurate readings from my DHT sensor on the Arduino, I installed the DHT.h library carefully and correctly. First, I opened the Arduino IDE and navigated to the "Sketch" menu, then "Include Library" and finally "Manage Libraries". In the search box, I entered "DHT" and found Adafruit's DHT Sensor Library. After selecting it, I clicked "Install" and waited for the process to complete.
Código para el Arduino 2
/* ESP32C3 OLEDDISPLAY
3V ------------- VCC
GND ------------ GND
SCL -------------- SCL
SDA ------------- SDA
D6 ------------ Data pin of the DHT
ESP32C3 DHT11
3V ------------- 3V
GND ------------ GND
D6 ------------ Data pin of the DHT
*/
#include "DHT.h" // DHT Library
#include < Wire.h>
#include < Adafruit_GFX.h>
#includ < Aedafruit_SSD1306.h>
const int OLED_RESET = 0;
Adafruit_SSD1306 display(OLED_RESET);
// Pin to which the DHT11 sensor is connected.
// If using the DHT11 Shield, it's digital Pin D4.
const int DHTPIN = D6;
// Specify the type of DHT sensor being used.
#define DHTTYPE DHT11
// Initialize the sensor with the pin and type.
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200); // Begin serial communication at 9600 Baud.
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(2000);
display.clearDisplay();
dht.begin(); // Start DHT communication.
}
void loop() {
// The DHT11 sensor provides a new reading every 2 seconds,
// so there's no need to constantly loop in the program.
delay(2000);
// Read humidity value.
double humidity = dht.readHumidity();
// Read temperature in Celsius.
double temperatureC = dht.readTemperature();
// Read temperature in Fahrenheit.
// The boolean parameter controls whether
// the temperature is displayed in Fahrenheit or Celsius.
double temperatureF = dht.readTemperature(true);
// Check if the values were read successfully.
if (isnan(humidity) || isnan(temperatureC) || isnan(temperatureF)) {
Serial.println("Error reading data.");
return;
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(5, 0);
display.println("Fab Academy");
display.setCursor(5, 15);
String tempValue = String(temperatureC);
display.println("Temp: " + tempValue + "C");
display.setCursor(5, 23);
String humValue = String(humidity);
display.println("Humidity: " + humValue + "%");
display.display();
delay(500);
}
Program 1
• Connection configuration: In the comments section, we describe how the components, including the ESP32C3, OLED display and DHT11 sensor, are to be physically connected. The pins used for each connection are specified.
•Inclusion of libraries: the libraries needed for the code to work are included, such as the DHT.h library for the DHT11 sensor and the libraries needed to control the SSD1306 OLED display.
• Initialization: In the setup() function, the serial and I2C communications are initialized, as well as the OLED display and the DHT11 sensor. The display is also cleared to prepare it for data display.
• Main loop: In the loop(), the temperature and humidity are read from the DHT11 sensor every 2 seconds. If the values are read correctly, they are displayed on the OLED screen. If there is an error reading the data, an error message is printed on the serial port.
My project, I am using the Xiao ESP32-C3 board to monitor the humidity and temperature of the environment. After extensive testing, I confirmed that both the board and the program work accurately and can display the values correctly on the serial monitor. Now, I am looking to expand the functionality of the project by adding more capabilities. For example, I would like to be able to control a fan based on humidity and temperature readings. To accomplish this, I have incorporated a new code segment that will activate the fan when the temperature exceeds 25°C and the humidity is greater than 60%. This approach will allow me to not only monitor the environment, but also take proactive measures to maintain optimal conditions, such as a cool temperature and adequate humidity levels. I am excited to continue developing this project with the Xiao ESP32-C3 board and explore more possibilities in the future.
Everything works perfectly :3
Recommendations
- Understand what is "OUTPUT": "output" refers to the output of data, signals or energy from one component, device or system to another component, device or system. The output can take various forms depending on the context and purpose of the system in question.
- "output" refers to the information or data that is displayed on the OLED screen as a result of some process or action in my case the temperature information.It could include text, graphics, images or any other visual information that is represented on the screen previously programmed.
- It is important to know the specific pins of the OLED display you are using and how they are connected to your Xiao or other microcontroller. This will allow you to properly connect the wires and communicate with the OLED display correctly.
- Most OLED displays operate with a specific power supply voltage. In your case, you mention that your OLED tolerates a 3.3V supply. It's important to adhere to this specification to avoid damaging the display. If you power the OLED with the wrong voltage, it may not function correctly or even be permanently damaged.
- These are the pins of the I2C bus communication, which are used for communication between the microcontroller (in this case, Arduino) and the OLED display. It's crucial to correctly identify these pins and connect them properly to the Arduino. If you swap the SCK and SDA pins, communication won't work, and you won't be able to display information on the OLED display properly.
Result
I love the result of my board, and even more to see that all the tracks and pine s are working correctly.
Program Buzzer
Código
// Definir el pin donde está conectado el buzzer
#define BUZZER_PIN 2
// Definiciones de las notas musicales
#define NOTE_C4 262
#define NOTE_D4 294
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_G4 392
#define NOTE_A4 440
#define NOTE_B4 494
#define NOTE_C5 523
#define NOTE_REST 0
void setup() {
// Configurar el pin del buzzer como salida
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
// Hacer sonar el buzzer con un tono de 1000Hz durante 1000ms (1 segundo)
int melody[] = {
NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_B4, NOTE_A4, NOTE_G4,
NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_B4, NOTE_A4, NOTE_G4,
NOTE_F4, NOTE_G4, NOTE_A4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_F4, NOTE_G4,
NOTE_A4, NOTE_B4, NOTE_A4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_D4, NOTE_E4,
NOTE_F4, NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_D4, NOTE_E4, NOTE_REST
};
// Duraciones de las notas (en milisegundos)
int noteDurations[] = {
4, 4, 8, 8, 8, 8, 4,
4, 4, 8, 8, 8, 8, 4,
4, 4, 8, 8, 8, 8, 8, 8,
4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4
};
// Toca el himno
for (int i = 0; i < sizeof(melody) / sizeof(melody[0]); i++) {
int duration = 1000 / noteDurations[i];
tone(BUZZER_PIN, melody[i], duration);
delay(duration * 1.1); // Agrega un pequeño tiempo entre notas para evitar que se escuchen juntas
}
noTone(BUZZER_PIN); // Detiene el sonido al finalizar el himno
delay(2000); // Espera antes de volver a reproducir el himno
tone(BUZZER_PIN, 1000);
delay(1000); // Esperar 1 segundo
// Detener el tono (silencio) durante 1000ms (1 segundo)
noTone(BUZZER_PIN);
delay(1000); // Esperar 1 segundo antes de repetir el ciclo
}
Program 1
- Definition of the pin to which the buzzer is connected
- Definitions of musical notes
- Configures the buzzer pin as an output
- Array containing the notes of the national anthem of Peru
A buzzer on Arduino is an output because it emits sound in response to electrical signals provided by the board. When you send a signal through a pin configured as an output to the buzzer, it produces mechanical vibrations that generate sound. In essence, the buzzer converts electrical signals into audible sound, which is why it is considered an output in the Arduino context.
final result
Use the 3D rendering to verify the layout of the components on your board. This will help you make sure that the components are placed correctly and that there are no space conflicts or interferences between them.
The multimeter is used to measure the continuity of the circuits, which helps to ensure that there are no short circuits or faulty connections on the board.
The 0 ohm resistor on my board plays a crucial role in the configuration of electrical connections. Although its nominal value is 0 ohms, its function is to act as a bridge or junction between two points in the circuit. This allows changes to be made to the signal or power path, providing flexibility in board design and configuration without the need to physically change components.
The multimeter helped us to measure voltages and currents at different points of the circuit, verify if the voltages and currents are within the expected values and help in the debugging process in case of errors or problems.
Efficient routing of tracks and vias minimizes electromagnetic interference and improves circuit performance
Apply heat evenly to the component and board to avoid warping and damage.
Instalar la biblioteca correctamente también garantiza que esté actualizada y optimizada, lo que puede mejorar la estabilidad y la compatibilidad con mi proyecto.
It is crucial to install the library correctly because it provides predefined functions and methods that simplify communication with the DHT sensor. This includes reading temperature and humidity data accurately and efficiently. In addition, the library handles the complexity of communicating with the sensor, allowing me to focus on the logic of my program without worrying about low-level details.
Link