Closed kpg141260 closed 1 year ago
Furthermore, in the OneWire lib you need to import const from Micropython, otherwise it will not know that type.
The file onewire.py is not needed for genuine MicroPython devices. I created it for being used with the Pycom variant of MicroPython. For genuine MicroPython the version in micropython-lib/micropython/drivers/bus/onewire is used, and that one shoud be installed by default on a RPi Pico. The same applies to the DS18X20 driver located at micropython-lib/micropython/drivers/sensor/ds18x20.
Hi,
after adding the Onewire library to my Micropython project on a Raspberry PICO I got error messages that the constants defined in the class OneWire cannot be resolved when used within the class: class OneWire: CMD_SEARCHROM = const(0xf0) CMD_READROM = const(0x33) CMD_MATCHROM = const(0x55) CMD_SKIPROM = const(0xcc) PULLUP_ON = const(1) ...
Possible solution to this is:
A) define the constants globally outside of the class: CMD_SEARCHROM = const(0xf0) CMD_READROM = const(0x33) CMD_MATCHROM = const(0x55) CMD_SKIPROM = const(0xcc) PULLUP_ON = const(1) class OneWire: ....
or B) when referencing the constants use: self.CMD_SEARCHROM and so on.
If that could be rectified in the source code on GitHub, that would potentially safe others some time.
Thanks, Pete