Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add calibration function to the library #12

Open
devicter opened this issue Aug 23, 2019 · 18 comments
Open

Add calibration function to the library #12

devicter opened this issue Aug 23, 2019 · 18 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@devicter
Copy link

The chip supports this.
This seems to be in the documentation. It would be great.

The format of the master command for calibrating a slave (6 bytes in total):

0xF8 + 0x41 + 0x37 + 0x21 + CRC check high byte + CRC check low byte.

Correct answer: 0xF8 + 0x41 + 0x37 + 0x21 + CRC check high byte + CRC check low byte.

Error response: 0xF8 + 0xC1 + anomalous code + CRC check high byte + CRC check low byte.

It should be noted that the calibration takes from 3 to 4 seconds, after the master sends a command, if the calibration is successful, it takes 3-4 seconds to get a response from the slave.

@mandulaj
Copy link
Owner

mandulaj commented Oct 1, 2019

I have to still play with the calibration feature. I have heard that you can even ruin your device. I will only add it when I am confident it works well. Thanks, I will put it higher up in my priority list.

@mandulaj mandulaj added enhancement New feature or request help wanted Extra attention is needed labels Oct 1, 2019
@RB3rg
Copy link

RB3rg commented Feb 27, 2020

I doubt this "calibration" works just like that.
It will need a reference, a specific voltage, and current to be used as a reference.
@devicter have you ever tested this calibration?
If not, you can use node-red to test it however if I am correct, as @mandulaj said, you will ruin your device. Let us know the result.

@mandulaj
Copy link
Owner

Has anyone had time to look at this?

@xavipolo
Copy link

I don't think it makes sense.
As RB3rg says, the calibration function should receive a parameter that modifies the readings.
If you connect a 12W bulb, and the reading is 11W, you should be able to calibrate it to 12W or +1W

As documented the message must be 6 bytes
0xF8 + 0x41 + 0x37 + 0x21 + CRC check high byte + CRC check low byte.

0xF8: I think this is the slave address (0x01 by default)
0x41 is the calibration function
0x37 and 0x21 could be the adjustment value (data high and low bytes) signed?

@morganflint
Copy link

morganflint commented Jul 26, 2020

More probably, I imagine you'll have to feed a specific voltage and current from a precision source to the module and then call the calibration function. In that case, without knowing these parameters, the calibration function is useless for us.

Anyway, the calibration option is included in the Windows software provided by Peacefair, even in the case the calibration procedure was well documented, anybody wanting to calibrate a module could do it from that software, so I don't think the function is needed (nor desirable if, as has been said, it could ruin the module) in the library.

@Nismonx
Copy link

Nismonx commented Jul 29, 2020

15960111613616626068608358322857
Thought this might help...
Although I still uncertain if this is to be done with an know load or off load.

@RB3rg
Copy link

RB3rg commented Jul 31, 2020

0xF8 is the broadcast address for Modbus so any device will catch it.
0x41 is the function of cal.
Now comes the question, the device reads voltage and current.
Calibration needs a reference, in this case, Voltage & Current though the 0x37 0x21 results (int) 14113
I can't see 14113 being the Voltage+Current to be compared.
Those guys are Chinese so 220V/50Hz is the standard, something around 220 should be pass in the calibration parameter.
Another point, the calibration should be float for precision (220.32), anyone can see how to pass (float)voltage + current into 2 bytes?.

@Jackaro0z
Copy link

0x37 0x21 is the password. Refer to datasheet intro.

@poweredscript
Copy link

poweredscript commented Aug 7, 2020

I tried to calibration even though it was successful.
But when the power supply is disconnected and connected again, the MCU does not remember the calibration done.
I'm confused, what am I missing?
This is my code

