Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

micro:bit v2 MICROPYTHON onewire DB18B20 waterproof temp sensor #162

Open
burksfamly opened this issue Nov 11, 2023 · 7 comments
Open

micro:bit v2 MICROPYTHON onewire DB18B20 waterproof temp sensor #162

burksfamly opened this issue Nov 11, 2023 · 7 comments

Comments

@burksfamly
Copy link

I need micro:bit v2 micropython .py library files for the onewire protocol and DS18B20 driver for a waterproof temp sensor. Research has been frustrating. Has anyone ported this yet.

I took a look at PyCom. Looks good if I could get enough info on micro:bit v2 micropython implementation. For example need to deal with removing from machine import Pin with from microbit import pin1...and then deal wirh the equivalwnt OPEN_DRAIN pin mode using pin1...without a map of rhe micro:bit v2 micropython environment...this will be trial and error, and I am alreadg in too many rabbit holes on this project. I DO NOT want to go back to the TMP36 because it requires a constant reference voltage. If you use your battery or battery points, temp readings change as the battery drains, and adding constant refererence voltage circuit is battery expensive

Any sources for the afforementioned files?

Thank You

@burksfamly burksfamly changed the title micro:bit v2 MICROPYRHON onewire DB18B20 waterproof temp sensor micro:bit v2 MICROPYTHON onewire DB18B20 waterproof temp sensor Nov 11, 2023
@martinwork
Copy link
Collaborator

@rhubarbdog
Copy link

rhubarbdog commented Nov 11, 2023

The code doesn't work. It requires an oscilloscope to get the timings correct. The big number in the sleep sub routine (register 7) needs to be reduced and possibly also the number of register 0 needs to be reduced before calling the sleep sub routine

@martinwork
Copy link
Collaborator

Thanks for letting us know @rhubarbdog

@dpgeorge
Copy link
Collaborator

MicroPython does have a built-in onewire module and drivers for the ds18x20. But the onewire module is not enabled on the micro:bit and needs to be compiled into the firmware to work.

@burksfamly
Copy link
Author

burksfamly commented Nov 13, 2023 via email

@dpgeorge
Copy link
Collaborator

Why was it 'turned off'?

Well, more so it was never turned on. Micro:bit v1 didn't have it and neither does v2.

To enable it and get the DS18x20 driver working requires a bit of work:

  • ability for pins to be in OPEN_DRAIN mode
  • implement mp_hal_pin_od_low, mp_hal_pin_od_high
  • implement mp_hal_quite_timing_enter/exit, mp_hal_delay_us_fast
  • enable MICROPY_PY_ONEWIRE
  • freeze in the onewire.py bus driver

Then, the ds18x20.py driver in micropython-lib will work.

@leomlr
Copy link

leomlr commented Feb 15, 2024

Hi,

We look forward to being able to program the ds18b20 with micro:bit with either solution. While waiting for these updates, thank you Damien George and Phil Hal.

Best regards, Léo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants