Hi user5870291, Welcome to the E2E forum! In your while loop you are continually reading the buffer, but data at 20sps only becomes available every 50ms. So when using the automatic data read mode, you must make sure that new contents are in the buffer before reading it, otherwise you will be seeing an empty buffer (all 0's). Note that sending a START command in the middle of a conversion will restart the conversion making the time for when the data is output even longer. There are a number of ways to overcome this issue. One is by delaying the reading of the buffer so that you wait 50ms between reads. Another method is to use GPIO2 and set it to DRDY mode then trigger an interrupt (or poll the input pin of the micro) to capture the new data following the high to low DRDY transition. Yet another alternative may be to monitor the UART interrupt status looking for new data available on the RX buffer. The last alternative is to not use the automatic mode but rather manually read the data by using the RDATA command. So you may wish to use a combination, such as monitoring DRDY then manually reading the data. Best regards. Bob B
↧