Using LM70 temperature sensor with Arduino

Hello guys,

I am trying to sense the temperature using the LM70 temperature sensor with an Arduino Mega. As you can see in the Datasheet, it uses the SPI protocol. I have made the following connections (VSSOP-8 Package):

  • SI/O pin --> Pin 50 Arduino Mega.
  • SC pin --> Pin 52 Arduino Mega.
  • CS pin --> Pin 53 Arduino Mega.
  • V+ pin --> 3.3V Arduino Mega.
  • GND pin --> GND Arduino Mega.

My code does not work (it does not print the right temperature), and I think it can be for two reasons:

  1. I am not reading correctly the information from the sensor. It sends 16 bits, from which the 11 first bits store the data for the temperature.
  2. I am not calculating the temperature in the right way.

This is my code:

// the sensor communicates using SPI, so include the library:
#include <SPI.h>

void setup() {
  pinMode(51,OUTPUT); //MOSI
  pinMode(50,INPUT); //MISO
  pinMode(52,OUTPUT); //CLOCK PIN
  digitalWrite(53,HIGH); //slave select stays high. When we set this to low, the sensor will start to send data.
  SPI.begin();
  Serial.begin(9600);

  //time to set up
  delay(500);
}

void loop() {
    //enable Slave
    digitalWrite(A0,LOW); //Enable communication with slave
    delay(500); //wait for conversion
    
    int val = SPI.transfer(0x00); // read from sensor
    Serial.println(val); //display reading on serial monitor
    int temperature = val * 0.25;
    Serial.println(temperature); //display temperature on serial monitor


    //disable Slave
    digitalWrite(53,HIGH); //set to High again
}

Please, if you see something wrong in my code, let me know.
Thank you in advance.

lm70.pdf (1.2 MB)

    //enable Slave

digitalWrite(A0,LOW); //Enable communication with slave
    //disable Slave
    digitalWrite(53,HIGH); //set to High again

?

Thank you for your answer! you are right, there it should be pin 53, not A0.

//enable Slave
digitalWrite(53,LOW); //Enable communication with slave
//disable Slave
digitalWrite(53,HIGH); //set to High again

I thought this would solve the problem but it doesnt. Any ideas?