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

[ERR_OUT_OF_RANGE] #13

Open
hpeyerl opened this issue Nov 29, 2023 · 0 comments
Open

[ERR_OUT_OF_RANGE] #13

hpeyerl opened this issue Nov 29, 2023 · 0 comments

Comments

@hpeyerl
Copy link

hpeyerl commented Nov 29, 2023

First off, this is amazing. I'm thrilled to have stumbled on this this morning. I built a cable for my Pi0w and connected it to my Renogy 30A. After a minor struggle getting node installed, I started node-renogy and saw this come in on my mqtt server:

NodeRenogy/device {"controllerV":12,"controllerC":30,"controllerDischgC":20,"controllerType":"Controller","controllerModel":" RNG-CTRL-WND30","softwareVersion":"V1.0.4","hardwareVersion":"V1.0.3","serialNumber":1116960,"controllerAddress":1}

Shortly thereafter though, the excitement came to a halt.

[1701278609650] INFO (3084 on gatepi): Starting NodeRenogy...
[1701278609756] INFO (3084 on gatepi): Connected to controller!
node:internal/errors:478
    ErrorCaptureStackTrace(err);
    ^

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -32768 and <= 32767. Received 33305
    at new NodeError (node:internal/errors:387:5)
    at checkInt (node:internal/buffer:72:11)
    at writeU_Int16BE (node:internal/buffer:832:3)
    at Buffer.writeInt16BE (node:internal/buffer:894:10)
    at Object.setData (/home/hpeyerl/NodeRenogy/renogy.js:24:13)
    at Object.getData (/home/hpeyerl/NodeRenogy/renogy.js:199:22)
    at async Timeout._onTimeout (/home/hpeyerl/NodeRenogy/index.js:25:32) {
  code: 'ERR_OUT_OF_RANGE'
}

The problem appears to be that my unit thinks the controller temp is 130degC which is far hotter than it actually is; thus it is returning 0x8219 which is larger than an int16.

As an experiment, I changed to UInt16BE:

diff --git a/renogy.js b/renogy.js
index 8143f15..8f45e4a 100644
--- a/renogy.js
+++ b/renogy.js
@@ -21,7 +21,7 @@ const renogyValues = {
         //Register 0x103 - Battery/Controller Temperature - 3
         //0x103 returns two bytes, one for battery and one for controller temp in c
         const buf = Buffer.alloc(2)
-        buf.writeInt16BE(rawData[3]);
+        buf.writeUInt16BE(rawData[3]);
         this.controlT = buf[0];
         this.battT = buf[1];
         //Register 0x104 - Load Voltage - 4

and now I get reasonably cogent data out of my unit.

NodeRenogy/state {"battCap":72,"battV":"12.60","battC":"0.22","controlT":130,"battT":25,"loadV":"0.00","loadC":"0.00","loadP":0,"solarV":"12.60","solarC":"0.22","solarP":2,"battVMinToday":"12.20","battVMaxToday":"12.80","chgCMaxToday":"0.54","dischgCMaxToday":"0.00","chgPMaxToday":"6.00","dischgPMaxToday":"0.00","chgAHToday":"0.00","dischgAHToday":"0.00","chgWHToday":"0.00","dischgWHToday":"0.00","uptime":501,"totalBattOverDischarges":0,"totalBattFullCharges":438,"totalChargeAH":1993,"totalDischargeAH":0,"cumulativePowerGenerated":27559,"cumulativePowerConsumed":0,"loadStatus":0,"chargingState":1,"FaultCodes":0}

I can send a pull req if you like or if you suggest some other fix I can try that. I don't really speak js though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant