I have a question regarding the Offset value for an ACS758.
This module is tuned from the manufacturer on 5v. Due to analogRead on Photon is not 5v tolerant, it is powered via 3V3.
Below is the following code for use with Arduino. The offsets are 2500 and 600 for Bi-directional and Uni-directional.
/*
Henry's Bench
ACS758 Current Measurement Tutorial
*/
const int analogIn = A0;
// Set your scale factor
int mVperAmp = 40; // See Scale Factors Below
/* Scale Factors
50A bi-directional = 40
50A uni-directional = 60
100A bi-directional = 20
100A uni-directional = 40
150A bi-directional = 13.3
150A uni-directioal = 26.7
200A bi-directional = 10
200A uni-directional = 20
*/
// Set you Offset
int ACSoffset = 2500; // See offsets below
/* Offsets
If bi-directional = 2500
If uni- directional = 600
*/
int RawValue= 0;
double Voltage = 0;
double Amps = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
RawValue = analogRead(analogIn);
Voltage = (RawValue / 1023.0) * 5000; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
Should these offsets be changed to 1650 and 396 due to using 3.3v instead of 5v?
Below as an example.
/*
Henry's Bench
ACS758 Current Measurement Tutorial
*/
const int analogIn = A0;
// Set your scale factor
int mVperAmp = 40; // See Scale Factors Below
/* Scale Factors
50A bi-directional = 40
50A uni-directional = 60
100A bi-directional = 20
100A uni-directional = 40
150A bi-directional = 13.3
150A uni-directioal = 26.7
200A bi-directional = 10
200A uni-directional = 20
*/
// Set you Offset
int ACSoffset = 1650; // See offsets below
/* Offsets
If bi-directional = 1650
If uni- directional = 396
*/
int RawValue= 0;
double Voltage = 0;
double Amps = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
RawValue = analogRead(analogIn);
Voltage = (RawValue / 4095.0) * 3300; // Gets you mV
Amps = ((Voltage - ACSoffset) / mVperAmp);
The other question I have is:
Any way of using 5v instead of 3.3v for the measurement?
This obviously is not safe if using A0.
If using the 50amp sensor and only needing to read up to lets say 30amp should be safe but not ideal.