Page 1 of 5

Onewire and DS18B20

Posted: Sun Oct 11, 2015 6:58 pm
by lucien2k
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.

Re: Onewire and DS18B20

Posted: Sun Oct 11, 2015 8:46 pm
by danicampora
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

Re: Onewire and DS18B20

Posted: Sun Oct 11, 2015 9:16 pm
by lucien2k
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()

Re: Onewire and DS18B20

Posted: Sun Oct 11, 2015 9:17 pm
by lucien2k
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)

Re: Onewire and DS18B20

Posted: Tue Oct 13, 2015 10:30 am
by lucien2k
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.

Re: Onewire and DS18B20

Posted: Tue Oct 13, 2015 11:55 am
by danicampora
Cool! Please keep us posted :-)

Re: Onewire and DS18B20

Posted: Sun Oct 18, 2015 6:04 pm
by Saran
@lucien2k: did you succeed reading a 1-wire sensor? I have no luck...

Re: Onewire and DS18B20

Posted: Sun Oct 18, 2015 10:29 pm
by cswiger
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

Re: Onewire and DS18B20

Posted: Thu Oct 22, 2015 7:50 am
by lucien2k
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.

Re: Onewire and DS18B20

Posted: Thu Oct 22, 2015 8:00 am
by danicampora
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.