trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

DS18B20 Temperature Sensor / 1-Wire on Windows 10

Fri May 08, 2015 1:21 am

Has anybody looked in to getting 1-wire devices working on Windows 10 yet? I'm interested in using DS18B20 temperature sensors, but have no idea how to get 1-wire working in Windows 10 for the Pi, or if it's even supported in this early preview build.

Thanks

jtanner_msft
Posts: 105
Joined: Fri May 01, 2015 7:12 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Sat May 09, 2015 12:04 am

This is a two wire example using GPIO but maybe it'll show you an approach you could use:
http://ms-iot.github.io/content/win10/s ... Blinky.htm
Jonathan Tanner | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

User avatar
AES256
Posts: 6
Joined: Sun May 03, 2015 10:37 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Sat May 09, 2015 12:53 pm

I'm also interested in using DS18B20.

jtanner_msft: your example is good for devices like an LED which requires to set the GPIO pin to low or high or like a tacticle button when you want to read high or low current on the pin.
However, when you read the DS18B20 sensor it will send a 9/12 bit number back to the pin.
It is using the so called 1-wire protocol. The protocol is implemented for example in Raspbian (built into the kernel).
I'm not sure if it was implemented in Windows 10 yet.

Has anybody found anything about 1-wire in Windows 10?

Thanks
Peter

jtanner_msft
Posts: 105
Joined: Fri May 01, 2015 7:12 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Mon May 11, 2015 10:49 pm

I don't believe that the Rpi2 has the hardware present to properly support 1-Wire connections. I am checking on this though and realize that you might be able to mimic support via software. As to if it'll be present in Windows 10 Iot Core I'm not sure at this time. If I learn anything I will let you know.
Jonathan Tanner | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Mon May 11, 2015 11:36 pm

jtanner_msft wrote:I don't believe that the Rpi2 has the hardware present to properly support 1-Wire connections. I am checking on this though and realize that you might be able to mimic support via software. As to if it'll be present in Windows 10 Iot Core I'm not sure at this time. If I learn anything I will let you know.
One-wire devices work well on the RPi and RPi2. There are several ways to interface the hardware, all are supported in Raspbian (and other Linux variants). There's even source code for how to do it if you guys are stuck.

markrad_msft
Posts: 58
Joined: Thu May 07, 2015 7:46 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 1:29 am

As I understand, the RPi does not directly support 1-Wire but instead Raspbian uses a GPIO pin to communicate with 1-Wire devices and a technique called bit banging. Presumably one could duplicate that functionality on Win 10. Alternatively one could possibly use a DS2482 which is a I2C/1-Wire bridge. I have not tried this.
Mark Radbourne | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 4:03 am

markrad_msft wrote:As I understand, the RPi does not directly support 1-Wire but instead Raspbian uses a GPIO pin to communicate with 1-Wire devices and a technique called bit banging. Presumably one could duplicate that functionality on Win 10. Alternatively one could possibly use a DS2482 which is a I2C/1-Wire bridge. I have not tried this.
You can use bit-banging on a GPIO pin, or an I2C interface, or a USB interface, or a serial port. All are supported in Raspbian, but not in winiot. Please do not try to cloud the issue.

trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 5:19 am

ame wrote:You can use bit-banging on a GPIO pin, or an I2C interface, or a USB interface, or a serial port. All are supported in Raspbian, but not in winiot. Please do not try to cloud the issue.
I'm assuming the intention of the previous reply was that we will need to write our own 1-wire protocol implementation in software (bit-banging) which is exactly what the Raspbian distro has implemented within the kernel - not an attempt to "cloud the issue". Someone had to write the Raspbian implementation - it didn't just magically appear. At this point the implementation doesn't exist in Winiot, whether it will be implemented by Microsoft is unknown.

It would only be a matter of obtaining the specifications of the 1-wire protocol and writing some code to send / receive data in the correct sequence to/from the pin on the GPIO and manipulate it accordingly.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 5:24 am

trashcoder wrote:
ame wrote:You can use bit-banging on a GPIO pin, or an I2C interface, or a USB interface, or a serial port. All are supported in Raspbian, but not in winiot. Please do not try to cloud the issue.
I'm assuming the intention of the previous reply was that we will need to write our own 1-wire protocol implementation in software (bit-banging) which is exactly what the Raspbian distro has implemented within the kernel - not an attempt to "cloud the issue". Someone had to write the Raspbian implementation - it didn't just magically appear. At this point the implementation doesn't exist in Winiot, .

It would only be a matter of obtaining the specifications of the 1-wire protocol and writing some code to send / receive data in the correct sequence to/from the pin on the GPIO and manipulate it accordingly.
Using such weasel-words as "the RPi does not directly support 1-Wire" is clouding the issue.

The point is, you can use RPi to communicate with 1-wire devices right now. However, as you say, whether it will be implemented by Microsoft is unknown.

trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 5:27 am

Found this library for Arduino that might be able to be ported to c# for winiot.

http://www.pjrc.com/teensy/td_libs_OneWire.html

trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 5:36 am

ame wrote:Using such weasel-words as "the RPi does not directly support 1-Wire" is clouding the issue.
The RPi doesn't "natively" support 1-wire. There is a software implementation of the protocol for one (possibly more) operating systems that run on the RPi.

Winiot on the RPi is currently a technical preview, not a final release. At this point it is not going to be on-par feature-wise with other operating systems that have been in development for the platform for many years.

I started this thread to get info on implementing the 1-wire interface for Winiot, not discuss that fact that it is available on other OS's.

markrad_msft
Posts: 58
Joined: Thu May 07, 2015 7:46 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 7:10 pm

trashcoder wrote:Found this library for Arduino that might be able to be ported to c# for winiot.

