Need help porting OneWire to RedBearLab nRF51822

Hello!

I'm using the RedBearLab nRF51822 (http://redbearlab.com/redbearlab-nrf51822/) board and want to use a DS1820 sensor.
The problem is, that OneWire does not support the mentioned board. I tried to figure out how to properly configure the PIN stuff. But not successful since I'm not familiar with the PIN setup and the board itself.

I asked for help in the official forum (https://redbearlab.zendesk.com/entries/83049019-Support-for-OneWire-I-O-register-types-needed-) but without any (official) reply. The creator of OneWire says "it's almost certainly possible" (Support for RedBearLab nRF51822 · Issue #3 · PaulStoffregen/OneWire · GitHub).

Any help is highly appreciated! Thank you!

@stefal

Seems like it would be "easier" to continue to ask on the forum for that board. What type of help do you want? What is it that does not work?

One-wire is not that difficult to implement :slight_smile:

Cheers!

Since I'm no expert and pretty new to Arduino its hard to explain. The OneWire library implements the protocol, thanks to that no further implementation to be done (hopefully).

The problem is that this OneWire library needs the PINs setup correctly to work properly. This can be found in OneWire.h starting at line 53:

// Platform specific I/O definitions

#if defined(__AVR__)
#define PIN_TO_BASEREG(pin)             (portInputRegister(digitalPinToPort(pin)))
#define PIN_TO_BITMASK(pin)             (digitalPinToBitMask(pin))
#define IO_REG_TYPE uint8_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))

#elif ...

Where this code is platform specific and needs to be adapted for the RedBearLab board. The library offers an fallback mode (line 118 which seems not to be working (tried it with the temperature example, ds.search() does not complete!?)

So I need to setup the above code correctly, but I do not know how :frowning: Implementing the protocol on my own seems to be reinventing the wheel (because of the existence of this library).

Hopefully I could explain my "problem" in more detail!

Cheers, thank you :slight_smile:

I'm one step closer: OneWire on RedBearLab nRF51822 - Nordic Q&A - Nordic DevZone - Nordic DevZone

Everything compiles fine and now I'm getting the message "No more addresses." No glue what that means for now ... :frowning:

That means the library did not detect any 1-wire devices.

Have you connected some 1-wire devices, 4.7K pullup, etc.? If you read this, you know you should include a description of everything, including the wiring.