3-Wire Serial SPI Temperature Sensor (MAX6629) with an Arduino Uno

Hi,

I have brought an MAX6629 SPI sensor found here:

I have hooked up VCC, GND, MISO (Arduino) to SO (MAX6629), Pin 10 (Arduino) to CS, and SCK.

The code I have uploaded to the Arduino Uno is shown below. However I am not getting anything out? If you take a look at the datasheet, you can see the 16 bits used, is my code reading it right?

#include <SPI.h>

double readCelsius(uint8_t cs) {
    uint16_t v;

    digitalWrite(cs, LOW);
    v = SPI.transfer(0x00);
    v <<= 8;
    v |= SPI.transfer(0x00);
    digitalWrite(cs, HIGH);

    if (v & 0x4) {
        return NAN; 
    }

    v >>= 3;

    return v*0.25;
}

void setup() {
    SPI.begin();
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    Serial.begin(115200);
}

void loop() {
    Serial.print(readCelcius(10));
    Serial.print(" ");
    delay(1000);
}

Thanks!

I have hooked up VCC, GND, MISO (Arduino) to SO (MAX6629), Pin 10 (Arduino) to CS, and SCK.

Just to clarify: SCK means pin 13 on the Arduino side, doesn't it?

However I am not getting anything out?

Does that mean you get nothing or do you get 0 as output?

If you take a look at the datasheet, you can see the 16 bits used, is my code reading it right?

With the exception that you use an unsigned integer instead of a signed one the code looks OK.

pylon:
Just to clarify: SCK means pin 13 on the Arduino side, doesn't it?

Does that mean you get nothing or do you get 0 as output?

With the exception that you use an unsigned integer instead of a signed one the code looks OK.

Yes it is pin 13. I get nothing in the output.

That's weird then, I don't see what's wrong..

Do you have your Serial Monitor configured for 115200 baud?

If you have, upload a simple sketch to check the serial connectivity. You should at least see some numbers.