Adafruit HUZZAH32 - ESP32 Feather and AC Current Sensor

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
JoanCS
 
Posts: 55
Joined: Thu May 07, 2020 12:43 pm

Adafruit HUZZAH32 - ESP32 Feather and AC Current Sensor

Post by JoanCS »

https://wiki.dfrobot.com/Gravity_Analog ... U_SEN0211_

I produced this assembly but with an "Adafruit HUZZAH32 - ESP32 Feather". Change A2 to A3, so as not to have a problem with Wi-Fi.
With an Arduino UNO, putting "VREF 5.0" works fine.
With the "ESP32 Feather" the "VREF 3.3" did not work for me. I don't bully because it doesn't work well for me.

Code: Select all

/*!
 * @file readACCurrent.
 * @n This example reads Analog AC Current Sensor.

 * @copyright   Copyright (c) 2010 DFRobot Co.Ltd (https://www.dfrobot.com)
 * @licence     The MIT License (MIT)
 * @get from https://www.dfrobot.com

 Created 2016-3-10
 By berinie BANNED <[email protected]>

 Revised 2019-8-6
 By Henry BANNED<[email protected]>
*/

const int ACPin = A3;         //set arduino signal read pin
#define BANNED 20;    //set Non-invasive AC Current Sensor tection range (5A,10A,20A)

// VREF: Analog reference
// For Arduino UNO, Leonardo and mega2560, etc. change VREF to 5
// For Arduino Zero, Due, MKR Family, ESP32, etc. 3V3 controllers, change VREF to 3.3
//#define VREF 5.0
#define VREF 3.3

float readACCurrentValue()
{
  float ACCurrtntValue = 0;
  float peakVoltage = 0;  
  float voltageVirtualValue = 0;  //Vrms
  for (int i = 0; i < 5; i++)
  {
    peakVoltage += analogRead(ACPin);   //read peak voltage
    delay(1);
  }
  peakVoltage = peakVoltage / 5;   
  voltageVirtualValue = peakVoltage * 0.707;    //change the peak voltage to the Virtual Value of voltage

  /*The circuit is amplified by 2 times, so it is divided by 2.*/
  voltageVirtualValue = (voltageVirtualValue / 1024 * VREF ) / 2;  

  ACCurrtntValue = voltageVirtualValue * BANNED;

  return ACCurrtntValue;
}

void setup() 
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);

}

void loop() 
{
  float ACCurrentValue = readACCurrentValue(); //read AC Current Value
  Serial.print(ACCurrentValue);
  Serial.println(" A");
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}
The results are: 5.06A and the reality is 2.5A and 16.01A and the reality is 5.3A

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”