Arduino with ADS1115 4-Channel 16-bit Analog-to-Digital Converter

Arduino uses ADS1115 to Measure Temperature

by Lewis Loflin

  
  

This project build on earlier Arduino projects. The TMP37 is an analog Centigrade temperature sensor whose output is proportional to temperature. Instead of connection to the Arduino analog-to-digital connection we use the ADS1115 channel A0 for 15-bit resolution versus 10-bit with a direct Arduino connection. This gives use almost 40 times the resolution and higher accuracy.

The temperature in Centigrade and Fahrenheit is displayed on the Arduino serial monitor.

The TMP37 is intended for applications over the range of 5 degrees C to 100 degrees C and provides an output scale factor of 20 mV per degrees C. The TMP37 provides a 500 mV output at 25 degrees C. Operation extends to 150 degrees C with reduced accuracy for all devices when operating from a 5 V supply.

The supply current runs well below 50 uA, providing very low self-heating-less than 0.1 degrees C in still air. In addition, a shutdown function is provided to cut the supply current to less than 0.5 uA. For more information on the TMP37 download the specification sheet. (pdf format)



Older version of this page see Arduino TMP37 Centigrade Temperature Sensor Tutorial.

Explanation of the Arduino and the ADS1115 see Programming ADS1115 4-Channel I2C ADC with Arduino.

Arduino sketch for this project: ads1115_temp_sensor.ino


/*
Read TMP37 temp sensor on A0 ADS1115 15-bit
ADC then displays temperature in C and F
on Arduino serial monitor.

By Lewis Loflin lewis@bvu.net
http://www.sullivan-county.com/main.htm
Electronics website:
http://www.bristolwatch.com/index.htm
*/

#include <Wire.h> // specify use of Wire.h library
#define  ASD1115  0x48

unsigned int val = 0;

byte writeBuf[3];
byte buffer[3];

float myfloat;
const float VPS = 4.096 / 32768.0; // volts per step

void setup()   {

  Serial.begin(9600);
  Wire.begin(); // begin I2C


  // ASD1115
  // set config register and start conversion
  // AIN0 and GND, 4.096v, 128s/s
  // Refer to page 19 area of spec sheet
  writeBuf[0] = 1; // config register is 1
  writeBuf[1] = 0b11000010; // 0xC2 single shot off
  // bit 15 flag bit for single shot not used here
  // Bits 14-12 input selection:
  // 100 ANC0; 101 ANC1; 110 ANC2; 111 ANC3
  // Bits 11-9 Amp gain. Default to 010 here 001 P19
  // Bit 8 Operational mode of the ADS1115.
  // 0 : Continuous conversion mode
  // 1 : Power-down single-shot mode (default)

  writeBuf[2] = 0b10000101; // bits 7-0  0x85
  // Bits 7-5 data rate default to 100 for 128SPS
  // Bits 4-0  comparator functions see spec sheet.

  // setup ADS1115
  Wire.beginTransmission(ASD1115);  // ADC
  Wire.write(writeBuf[0]);
  Wire.write(writeBuf[1]);
  Wire.write(writeBuf[2]);
  Wire.endTransmission();
  delay(500);

}  // end setup

void loop() {

  buffer[0] = 0; // pointer
  Wire.beginTransmission(ASD1115);  // DAC
  Wire.write(buffer[0]);  // pointer
  Wire.endTransmission();

  Wire.requestFrom(ASD1115, 2);
  buffer[1] = Wire.read();  //
  buffer[2] = Wire.read();  //
  Wire.endTransmission();

  // convert display results
  val = buffer[1] << 8 | buffer[2];

  if (val > 32768) val = 0;

  myfloat = val * VPS; // convert to voltage

  Serial.print("Sensor voltage = ");
  Serial.println(myfloat);

  Serial.print("Temp C = ");
  Serial.println(myfloat / 0.02);

  Serial.print("Temp F = ");
  Serial.println((myfloat / 0.02 ) * 9 / 5 + 32);
  
  delay(500);

} // end loop

For earlier Arduino Projects see Arduino Projects Hobby Projects Tutorials

Videos:
My YouTube Videos on Electronics
Introduction to the Arduino Microcontroller
Part 1: Programming Arduino Output
Part 2: Programming Arduino Input
Part 3: Arduino Analog to Digital Conversion
Part 4: Using Arduino Pulse-Width-Modulation
Repost Arduino AC Power Control

arduino

See How I got into Electronics

New May 1, 2016:

I'd say my job title would be applied technologist. See Electronics Projects for Students and Hobbyists

Recent YouTube Videos: