Hi Everybody,
I am new on this forum , but have some experience with arduino.
Recently I decided to build some kind of variometer for my RC plane based on arduino uno+LPS25H. Unfortunately, this sensor in default settings has poor accuracy and vario in that condition does not make sense - error is approx +-1m.
In order to improve accurancy I have to turn on FIFO mode , but to do this I have to change register according to decryption "The FIFO buffer is enabled by setting to 1 the FIFO_EN bit (21h - CTRL_REG2)" and then select "FIFO mean mode (F_MODE2:0=”110” in FIFO_CTRL (2Eh))".
According to documentation in"LPS25H.h" file I have:
"void writeReg(int reg, byte value);"
I wrote this simply code to check register , but apparently I did something wrong , because in the results
FIFO CHECK=
32 //FIFO_EN=0x2F
0 //CTRL_REG2=0x21;
41 //FIFO_CTRL=0x2E;
Status&MODE after change=
32
0
110
Would be somebody so nice and help me?
Thank you in advance.
Code:
#include <Wire.h>
#include <LPS25H.h>
LPS25H ps;
//ON
int CTRL_REG2=0x21;
byte valueON = 1;
//MODE
int FIFO_CTRL=0x2E;
byte valueCH =110;
//CHECK
int FIFO_EN=0x2F;
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!ps.init())
{
Serial.println("Failed to autodetect pressure sensor!");
while (1);
}
ps.enableDefault();
Serial.println("FIFO CHECK=");
Serial.println(ps.readReg(FIFO_EN));
Serial.println(ps.readReg(CTRL_REG2));
Serial.println(ps.readReg(FIFO_CTRL));
Serial.println(" ");
Serial.println("Status&MODE after change=");
ps.writeReg(CTRL_REG2,valueON);
ps.writeReg(FIFO_CTRL,valueCH);
Serial.println(ps.readReg(FIFO_EN));
Serial.println(ps.readReg(CTRL_REG2));
Serial.println(ps.readReg(FIFO_CTRL));
}