Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Current Sensor - Measuring Electrical Current with Arduino

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:

  1. Measure and display real-time current readings.
  2. Calculate and display the average current over a certain period.
  3. Set thresholds and trigger alerts when the current exceeds predefined limits.
  4. Store and analyze historical current data for further analysis.

List of Components:

To build this project, you will need the following components:

  1. Arduino Uno - 1x [Link: https://www.arduino.cc/en/Main/ArduinoBoardUno]

  2. Current Sensor (ACS712) - 1x [Link: https://www.sparkfun.com/products/11005]

  3. LCD Display (16x2) - 1x [Link: https://www.adafruit.com/product/181]

  4. Breadboard - 1x [Link: https://www.sparkfun.com/products/12615]

  5. 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
}

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.