Onewire and DS18B20

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Onewire and DS18B20

Post by lucien2k » Sun Oct 11, 2015 6:58 pm

Just want to say thank you for the delivery yesterday. Quite happy so far, even if the documentation is pretty challenging.

I have been trying (struggling) to get the libraries I found for onewire and the temperature sensor (DS18B20) to work with the wipy.

https://github.com/micropython/micropyt ... onewire.py
https://github.com/micropython/micropyt ... ds18x20.py

There have obviously been some pretty big changes since these were made, they aren't plug and play that is for sure.

I have been having problems getting the onewire device to reply to the reset pulse. Has anyone else had any luck?

I'll post my modified files later, I can verify that my bus is pulling low for 480us but I can't see the presence pulse as a response.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Onewire and DS18B20

Post by danicampora » Sun Oct 11, 2015 8:46 pm

Thanks lucien2k. I would say that challenging is actually and understatement ;-), but it will improve as soon as we are done with shipping. We are a small team...

Now that we have the new hardware API, once other ports move to it, libraries will become plug and play.

Please post your files so that others (including me) can check it and test it.

Cheers,
Daniel

lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Re: Onewire and DS18B20

Post by lucien2k » Sun Oct 11, 2015 9:16 pm

Here are the two files I modified: https://github.com/lucien2k/wipy-onewire

I have been struggling to get it to reply properly to a reset (I think that is where the problem lies)

Code: Select all

from onewire import OneWire
from machine import Pin
ow = OneWire(Pin('GP1'))
ow.reset()
And here is what I should be able to do to get a temp reading:

Code: Select all

from machine import Pin
from tempsensor import TempSensor
d = TempSensor(Pin('GP1'))
d.read_temp()

lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Re: Onewire and DS18B20

Post by lucien2k » Sun Oct 11, 2015 9:17 pm

On a side note, this is the first time I have attempted this with any device. So it is quite likely that I am doing something wrong.

I am pretty sure I have it wired up correctly at least, as I am getting a pin high reply (whereas with the sensor disconnected/unpowered, I get a low reply)

lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Re: Onewire and DS18B20

Post by lucien2k » Tue Oct 13, 2015 10:30 am

Seems like it could be a wiring problem, got some help from an electronics student last night.

I'll try to do some more testing tonight, fingers crossed.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Onewire and DS18B20

Post by danicampora » Tue Oct 13, 2015 11:55 am

Cool! Please keep us posted :-)

Saran
Posts: 17
Joined: Thu May 28, 2015 6:52 pm

Re: Onewire and DS18B20

Post by Saran » Sun Oct 18, 2015 6:04 pm

@lucien2k: did you succeed reading a 1-wire sensor? I have no luck...

cswiger
Posts: 13
Joined: Fri Oct 16, 2015 9:51 pm

Re: Onewire and DS18B20

Post by cswiger » Sun Oct 18, 2015 10:29 pm

Diving in with Lucien2K code - I'm seeing the presence pulse and reset returns true:

>>> from tempsensor import TempSensor
>>> from machine import Pin
>>> p = Pin('GP1')
>>> t = TempSensor(p)

http://swigerco.com/ds18b20_init.JPG

def reset(self):
"""
Perform the onewire reset function.
Returns 1 if a device asserted a presence pulse, 0 otherwise.

>>> t.ow.reset()
True

lucien2k
Posts: 24
Joined: Sun Oct 11, 2015 5:34 pm

Re: Onewire and DS18B20

Post by lucien2k » Thu Oct 22, 2015 7:50 am

I need to get a new sensor (been busy for the last couple of weeks at work). I realised I had it wired wrong and I think I have cooked it.

With my suspected broken sensor, I am getting the reset pulse now but not getting any data from it.

User avatar
danicampora
Posts: 342
Joined: Tue Sep 30, 2014 7:20 am
Contact:

Re: Onewire and DS18B20

Post by danicampora » Thu Oct 22, 2015 8:00 am

On my TODO list I have: clean up smtplib and make it public, and also get one of these sensors to port the onewire library o the new API.

Post Reply