Open rboydak opened 10 years ago
Hi I think this code is outdated. I will recheck and push the new codes later. I will also check the pinnings.
Hey, i´m working on a project using the ADE7758 and an Arduino UNO. I tried your code but it won´t work properly... Did you worked further on this project? If yes, can you share your new code and a schematic maybe.
Thank you!
Yes I have worked further on it but I was not able to push it because I forgot. I'll look for it next week.
On Thu, Jan 8, 2015 at 9:47 PM, EnergyChris notifications@github.com wrote:
Hey, i´m working on a project using the ADE7758 and an Arduino UNO. I tried your code but it won´t work properly... Did you worked further on this project? If yes, can you share your new code and a schematic maybe.
Thank you!
— Reply to this email directly or view it on GitHub https://github.com/engkan2kit/ADE7758/issues/1#issuecomment-69180627.
Hey,
thank you for your soon reply.
I´m looking intent for your updated code :)
Kind regards!
I pushed newer codes. However, these were from March 2014. I am not sure if this works for you directly, you might need to modify something and to solve the scaling of voltages and current. Read the Readme for further info. I will be working on this again in the near future.
On Wed, Jan 14, 2015 at 9:10 PM, EnergyChris notifications@github.com wrote:
Hey,
thank you for your soon reply.
I´m looking intent for your updated code :)
Kind regards!
— Reply to this email directly or view it on GitHub https://github.com/engkan2kit/ADE7758/issues/1#issuecomment-69913559.
Hi, Can you please share your code for arduino UNO?
I´m looking intent for your updated code too.
thanks very much!
Hi, I am trying to measure voltage and current with an arduino uno, but i can´t get it to work right. First i notice that the pins for the SPI bus are different, apparently they are defined for an arduino mega in your code. Is that correct?
Thanks a lot!
Sorry about the source codes. They got mixed-up with my other versions of this library. I initially used the SPI library but later converted it to use software SPI because my project needed the hardware SPI for a more sensitive communication and changing modes added delays.
Hi, I am trying with arduino uno to. ¿Someone could do it? I have the other question. ¿Can the ADE7758 measure DC (direct corrent)?
Thanks you
This was tested before with arduino Uno and Mega. I don't think it can measure DC correctly. if you want DC power correctly. But if you are handling DC, you can just use voltage divider and use the ADC of your arduino for the voltage and use a sense resistor for the current.
Thank you for your answer. I don't understand my situation but I have this problem (see the image) (unknown command) When I push some letter (a, b, c, d) the same thing happens.
(copy and paste for see the image) https://www.dropbox.com/s/gn680q5mrt4azhb/problema.JPG?dl=0 Do you know why?
Thank you
Can you post your code? Especially the switch/case part.
Hi, I'm trying to metering the AC and the temperature but no run. this is the code (is the same like your code)
ADE7758: `
char inputChar; // a string to hold incoming data boolean rx = false; // whether the string is complete ADE7758 myADE(&SPI,3); void setup() { Serial.begin(9600);
myADE.begin(); Serial.println("ADE7758 begins operating"); delay(1000); }
void loop() {
if (rx) { switch(inputChar){
//////////////////////////
case 't':
Serial.println("Temperature: ");
for(int k=0; k<=9; k++) //I don't know wihs is the Bit Location for temperature
{
Serial.println(myADE.getTemperature(k),HEX);
}
/////////////////////////
case 'a':
Serial.println("ENERGY readings for each phase:");
Serial.println(myADE.getWattHR(PHASE_A), HEX);
Serial.println(myADE.getWattHR(PHASE_B), HEX);
Serial.println(myADE.getWattHR(PHASE_C), HEX);
break;
case 'b':
Serial.println("CURRENT RMS readings for each phase:");
Serial.println(myADE.IRMS(PHASE_A), HEX);
Serial.println(myADE.IRMS(PHASE_B), HEX);
Serial.println(myADE.IRMS(PHASE_C), HEX);
break;
case 'c':
Serial.println("VOLTAGE RMS readings for each phase:");
Serial.println(myADE.VRMS(PHASE_A), HEX);
Serial.println(myADE.VRMS(PHASE_B), HEX);
Serial.println(myADE.VRMS(PHASE_C), HEX);
break;
case 'd':
Serial.println("Complex Energy readings for each phase:");
Serial.println(myADE.getVAHR(PHASE_A), HEX);
Serial.println(myADE.getVAHR(PHASE_B), HEX);
Serial.println(myADE.getVAHR(PHASE_C), HEX);
break;
default:
Serial.println("unknown command");
}
rx = false;
} }
void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); rx = true; } } `
ADE7758Lib.cpp
`
extern void isrGDO0event(void); SPISettings ADESETTINGS(125000, MSBFIRST, SPI_MODE1); //public ADE7758::ADE7758(SPIClass *ADESPI, int SSpin) { _ADE7758SPI=ADESPI; _SSpin=SSpin; digitalWrite(_SSpin, HIGH); //Ensure Chip select pin is output pinMode(_SSpin, OUTPUT);
}
void ADE7758::begin() { //normal mode //write8bits(OPMODE, 0x44); //spi_setup(); //write8bits(OPMODE, 0x05); }
////////////////////////////////// int ADE7758::getTemperature(char phase) { return read8bits(TEMP+phase); } //////////////////////////////////
int ADE7758::getWattHR(char phase) { return read16bits(AWATTHR+phase); }
int ADE7758::getVARHR(char phase) { return read16bits(AVARHR+phase); }
int ADE7758::getVAHR(char phase) { return read16bits(AVAHR+phase); }
long ADE7758::VRMS(char phase) { char i=0; long volts=0; getVRMS(phase);//Ignore first reading for(i=0;i<10;++i){ volts+=getVRMS(phase); delayMicroseconds(50); } //average return volts/10; }
long ADE7758::IRMS(char phase) { char i=0; long current=0; getIRMS(phase);//Ignore first reading for(i=0;i<10;++i){ current+=getIRMS(phase); delayMicroseconds(50); } //average return current/10; }
void accumulateEnergy() {
}
long ADE7758::waveform(char phase,char source) {
}
void ADE7758::powerOff() {
}
void ADE7758::powerON() {
}
void ADE7758::sleep() {
}
void ADE7758::wakeUp() {
}
long ADE7758::getInterruptStatus(void){ return read24bits(STATUS); }
long ADE7758::getResetInterruptStatus(void){ return read24bits(RSTATUS); }
int ADE7758::lineFreq(char phase){ uint8_t mmode; mmode = read8bits(MMODE); write8bits(MMODE,(mmode&0x11111100 )| phase); delay(10); return read16bits(FREQ); } //private
void ADE7758::enableChip() {
digitalWrite(_SSpin, LOW);
}
void ADE7758::disableChip() { digitalWrite(_SSpin, HIGH); }
void ADE7758::write8bits(char reg, unsigned char data) { _ADE7758SPI->beginTransaction(ADESETTINGS); enableChip();
delay(10); _ADE7758SPI->transfer(REG_WRITE(reg)); delay(2);
_ADE7758SPI->transfer(data);
delay(1);
disableChip(); _ADE7758SPI->endTransaction(); }
void ADE7758::write16bits(char reg, unsigned int data) { _ADE7758SPI->beginTransaction(ADESETTINGS); enableChip();
delay(10); _ADE7758SPI->transfer(REG_WRITE(reg)); delay(2); _ADE7758SPI->transfer((unsigned char)((data>>8)&0xFF)); delay(2); _ADE7758SPI->transfer((unsigned char)(data&0xFF)); delay(1);
disableChip(); _ADE7758SPI->endTransaction(); }
unsigned char ADE7758::read8bits(char reg) { _ADE7758SPI->beginTransaction(ADESETTINGS); enableChip();
unsigned char ret; delay(10); _ADE7758SPI->transfer(REG_READ(reg)); delay(2); ret=_ADE7758SPI->transfer(0x00); delay(1);
disableChip(); _ADE7758SPI->endTransaction(); return ret; }
unsigned int ADE7758::read16bits(char reg) { _ADE7758SPI->beginTransaction(ADESETTINGS); enableChip(); unsigned int ret=0; unsigned char ret0=0; delay(10); _ADE7758SPI->transfer(REG_READ(reg)); delay(2); ret=_ADE7758SPI->transfer(0x00); delay(2); ret0=_ADE7758SPI->transfer(0x00); delay(1);
disableChip(); _ADE7758SPI->endTransaction(); ret= (ret<<8)|ret0; return ret; }
unsigned long ADE7758::read24bits(char reg) { _ADE7758SPI->beginTransaction(ADESETTINGS); enableChip(); unsigned long ret=0; unsigned int ret1=0; unsigned char ret0=0; delay(10); _ADE7758SPI->transfer(REG_READ(reg)); delay(2); ret=_ADE7758SPI->transfer(0x00); delay(2); ret1=_ADE7758SPI->transfer(0x00); delay(2); ret0=_ADE7758SPI->transfer(0x00); delay(1);
disableChip();
_ADE7758SPI->endTransaction();
ret= (ret<<16)|(ret1<<8)|ret0;
return ret;
}
long ADE7758::getIRMS(char phase) { return read24bits(AIRMS+phase); }
long ADE7758::getVRMS(char phase)
{
return read24bits(AVRMS+phase);
}
`
ADE7758Lib.h
`
//PHASE_SEL
//WAV_SEL
//interrupt mask/status bit
class ADE7758 { public: ADE7758 (SPIClass *,int ); void begin(); int WattHR(char ); int VARHR(char ); int VAHR(char ); long VRMS(char ); long IRMS(char ); long waveform(char ,char ); int lineFreq(char );
void accumulateEnergy();
void powerOff();
void powerON();
void sleep();
void wakeUp();
long getInterruptStatus(void);
long getResetInterruptStatus(void);
void enableChip();
void disableChip();
void write8bits(char , unsigned char );
void write16bits(char , unsigned int );
unsigned char read8bits(char );
unsigned int read16bits(char );
unsigned long read24bits(char );
//////////////////
int getTemperature(char);
/////////////////
long getIRMS(char );
long getVRMS(char );
int getWattHR(char );
int getVARHR(char );
int getVAHR(char );
private:
SPIClass *_ADE7758SPI;
int _SSpin;
long accuWattHRA;
long accuWattHRB;
long accuVARHRA;
long accuVARHRB;
long accuVAHRA;
long accuVAHRB;
};
`
Thank you so much for your help
They way I see it in you switch statement, if you enter a 't', it goes to the case 't'. However, since you did not put a break, it will still check for the next cases which will not match 't'. Therefore, it goes to the default: Serial.println("unknown command"); Also, I forgot to implement the TEMP(0x11) register temperature computation. But it is in the datasheet. The function should not accept a second argument. We are supposed to add a temperature sensor inside a transformer per phase that is why we put that function like that but we never had time to implement it. Therefor, the getTemperature(0) just put zero in it. Itshould return the content of the TEMP register. Just use the computation in datasheet.
Thank you for your help. I did that, but I coninue with the problem.
I dowloand your code and I have the same problem (unknown command) Do you have any other ideas? Thank you.
You should check your code again. Inside the serial event, you had char inChar, but you are using inputChar in your loop. change it to this:
void serialEvent() { while (Serial.available()) { // get the new byte: inputChar = (char)Serial.read(); rx = true; } }
On Mon, Jul 17, 2017 at 3:35 AM, 2Peter notifications@github.com wrote:
Thank you for your help. I did that, but I coninue with the problem.
I dowloand your code and I have the same problem (unknown command) Do you have any other ideas? Thank you.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/engkan2kit/ADE7758/issues/1#issuecomment-315631653, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTqU1qRHSUY8Ur_eN8kjqc2eugx_SF9ks5sOmYDgaJpZM4B7IWV .
Hi, I tried it and this is the result: https://www.dropbox.com/s/239l2mqnrdwg8wj/void%20changer.JPG?dl=0 (not meter the temperature, for example)
I think that the problem is in the circuit diagram. Can you check this picture please? https://www.dropbox.com/s/qxpozynnyq6l99q/circuito%20temperatura.jpeg?dl=0
I used the SPI connection, only for meter temperature. This is correct ?
Thank you.
Wiring seems fine. How is the "-" and the gnd of the ade7758 connected the gnd of arduino?
On Jul 20, 2017 3:31 AM, "2Peter" notifications@github.com wrote:
Hi, I tried it and this is the result: https://www.dropbox.com/s/ 239l2mqnrdwg8wj/void%20changer.JPG?dl=0 http://url (not meter the temperature, for example)
I think that the problem is in the circuit diagram. Can you check this picture please? https://www.dropbox.com/s/qxpozynnyq6l99q/circuito% 20temperatura.jpeg?dl=0 http://url
I used the SPI conection, This is correct ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/engkan2kit/ADE7758/issues/1#issuecomment-316492410, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTqU4Pq7oT2z1voc6MYT7faEIhOyx8dks5sPlmDgaJpZM4B7IWV .
Sorry, the "-" is the GND of arduino. I did a modification to know if arduino take the temperature's data, but not (check the picture) https://www.dropbox.com/s/xzs71xl4cj03j8y/temperatura_he_pedido_dato.JPG?dl=0 With the voltage happen the same
engkan2kit
HI.,., Can you please share the updated code for ADE7758., the old code is not working.,.
engkan2kit
HI.,., Can you please share the updated code for ADE7758., the old code is not working.,.
Hi Sorry, I don't have the hardware for this anymore. If you can send me the eval board for ADE7758, I can update the code and ensure it works.
Hi.,. the ADE7758 library works well for the arduino UNO.,., but not responding good for esp8266 series.,. can you help us??
it is giving wrong data.,., any spi settings to be changed??
On Fri, Sep 1, 2023 at 4:24 PM Kister Genesis Jimenez < @.***> wrote:
engkan2kit
HI.,., Can you please share the updated code for ADE7758., the old code is not working.,.
Hi Sorry, I don't have the hardware for this anymore. If you can send me the eval board for ADE7758, I can update the code and ensure it works.
— Reply to this email directly, view it on GitHub https://github.com/engkan2kit/ADE7758/issues/1#issuecomment-1702561891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKHRYCWJUKFTDJ7L7GKJ73LXYG5IFANCNFSM4APMQWKQ . You are receiving this because you commented.Message ID: @.***>
-- With thanks and Regards G.R.Kanagachidambaresan, eee1.blogspot.com +91-9994120988.
Hi, I have made the SPI between ADE7758 and arduino to measure Vrms but it starts to count instead of measuring the voltage, can anyone help me with this problem?
Thank you for sharing... where can ı find any schematic or wiring about ade7758 for using with arduino ?