chipKIT® Development Platform

Inspired by Arduino™

OneWire Library

Created Tue, 05 Jul 2011 19:28:56 +0000 by dangeljs


Tue, 05 Jul 2011 19:28:56 +0000

I've ported the OneWire Library to read the temperature from a ds18s20 using an Uno32. I used #ifdefs to allow the code to go between an arduino and chipKit, but I don't have an arduino to ensure I didn't change the library so much that it doesn't work on an arduino. Is there a place to share and/or post the library? I don't see a way of attaching it with this post.




Fri, 08 Jul 2011 14:54:01 +0000

I don't know if I didn't see this attachment section below before or if it is new, but here is the modified code for those who are interested. I modified the code from: which I was directed to via the website (after a google search). It is labeled as the 2.0 version on


Sat, 09 Jul 2011 15:41:54 +0000

Use the above library in conjuntion with Miles Burtons temperature library and both the 18s and 18b versions of dallas temperature sensors can be used. See this page:

There are examples of usage in the Miles' library.


Tue, 26 Jul 2011 18:54:37 +0000


I was curious if you were interested in posting your library because there is a location on github specifically for third party libraries? If you are interested tell me and I will make sure that it gets posted.



Tue, 26 Jul 2011 20:40:44 +0000

I don't have any problem with that, I consider it the communities code. I just modified it so that I could use it.


Sat, 29 Oct 2011 16:13:42 +0000

Hi, Paul here - the maintainer of the OneWire library.

I'm planning to release version 2.1, with built-in support for chipKit.

If you see this message before Oct 31, 2011, and you have a few minutes to compile and run this code on a chipKit with DS18S20 or similar one wire devices, please contact me directly: paul at pjrc (anti-spam features won't let me give you an email as my first post here... I'm sure you can find my address). I will send you a pre-release copy.

I hacked up the above code quite a bit, into a set of hardware abstraction macros in one place in the header file. I do not have a chipKit, so if you can spend even a few minutes verifying the code compiles for chipKit, it will really help.

Thanks. :-)


Thu, 03 Nov 2011 22:44:33 +0000

The latest library (v2.1) can be found at:

Also attached here on this post.

This version will work with both Arduino and Chipkit boards.


Thu, 26 Jan 2012 23:16:42 +0000

Hi then i trying connect OneWire library i have error message what i can do with that?

file included from /Applications/, from /Applications/, from /Applications/, from sketch_jan27a.cpp:1: /Applications/ error: expected identifier before numeric constant /Applications/ error: expected '}' before numeric constant /Applications/ error: expected unqualified-id before numeric constant /Applications/ error: 'BOOL' does not name a type /Applications/ error: expected unqualified-id before numeric constant /Applications/ error: expected unqualified-id before numeric constant /Applications/ error: expected unqualified-id before numeric constant /Applications/


Wed, 11 Jul 2012 02:33:05 +0000

I am getting the exact same error as the above poster is receiving trying to use the One Wire library. I even tried different code that I have been using on my Arduino Mega for months now and it will not work at all. Don't know what is going on with this, if anyone knows anything about this issue any help would be greatly appreciated. Other than the One Wire library, I am enjoying the chipKit a whole lot. Thanks everybody!


Thu, 12 Jul 2012 03:12:30 +0000

What version of MPIDE are you using? This library was ported over a year ago and I think there may be problems with including <PLIB.H> or not including. I haven't used it in a while so I'm not sure what the issues may be, and I'm really busy right now. If I find some time I'll get back, but you may want to play around with either adding the PLIB.H or removing it from the header file and see if that fixes the errors.


Thu, 02 Aug 2012 20:55:30 +0000

I'm using the latest version 023 I believe it is. I will try your suggestion and get back with everyone and let you know what I find. I've worked with them forever on my Arduino, however I am having a little trouble getting them to work on the MAX32


Thu, 17 Jan 2013 23:58:50 +0000

I'm about to publish OneWire version 2.2. Here's a preview copy.

Would anyone like to test this with the latest ChipKit boards? If anything needs to be changed, please let me know ASAP?!

I tend to release OneWire about once a year, so if anything is needed for ChipKit or Digilent boards, now's the time to get a patch in.....


Tue, 29 Jan 2013 21:53:04 +0000


Just tested this library and it works on my Uno32 board with the DS18S20 sensor. The only thing I see is that the temperature is off by 1,6-1,7 degrees celsius in air on average between 10 new sensors. It shows 1.6-1.7 higher than real temp. (24.6 real and 26.3 on the sensor) I have not tested it in fluids yet. I am using the example code provided with the onewire library.

I connected three and three sensors on the bus on a breadboard with a 4.7Kohm pullup as adviced in the example. I get the same result with only one sensor connected also. Is there any calculations in the library, or is the value coming directly from the sensor without any calculations needed?

This was a really great find. I have just bought the Uno32 board and is exploring the vast world of microchip programming :) Thank you for this library as the old one did not work...