AMS5812-300-D Pressure returned as NaN

Hello. I’m trying to get a reading off of my pressure sensor with a Raspberry Pi ultimately using Node-Red.

I’ve installed an NCD I2C shield and connected the AMS5812 to the shield via the In port. I’ve installed the NPM module as per the Node-Red Dashboard instructions however I can not get a pressure reading. I’ve applied 15PSI to port 2 on the AMS5812. I’ve configured the test.js file that came with the module to use I2C and set the range to 300. I get a temperature reading however the pressure is returned as NaN.

{ pressure: NaN, temperature: 25.010681315327687 }

Appreciate any assistance in setting this up - or pointers on how to work out what the error is.

Didn’t get any support on this but thought I would leave this incase someone else has similar issues.

Looking at the code I have found the issue. In the ncd-red-ams5812 module, index.js the config object has pScale set as a string “mbar”. If the parameter is omitted as it is in test.js, index.js try’s to perform a calculation using that parameter on line 45 hence NaN.

this.status.pressure = ((pCounts - 3277) / (26214 / (max-min)) + min) * this.config.pScale

Work around with the test.js file is to define the pScale parameter which overwrites it. As I’m using PSI it was a case of setting it to 1.

test.js edit the following:
var config = {
range: 300,
sType: “d”,
tempScale: “c”

change it to:
var config = {
range: 300,
sType: “d”,
tempScale: “c”,
pScale: 1

You could probably just edit the index.js code as well however ideally we shouldn’t need to touch that right?

Whoever maintains the ncd-red-ams5812 node red module might need to review their code maybe?

Once I worked this out to get node-red to show the correct pressure it was just a case of configuring the AMS5812 node to use mBar which sets the pScale to 1 then set the pressure gauge’s Units and Max values. I presume this bug or another is why I have to set the scale to 1 (mbar) even though I wanted PSI.

I seem to be all sorted now.