//The command format of the master to calibrate the slave is (total 6 bytes):
//               0xF8 + 0x41 + 0x37 + 0x21 + CRC check high byte + CRC check low byte.
//Correct reply: 0xF8 + 0x41 + 0x37 + 0x21 + CRC check high byte + CRC check low byte. 6
//Error Reply:   0xF8 + 0xC1 + Abnormal code + CRC check high byte + CRC check low byte. 5
bool PZEM004Tv30::setCalibration(){
    uint8_t buffer[] = {0xF8, 0x41, 0x37, 0x21, 0x00, 0x00}; // Work
	//uint8_t buffer[] = {0x01, 0x41, 0x37, 0x21, 0x00, 0x00}; // Work
    uint8_t reply[6];   

    setCRC(buffer, 6);
    _serial->write(buffer, 6);

    uint16_t length = recieve(reply, 6);

	// for(int i = 0; i < sizeof(reply); i++){
		// Serial.print("0x");
       // Serial.print(reply[i] < 16 ? "0" : "");
       // Serial.println(reply[i], HEX);
    // }
	
    if(length == 0 || length == 5){
        return false;
    }
    return true;
}

@Nismonx
Copy link

Nismonx commented Aug 7, 2020

@poweredscript

In what condition you had the PZEM when you attempt your calibration calibration code?
In windows it always return calibration fail, have tried with/or without load.
PZEM004T

Request F8 41 37 21 B7 78 //Send-Calibration request
Return: F8 C1 04 A0 62 //Calibration fail

@poweredscript
Copy link

@Nismonx

My code is adding a function to the library.
As for the program you use, I think it should have an instruction manual "the user manual of the software.txt"
If you do not use voltage and current, the program requirements cannot be calibrated.

The user manual of the software

1.Before use it, please click the กพrunกฟdocument to login, after login successfully, you can use the software.

2.In all parameter setting,if the color is gray,that means it can't be amend, other color means it can be amend.

3.At present,this software is standalone version, not support Multimachine communication,that means if you want to
use more than one module at the same time, you should set the address of each module in advance, then use the
address to distinguish the termianl box when read or set the data.

4.Power alarm way is: the power data display become to read in the software.There is no power alarm signal output
driving port in the module PCB.

5.Please be with caution to use the calibration function in the software!
The module has been calibrated at least twice with the professional equipment before delivery, so the data will
has problem in general.
If it is must be calibrated because of the defective product,the calibrationg password is: PZEM014/6
Calibration condition:
PZEM-014: VOLTAGE:220v,CURRENT:1A
PZEM-016: VOLTAGE:220v,CURRENT:10A

@Nismonx
Copy link

Nismonx commented Aug 8, 2020

@poweredscript

I was just concerned that the calibration simply may not work and clearly misconstrued the last 2 paragraphs:

""....
Calibration condition:
PZEM-014: VOLTAGE:220v,CURRENT:1A
PZEM-016: VOLTAGE:220v,CURRENT:10A ""

I have use a 220v pressure with a 1amp load and had the same outcome (calibration failed) but its as far as I went. The picture above was a very poor choice of mine.

Thanks for pointing this out I just realise where I gone wrong , I have a PZEM-016.

@morganflint
Copy link

morganflint commented Aug 17, 2020

Apparently, in the "Set parameters" option, you can see the calibration conditions for a module (but they are greyed out, so cannot be changed):
CapturaPZEM2

Anyway, I wouldn't calibrate it unless I had a precision AC source and load...

@RB3rg
Copy link

RB3rg commented Sep 20, 2020

Apparently, in the "Set parameters" option, you can see the calibration conditions for a module (but they are greyed out, so cannot be changed):
CapturaPZEM2

Anyway, I wouldn't calibrate it unless I had a precision AC source and load...

@morganflint can you share this PZEM014 Master?
The one I found doesn't run.
Then I will have a look into this.

@morganflint
Copy link

Hello, although in the screen says "PZEM014Master", I downloaded and installed it as PZEM004TMaster:
image

I think I downloaded it from the link that can be found at Peacefair's Aliexpress shop product page, but I'm enclosing it here just in case:
004T software+driver+user manual.zip

@sirapol
Copy link

sirapol commented May 31, 2021

Hello , Is this issues solve or not ?
I still like your problem "The calibration failed!"

@poweredscript
Copy link

Hello , Is this issues solve or not ?
I still like your problem "The calibration failed!"
The problem has not been resolved.

@mandulaj mandulaj added this to the Release 1.2.0 milestone Jul 16, 2021
@sanj2002
Copy link

sanj2002 commented Nov 3, 2024

Iam using software for calibration it won't take default password help me out friends if any one did calibration through pc Software

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants