In my Previous Post , I have shared interfacing of ADXL375 High g Accelerometer with CC3200 LaunchPad.
In this post, I am sharing Interfacing of ADT7320 Temperature sensor with CC3200 LaunchPad and Body temperature measurement with ADT7320.
ADT7320 is High resolution Temperature sensor (Resolution 0.0625°C/LSB in 13bit and 0.0078°C/LSB in 16bit mode). Maximum Temperature measurement range is −20°C to +105°C. As Eval-ADT7320FBZ is flex module it is very much suitable for body temperature measurement (It provides maximum contact surface with body and excellent heat transfer).
Color code for ADT7320 wiring is as below...
ADT7320 supports 4-Wire SPI communication protocol in SPI Mode3 (Clock Priority = 1 and Clock Phase = 1)
By default ADT7320 is in continuous operation mode with 13 bit resolution. Reading Temperature Value Register (0x02 address and 16bit) gives bit15(MSB) to bit4(LSB) with -ve temperature in 2's complement format.
to get final result of temperature the received value need to divide by 8. and with 13 bit mode resolution is 0.0625 C/LSB.. Final equation of temperature in C is....
Temp in C = Received Value of temp Value*0.0625/8
As Read command Byte for ADT7320 is following with R/W' = 1..
So, to read 0x02 address (Temperature Value Register of 16 bit) with Read command, SPI read request byte is 0x50..
and after that for read receiving two bytes from ADT7320 two time 0xFF need to be written on bus.. Here first MSB and Last LSB sequence need to be used.
for reference SPI read waveform from ADT7320 Datasheet is as below..
Test Setup..
After considering all above points.. The code for energia to interface ADT7320 with CC3200 LaunchPad is as below.. The some code works just fine with Arduino too..
Note: I have used default configuration but You can use write command to change ADT7320 Configuration (i.e. to change resolution, set temp comperator interrupt, shutdown device etc...)
//ADT7320 Interfacing with CC3200 LaunchPAD (Rev 0) // Released under CC-SA Creative commons Share Alike Licence // by ravi Butani #include <SPI.h> const int chipSelectPin = 18; void setup() { Serial.begin(9600); SPI.setDataMode(SPI_MODE3);// ADT7320 Supports only MODE3 SPI // start the SPI library: SPI.begin(); // initalize the data ready and chip select pins: pinMode(chipSelectPin, OUTPUT); delay(100); } void loop() { //Read the temperature data int tempData = readRegister(0x50, 2); // 0x50 is read commad for 0x02 register tempData = tempData/8;// MSB bit15 and LSB bit4 so received value need to be divide/8 // convert the temperature to celsius and display it: float realTemp = (float)tempData * 0.0625; Serial.print("Temp[C]="); Serial.print(realTemp); Serial.print("\tRXdata>>3="); Serial.println(tempData); delay(500); } //Read from register from the ADT7320: unsigned int readRegister(byte thisRegister, int bytesToRead ) { byte inByte = 0; // incoming byte from the SPI unsigned int result = 0; // result to return // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); // send the device the register you want to read: SPI.transfer(thisRegister); // send a value of 0 to read the first byte returned: result = SPI.transfer(0xFF); // decrement the number of bytes left to read: bytesToRead--; // if you still have another byte to read: if (bytesToRead > 0) { // shift the first byte left, then get the second byte: result = result << 8; inByte = SPI.transfer(0xFF); // combine the byte you just got with the previous one: result = result | inByte; // decrement the number of bytes left to read: bytesToRead--; } // take the chip select high to de-select: digitalWrite(chipSelectPin, HIGH); // return the result: return(result); } //Sends a write command to ADT7320 void writeRegister(byte thisRegister, byte thisValue) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); SPI.transfer(thisRegister); //Send register location SPI.transfer(thisValue); //Send value to record into register // take the chip select high to de-select: digitalWrite(chipSelectPin, HIGH); }
Here is Demo Video....
Reference :
http://energia.nu/wordpress/wp-content/uploads/2014/09/cc3200lppinmap.jpg
http://www.analog.com/media/en/technical-documentation/data-sheets/ADT7320.pdf
http://www.analog.com/media/en/technical-documentation/evaluation-documentation/UG-138.pdf