Raspberry Pi - AD7416ARZ 10-Bit Temperature Sensor Java Tutorial

by Dcube Tech Ventures in Circuits > Electronics

33 Views, 0 Favorites, 0 Comments

Raspberry Pi - AD7416ARZ 10-Bit Temperature Sensor Java Tutorial

Raspberry Pi - AD7416ARZ 10-Bit Temperature Sensor Java Tutorial

AD7416ARZ is 10-Bit temperature sensor with four single channel analog to digital convertors and an on board temperature sensor incorporated in it. The temperature sensor on the parts can be accessed via multiplexer channels. This high-accuracy temperature sensor has become an industry standard in terms of form, factor and intelligence, providing calibrated, linearized sensor signals in digital, I2C format. Here is the demonstration with a Java code using Raspberry Pi.

What You Need..!!

AD7416ARZ_I2CS_A_1.png
pi.jpg

Connections:

AD7416ARZ_I2CS_A_1.png
pi.jpg
sensor.jpg
complete_connection.jpg

Take a I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.

Then connect the one end of I2C cable to AD7416ARZ sensor and the other end to the I2C shield.

Also connect the Ethernet cable to the pi or you can use a WiFi module.

Connections are shown in the picture above.

Code:

complete_connection.jpg

The Java code for AD7416ARZ can be downloaded from our GitHub repository- Dcube Store.

Here is the link for the same :

https://github.com/DcubeTechVentures/AD7416ARZ/blob/master/Java/AD7416ARZ.java

We have used pi4j library for java code, the steps to install pi4j on raspberry pi is described here:

http://pi4j.com/install.html

You can also copy the code from here, it is given as follows:

// Distributed with a free-will license.

// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

// AD7416ARZ

// This code is designed to work with the AD7416ARZ_I2CS I2C Mini Module available in Dcube Store.

import com.pi4j.io.i2c.I2CBus;

import com.pi4j.io.i2c.I2CDevice;

import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class AD7416ARZ

{

public static void main(String args[]) throws Exception

{

// Create I2C bus

I2CBus Bus = I2CFactory.getInstance(I2CBus.BUS_1);

// Get I2C device, AD7416ARZ I2C address is 0x48(72)

I2CDevice device = Bus.getDevice(0x48);

// Read 2 bytes of data from address 0x00(00)

// temp msb, temp lsb

byte[] data = new byte[2];

device.read(0x00, data, 0, 2);

// Convert the data to 10-bits

int temp = (((data[0] & 0xFF) * 256) + (data[1] & 0xC0)) / 64;

if(temp > 511)

{

temp -= 1024;

}

double cTemp = temp * 0.25;

double fTemp = cTemp * 1.8 + 32;

// Output data to screen

System.out.printf("Temperature in Celsius : %.2f C %n", cTemp);

System.out.printf("Temperature in Fahrenheit : %.2f F %n", fTemp);

}

}

Applications:

AD7416ARZ is a 10-Bit Temperature sensor with four single channel analog to digital converter can perform the operation of Data acquisition with ambient temperature monitoring. It can also be employed in Industrial process control systems, Automotive Battery-charging applications and Personal computers.