Arduino 1-Wire Device Libraries

DS2438 Example Code - Temperature and Voltages

This example demonstrates the use of this library to to read temperature and raw voltages for both channels, printing the values to the serial port.

// Copyright 2013, - All Rights Reserved
#include <Arduino.h>
#include <OneWire.h>
#include <DS2438.h>

// define the Arduino digital I/O pin to be used for the 1-Wire network here
const uint8_t ONE_WIRE_PIN = 2;

// define the 1-Wire address of the DS2423 counter here (lsb first)
uint8_t DS2438_address[] = { 0x26, 0x4e, 0xe6, 0x37, 0x00, 0x00, 0x00, 0x4e };

OneWire ow(ONE_WIRE_PIN);
DS2438 ds2438(&ow, DS2438_address);

void setup() {

void loop() {
    if (ds2438.isError()) {
        Serial.println("Error reading from DS2438 device");
    } else {
        Serial.print("Temperature = ");
        Serial.print(ds2438.getTemperature(), 1);
        Serial.print("C, Channel A = ");
        Serial.print(ds2438.getVoltage(DS2438_CHA), 1);
        Serial.print("v, Channel B = ");
        Serial.print(ds2438.getVoltage(DS2438_CHB), 1);

<<Previous Page | Index | Next Page>>