Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Importance and Utility of Current Sensor
The ability to measure electrical current is crucial in many applications, such as power monitoring, energy management, and industrial automation. Current sensors allow us to monitor the flow of electrical current in a circuit, providing valuable information about power consumption, load balancing, and system health. By integrating current sensors with Arduino, we can easily collect and analyze current data, enabling us to make informed decisions and optimize our electrical systems.
Project: Current Monitoring System
In this project, we will create a current monitoring system using Arduino and a current sensor. The system will measure the AC current flowing through a load and display it on an LCD screen. The objectives of this project are to:
List of Components:
To build this project, you will need the following components:
Arduino Uno - 1x [Link: https://www.arduino.cc/en/Main/ArduinoBoardUno]
Current Sensor (ACS712) - 1x [Link: https://www.sparkfun.com/products/11005]
LCD Display (16x2) - 1x [Link: https://www.adafruit.com/product/181]
Breadboard - 1x [Link: https://www.sparkfun.com/products/12615]
Jumper Wires - As required [Link: https://www.sparkfun.com/products/11026]
Examples:
Example 1: Read and Display Real-Time Current
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD connections
const int currentSensorPin = A0; // Current sensor analog pin
void setup() {
lcd.begin(16, 2); // Initialize LCD
lcd.print("Current:"); // Display label
pinMode(currentSensorPin, INPUT); // Set current sensor pin as input
}
void loop() {
int rawValue = analogRead(currentSensorPin); // Read raw ADC value
float current = map(rawValue, 0, 1023, 0, 5); // Convert ADC value to current (0-5A)
lcd.setCursor(8, 0); // Set cursor position
lcd.print(current, 2); // Display current with 2 decimal places
delay(1000); // Delay for 1 second
}
Example 2: Calculate and Display Average Current
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD connections
const int currentSensorPin = A0; // Current sensor analog pin
const int sampleCount = 10; // Number of samples for averaging
void setup() {
lcd.begin(16, 2); // Initialize LCD
lcd.print("Avg Current:"); // Display label
pinMode(currentSensorPin, INPUT); // Set current sensor pin as input
}
void loop() {
float sum = 0;
for (int i = 0; i < sampleCount; i++) {
int rawValue = analogRead(currentSensorPin); // Read raw ADC value
float current = map(rawValue, 0, 1023, 0, 5); // Convert ADC value to current (0-5A)
sum += current; // Accumulate current values
delay(100); // Delay between samples
}
float average = sum / sampleCount; // Calculate average current
lcd.setCursor(13, 0); // Set cursor position
lcd.print(average, 2); // Display average current with 2 decimal places
delay(1000); // Delay for 1 second
}
Example 3: Set Thresholds and Trigger Alerts
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD connections
const int currentSensorPin = A0; // Current sensor analog pin
const float threshold = 3.5; // Current threshold (in Amperes)
void setup() {
lcd.begin(16, 2); // Initialize LCD
lcd.print("Current:"); // Display label
pinMode(currentSensorPin, INPUT); // Set current sensor pin as input
}
void loop() {
int rawValue = analogRead(currentSensorPin); // Read raw ADC value
float current = map(rawValue, 0, 1023, 0, 5); // Convert ADC value to current (0-5A)
lcd.setCursor(8, 0); // Set cursor position
lcd.print(current, 2); // Display current with 2 decimal places
if (current > threshold) {
lcd.setCursor(0, 1); // Set cursor position
lcd.print("Current exceeded!"); // Display alert message
} else {
lcd.setCursor(0, 1); // Set cursor position
lcd.print(" "); // Clear alert message
}
delay(1000); // Delay for 1 second
}