Possibility of OneWire.h Library

Is it possible to implement OneWire.h Library? I am using it for temperature sensing using DS18B20. it requires, 1-Wire digital temperature sensor from Maxim IC.

You can get the source at:

http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip


I have tried implementing but I get error in Line 108 of OneWire.h

  • By adding belows description, I could compile this library. But I have not tried the operation. Can you try that?

    #elif defined(GRPEACH)

    #define PIN_TO_BASEREG(pin)             (portInputRegister(digitalPinToPort(pin)))

    #define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))

    #define IO_REG_TYPE uint16_t

    #define IO_REG_ASM asm("r30")

    #define DIRECT_READ(base, mask)         (((*(base)) & (mask)) ? 1 : 0)

    #define DIRECT_MODE_INPUT(base, mask)   ((*((base)+1)) &= ~(mask))

    #define DIRECT_MODE_OUTPUT(base, mask)  ((*((base)+1)) |= (mask))

    #define DIRECT_WRITE_LOW(base, mask)    ((*((base)+2)) &= ~(mask))

    #define DIRECT_WRITE_HIGH(base, mask)   ((*((base)+2)) |= (mask))

  • In reply to Okamiya Yuuki:

    Hello Yuuki,

    Thanks for the reply. I have added the code that you suggested. I took the prgram from the examples folder. Copied the DallasTemperature folder. I changed the files as mentioned in forum.arduino.cc/index.php

    I am still getting the following error:

    /RZA1H_RTC_private.o gr_common/core/Ethernet.o gr_common/core/IPAddress.o gr_common/lib/Servo/Servo.o gr_sketch.o DallasTemperature/DallasTemperature.o peach_advanced_lib/peach_advanced_lib.a mbed-lib/mbed-lib.a -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys

    gr_sketch.o: In function `_GLOBAL__sub_I_ds':

    /gr_sketch.cpp:11: undefined reference to `OneWire::OneWire(unsigned char)'

    gr_sketch.o: In function `loop':

    /gr_sketch.cpp:25: undefined reference to `OneWire::search(unsigned char*)'

    /gr_sketch.cpp:28: undefined reference to `OneWire::reset_search()'

    /gr_sketch.cpp:39: undefined reference to `OneWire::crc8(unsigned char const*, unsigned char)'

    /gr_sketch.cpp:64: undefined reference to `OneWire::reset()'

    /gr_sketch.cpp:65: undefined reference to `OneWire::select(unsigned char const*)'

    /gr_sketch.cpp:66: undefined reference to `OneWire::write(unsigned char, unsigned char)'

    /gr_sketch.cpp:71: undefined reference to `OneWire::reset()'

    /gr_sketch.cpp:72: undefined reference to `OneWire::select(unsigned char const*)'

    /gr_sketch.cpp:73: undefined reference to `OneWire::write(unsigned char, unsigned char)'

    /gr_sketch.cpp:79: undefined reference to `OneWire::read()'

    /gr_sketch.cpp:84: undefined reference to `OneWire::crc8(unsigned char const*, unsigned char)'

    collect2.exe: error: ld returned 1 exit status

    make: *** [gr_build/peach_sketch.elf] Error 1

    Thanks for your help.....