user28629: I am trying to connect an ADXL355 digital sensor to an Arduino. The wiring and the code I think are OK because the system returns the correct values sometimes and partly correct answers mostly. The code checks the device register, and the correct data is printed to serial most of the time. The code also checks for temperature but only returns the correct value occasionally. The values are polled every few seconds. The values are correct all of the time if they are correct the first time after restart but never if they are incorrect on restart. I thought it might help to unplug the sensor when uploading the program or powering up the Arduino through USB to the computer but there is no clear pattern.
It is not a defective sensor because I have 2 that behave the same way. What could be the problem? Is this a problem with the Arduino? 

I only wire VDD, VDDIO, ground,chip select, sclk, MOSI and MISO.
code:
#include <SPI.h>

    const int ID = 0x00;
    const int FIFO = 0x11;
    const int TEMP = 0x06;
    const int TEMP1 = 0x07;
    const byte FIFO_WATERMARK = 0x29;
    const int chipSelectPin = 7;


    void setup() {
        Serial.begin(9600);

        SPI.begin();

        pinMode(dataReadyPin, INPUT);
        pinMode(chipSelectPin, OUTPUT);

        // writing 0 to to enable sensor
        writeRegister(0x2D, 0x00);

        delay(100);

        Serial.println(readRegister(ID));
        Serial.println(readRegister(FIFO_WATERMARK));
    }

    void loop() {
        int temp = (readRegister(TEMP)); // << 8) | (readRegister(TEMP1))) ;
        temp = (temp<<8)|(readRegister(TEMP1));
        Serial.println(((1852 - temp)/9.05) + 19.21);
        Serial.println(readRegister(ID));

        delay(1000);
    }

    byte readRegister (byte thisRegister){
        byte inByte = 0 ;
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer((thisRegister << 1) | 1);
        inByte = SPI.transfer(0x00);
        digitalWrite(chipSelectPin, HIGH);
        return inByte;
    }
    void writeRegister (byte thisRegister, byte value){
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer(thisRegister << 1);
        SPI.transfer(value);
        digitalWrite(chipSelectPin, HIGH);
    }

Some one suggested it might be signal bounce on the SPI and the clock rate was set to 500kHz but it didn't work.
Update:
Not long ago, the correct device ID would be read consistently (173 for 0xAD); now that returns 0. The temperature would either return 0 from the register or changing values between -1 and -5 that may have been wrongly calibrated temperature. But sometimes the correct temperature would return. Now it also only returns 0 from the registers.

user31812: Per your post looks like you have not wired any grounds. Consider wiring Analog and Digital grounds.

Here are excerpts from the datasheet


user70119: This is a poor product, look at this: that describes exactly the problems you (and me) are experiencing. Correct me if you've found any solutions so far.
edit
Try looking at description of regster 0x2f in datasheet and to this question.
I think that the first problem you describe can be solved this way, the second behaviour sounds like you fried the device.

28629: <p>I am trying to connect an <a href="http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL354_355.pdf" rel="nofollow noreferrer">ADXL355</a> digital sensor to an Arduino. The wiring and the code I think are OK because the system returns the correct values sometimes and partly correct answers mostly. The code checks the device register, and the correct data is printed to serial most of the time. The code also checks for temperature but only returns the correct value occasionally. The values are polled every few seconds. The values are correct all of the time if they are correct the first time after restart but never if they are incorrect on restart. I thought it might help to unplug the sensor when uploading the program or powering up the Arduino through USB to the computer but there is no clear pattern.</p>

<p>It is not a defective sensor because I have 2 that behave the same way. What could be the problem? Is this a problem with the Arduino? </p>

<p><a href="https://i.stack.imgur.com/0gpi1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0gpi1.png" alt="enter image description here"></a></p>

<p>I only wire VDD, VDDIO, ground,chip select, sclk, MOSI and MISO.</p>

<p>code:</p>

<pre><code>#include &lt;SPI.h&gt;

    const int ID = 0x00;
    const int FIFO = 0x11;
    const int TEMP = 0x06;
    const int TEMP1 = 0x07;
    const byte FIFO_WATERMARK = 0x29;
    const int chipSelectPin = 7;


    void setup() {
        Serial.begin(9600);

        SPI.begin();

        pinMode(dataReadyPin, INPUT);
        pinMode(chipSelectPin, OUTPUT);

        // writing 0 to to enable sensor
        writeRegister(0x2D, 0x00);

        delay(100);

        Serial.println(readRegister(ID));
        Serial.println(readRegister(FIFO_WATERMARK));
    }

    void loop() {
        int temp = (readRegister(TEMP)); // &lt;&lt; 8) | (readRegister(TEMP1))) ;
        temp = (temp&lt;&lt;8)|(readRegister(TEMP1));
        Serial.println(((1852 - temp)/9.05) + 19.21);
        Serial.println(readRegister(ID));

        delay(1000);
    }

    byte readRegister (byte thisRegister){
        byte inByte = 0 ;
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer((thisRegister &lt;&lt; 1) | 1);
        inByte = SPI.transfer(0x00);
        digitalWrite(chipSelectPin, HIGH);
        return inByte;
    }
    void writeRegister (byte thisRegister, byte value){
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer(thisRegister &lt;&lt; 1);
        SPI.transfer(value);
        digitalWrite(chipSelectPin, HIGH);
    }
</code></pre>

<p>Some one suggested it might be signal bounce on the SPI and the clock rate was set to 500kHz but it didn't work.</p>

<p>Update:<br>
Not long ago, the correct device ID would be read consistently (173 for 0xAD); now that returns 0. The temperature would either return 0 from the register or changing values between -1 and -5 that may have been wrongly calibrated temperature. But sometimes the correct temperature would return. Now it also only returns 0 from the registers.</p>
 31812: <p>Per your post looks like you have not wired any grounds. Consider wiring Analog and Digital grounds.</p>

<p><a href="https://i.stack.imgur.com/1HIg7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1HIg7.jpg" alt="ADXL355 Grounds"></a></p>

<p>Here are excerpts from the datasheet</p>

<p><a href="https://i.stack.imgur.com/u8I6n.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u8I6n.jpg" alt="ADXL355 Ground Pins"></a></p>
 70119: <p>This is a poor product, look at <a href="https://ez.analog.com/mems/f/q-a/109925/adxl355-latch-up-condition" rel="nofollow noreferrer">this</a>: that describes exactly the problems you (and me) are experiencing. Correct me if you've found any solutions so far.</p>
<h2>edit</h2>
<p>Try looking at description of regster 0x2f in datasheet and to <a href="https://electronics.stackexchange.com/questions/532331/why-is-the-only-way-to-make-this-device-work-to-manually-unplug-and-re-plug-the/532373#532373">this question</a>.<br />
I think that the first problem you describe can be solved this way, the second behaviour sounds like you fried the device.</p>