http://www.pjrc.com/teensy/td_libs_OneWire.html
That's great. I did start to look for an implementation myself but you beat me to it. I took a look at the code. I only gave it a cursory glance so far but I didn't see anything that would prevent one converting it for WinIoT. However I would likely choose to port it to C++ on WinIoT and provide a C# wrapper. I will try and look at this in more detail later. I should note though that if I did some work on this it would be for my personal interest (I also happen to have a DS18B20 at home that I wanted to hook to my RPi). This wouldn't be MSFT sanctioned code.
Mark Radbourne | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue May 12, 2015 10:23 pm

markrad_msft wrote:However I would likely choose to port it to C++ on WinIoT and provide a C# wrapper.
That's great! My C++ skills lie somwhere between non-existent and not very good so I was just going to try a C# port but your plan sounds much better.

I look forward to seeing what you can come up with.

chrisfaig
Posts: 1
Joined: Wed May 27, 2015 8:26 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Wed May 27, 2015 8:31 am

I did a workaround to use protocols that are not implemented yet. You can get a arduino talking 1wire with the sensor, and the arduino talking i2c with Windows iot. Give a look : https://www.hackster.io/phantom_overrid ... spi-2-wiot. Hope it may help you

Regards

Chris

juanpaexpedite
Posts: 15
Joined: Fri May 15, 2015 10:27 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Wed May 27, 2015 5:41 pm

I experimented and done by myself, take a look to my post http://expediteapps.com/blog/temperatur ... with-rpi2/, I had to make several trials and errors until I did it. I use a thermistor and it is not exactly one wire because I had many input errors on reading the values, but with two I think you can try.

stefanheesch
Posts: 1
Joined: Wed May 27, 2015 10:15 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Wed May 27, 2015 10:33 pm

Two days ago I created a small I2C-1Wire Bridge for connecting a 1Wire device to the I2C bus. Since I want to build a brewing Controller and have a thermometer with a DS1821 chip, I implemented the Bridge for that sensor. The source code is available on Github https://github.com/hb9tws/OneWireBridge. The Bridge runs on an AVR ATTiny45 Controller: http://www.radio.cc/post/source-code-fo ... -on-github

You Need a Bascom AVR Compiler and the I2C Slave library from MCS Electronics to compile the source code. You may use it for personal Project. it is licensed for non Commercial use.

adambarath
Posts: 2
Joined: Fri Jun 05, 2015 6:13 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Fri Jun 05, 2015 6:37 am

May I help developing the C# wrapper or something like bit banging protocol? I'm interested in DS18B20 too, but I have problems with timing (I guess...). (The sensor is in parasite mode.) Does anybody know how to resolve timing problem? Sensor needs to recive reset command for 480ns.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Fri Jun 05, 2015 9:17 am

If you can read/write a UART (either on-board*, or a USB serial adapter) you can use it to fake up the one-wire timing:
http://www.maximintegrated.com/en/app-n ... mvp/id/214

I did this a long time ago on my Linux home server for logging temperature.

(* actually I know the on-board UART is allocated to debugging)

jtanner_msft
Posts: 105
Joined: Fri May 01, 2015 7:12 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue Jun 09, 2015 12:02 am

My current understanding is that at the moment the C# apps can’t always guarantee the timing needed to properly drive this sensor. It is something that the product team is aware of and looking at improving for the future. For the time being however we would suggest you look at using an Arduino to drive the device in conjunction with your Rpi2 device.

I hope this helps.
Jonathan Tanner | Microsoft | Windows 10 IoT Core Insider Preview Support | This posting is provided 'as is' with no warranties and confers no rights.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue Jun 09, 2015 1:02 am

jtanner_msft wrote:My current understanding is that at the moment the C# apps can’t always guarantee the timing needed to properly drive this sensor. It is something that the product team is aware of and looking at improving for the future. For the time being however we would suggest you look at using an Arduino to drive the device in conjunction with your Rpi2 device.

I hope this helps.
That's why I suggested the UART, since the timing is done by the hardware.

I wouldn't suggest an Arduino. I'd suggest Raspbian.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23869
Joined: Sat Jul 30, 2011 7:41 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Tue Jun 09, 2015 8:48 am

Thread cleaned of cruft.

Play nice people, or don't play at all.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

biduan
Posts: 1
Joined: Thu Sep 03, 2015 6:40 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Sat Sep 05, 2015 3:12 pm

Try this lib

https://github.com/Rinsen/OneWire

maybe it could help for you.

However, I test on my DS18B20 sensor, which got "Slave address was not acknowledged" error message. suppose it is cause of my wrong PIN connecting.

User avatar
joan
Posts: 14349
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Sat Sep 05, 2015 4:13 pm

That software is using an I2C interface to a 1-wire device. I don't know how to convert that information into terms a Windows user will understand.

paul777
Posts: 4
Joined: Wed May 14, 2014 3:11 pm

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Fri Nov 13, 2015 10:38 am

trashcoder wrote:Has anybody looked in to getting 1-wire devices working on Windows 10 yet? I'm interested in using DS18B20 temperature sensors, but have no idea how to get 1-wire working in Windows 10 for the Pi, or if it's even supported in this early preview build.

Thanks
Hi,

Did you ever find a good solution for this I'm looking at the same problem myself?

thanks

trashcoder
Posts: 6
Joined: Fri May 08, 2015 1:16 am

Re: DS18B20 Temperature Sensor / 1-Wire on Windows 10

Fri Nov 13, 2015 12:52 pm

paul777 wrote:Hi,

Did you ever find a good solution for this I'm looking at the same problem myself?

thanks
I ended up using an Arudino connected to the Pi via I2C...

Return to “Windows 10 for IoT”