Hello!
I have been trying to read a flow sensor with the nRF52840 DK, but the output is unexpected.
It has been proven that the flow sensor is functional, by connecting it with another MCU.
When I used a logic analyzer, the output I received was completely normal, meaning that the flow sensor is actually sending some values, and the DK receives them correctly. The thing is that the values that the flow sensor sends are incorrect. So, the flow sensor gives off incorrect values, but there is no problem with the DK.
After that, I tried to find what was wrong, and for the life of me, I could not see anything wrong with my code. As a result, I started all over from the TWI sensor example. Nothing changed. Even at the most basic level of TWI code, the registers I am reading are giving me the wrong info. What is curious is that when I use the same sensor with a BBB board, where I do not know and cannot change the code that is being executed, the flow sensor gives correct values. So it is not a sensor problem.
I am attaching you the twi code and the sensor's datasheet, where I have highlighted some lines on page 6, so you can understand a bit about the register I am trying to read. Chapter 2.4 is also quite useful. The sensor, by default, jumps into reading the flow register, and so I do not change the register read in my code. In the code, I am just shooting the sensor's flow registers values in the Terminal, every time a twi event occurs. I do not try to translate the data into real values, since I see that the raw register values are incorrect. The output of the code is shown in the figure. The red square contains the 7F-FF registers that denote the full-scale positive flow, which is totally incorrect, since I cannot produce such a flow (500LPM).
Do you have any idea what I am doing wrong?
I am truly pissed, because I know that it is a very simple application, but I cannot get it to work.
Thank you in advance,
Kostas
7723.twi_sensor_mine.zip4571.ESF Series I2C Interface_v2.pdf