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

Understanding the SCT-013 Current Sensor

In this article, we will explore the SCT-013 current sensor and its application in the Arduino environment. Understanding how to use this sensor is crucial for various projects that involve measuring AC current. We will discuss the importance of the SCT-013 sensor, its compatibility with Arduino, and any necessary adjustments required to integrate it into Arduino-based projects.

Project: Creating an AC Current Monitoring System

For our project example, we will create an AC current monitoring system using the SCT-013 sensor and Arduino. The objective of this project is to measure the current flowing through an AC line and display it on an LCD screen. This system can be used for various applications like energy monitoring, power consumption analysis, and equipment protection.

Components List:

  • Arduino Uno (1)
  • SCT-013 Current Sensor (1)
  • LCD Display (16x2) (1)
  • Breadboard (1)
  • Jumper wires

Examples:

  1. Reading AC Current using SCT-013 Sensor
// Include the necessary libraries
#include <LiquidCrystal_I2C.h>

// Define the pins for the SCT-013 sensor and LCD display
const int sensorPin = A0;
const int lcdAddress = 0x27;  // I2C address of the LCD display

// Create an instance of the LCD display object
LiquidCrystal_I2C lcd(lcdAddress, 16, 2);

void setup() {
  // Initialize the LCD display
  lcd.begin(16, 2);
  lcd.print("AC Current: ");

  // Set up the serial communication
  Serial.begin(9600);
}

void loop() {
  // Read the analog value from the SCT-013 sensor
  int sensorValue = analogRead(sensorPin);

  // Convert the analog value to current in Amperes
  float current = sensorValue * 0.0049;  // Adjust this value based on calibration

  // Display the current value on the LCD display
  lcd.setCursor(0, 1);
  lcd.print(current);
  lcd.print(" A");

  // Print the current value to the serial monitor
  Serial.println(current);

  delay(1000);  // Delay for 1 second
}

In this example, we use the SCT-013 sensor to measure the AC current. The analog value from the sensor is converted to the corresponding current value using a calibration factor. The current value is then displayed on the LCD screen and printed to the serial monitor.

  1. Calibrating the SCT-013 Sensor
// Include the necessary libraries
#include <LiquidCrystal_I2C.h>

// Define the pins for the SCT-013 sensor and LCD display
const int sensorPin = A0;
const int lcdAddress = 0x27;  // I2C address of the LCD display

// Create an instance of the LCD display object
LiquidCrystal_I2C lcd(lcdAddress, 16, 2);

// Calibration variables
const float calibrationFactor = 0.0049;  // Adjust this value based on calibration
float offset = 0.0;

void setup() {
  // Initialize the LCD display
  lcd.begin(16, 2);
  lcd.print("Calibrating...");

  // Set up the serial communication
  Serial.begin(9600);

  // Perform calibration
  offset = calibrateSensor();

  lcd.clear();
  lcd.print("Calibration done");
  delay(2000);
  lcd.clear();
}

void loop() {
  // Read the analog value from the SCT-013 sensor
  int sensorValue = analogRead(sensorPin);

  // Apply calibration and calculate the current value
  float current = (sensorValue - offset) * calibrationFactor;

  // Display the current value on the LCD display
  lcd.setCursor(0, 1);
  lcd.print(current);
  lcd.print(" A");

  // Print the current value to the serial monitor
  Serial.println(current);

  delay(1000);  // Delay for 1 second
}

float calibrateSensor() {
  // Perform calibration by averaging sensor readings for a short period

  const int numReadings = 100;
  int sum = 0;

  for (int i = 0; i < numReadings; i++) {
    int sensorValue = analogRead(sensorPin);
    sum += sensorValue;
    delay(10);
  }

  return sum / numReadings;
}

In this example, we add a calibration step to improve the accuracy of the current measurement. The calibrateSensor() function is used to calculate the offset value by averaging multiple sensor readings. This offset is then subtracted from subsequent sensor readings to obtain the calibrated current value.

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.