Open ProblemSolved99 opened 3 years ago
Hi there,
first things first: Thank you very much for developing this Python-based implementation for driving the NAU7802, Will!
Then, also thanks a stack for bringing up the topic of MicroPython support, @ProblemSolved99. We are also looking for this to integrate into our datalogger application, see https://github.com/hiveeyes/terkin-datalogger/issues/75. Some discussions around that topic can be found at, for example, [1] and [2]. While some of those resources are in German, you can use the translation feature when signing up as a member.
Looking at adapting the lowlevel interface to the I2C bus by using micropython-smbus
is a sweet idea, it would be nice if this could work well.
With kind regards, Andreas.
[1] https://community.hiveeyes.org/t/diskussion-zum-nuvoton-nau7802-24bit-2ch-adc/3237 [2] https://community.hiveeyes.org/search?q=nau7802
Hi again,
I conducted some research and found those details I would like to share here.
It looks like the nau7802py
library is using the read_byte
and write_word_data
methods of SMBus:
However, it looks like those methods are not implemented in the canonical version of the micropython-smbus
library by @gkluoe, see init.py#L52-L67.
On the other hand, there has been a report by @MrRubberDucky99 at https://github.com/gkluoe/micropython-smbus/issues/3 where @gkluoe followed up on by submitting https://github.com/gkluoe/micropython-smbus/commit/23211716, implementing read_byte
and write_byte
. However, it looks like this has not been tested and integrated yet due to a lack of feedback.
Maybe we could use the energy from @ProblemSolved99 to investigate further and fill some gaps.
With kind regards, Andreas.
Dear @ProblemSolved99,
when looking at the code once more, taking my findings from above into consideration, the outcome from calling the begin()
method is probably always False
, because isConnected()
would also return False
.
https://github.com/longapalooza/nau7802py/blob/294c41551cc17ffc7f0f522b9f660b2c9d0bdcee/nau7802py.py#L143-L154 https://github.com/longapalooza/nau7802py/blob/294c41551cc17ffc7f0f522b9f660b2c9d0bdcee/nau7802py.py#L275-L282
Because the exception raised when calling the method read_byte
, which is not implemented, gets silently ignored, there is no indicator that this went wrong. So, I would be excited to hear back from you about the outcome when you start filling this gap by using https://github.com/gkluoe/micropython-smbus/commit/23211716.
With kind regards, Andreas.
Hi All, just a note to say I'd love it if you could test the implementation of these in my usmbus module, as I still have no way to test it myself.
The updated version lives on a branch here: https://github.com/gkluoe/micropython-smbus/tree/%233 and you can find the raw file here: https://raw.githubusercontent.com/gkluoe/micropython-smbus/%233/usmbus/__init__.py
Hey, guys. Two years later, I've got a NAU7802 and an ESP32 Wroom to test this with. There's still no MicroPython library for this thing, only a CircuitPython library, but I haven't been able to port it.
I've implemented micropython-smbus into my project and added implementations for read_byte(), write_byte(), read_word_data(), and write_word_data(), but my program can't get past myScale.begin() for Example 1 in this repo. Not sure how you got as far as you did, @ProblemSolved99. According to @amotl, .begin() shouldn't be returning True, which makes sense given what he shows.
I've published what I've tried here.
I'll give converting from CircuitPython to MicroPython tomorrow another go, I suppose, unless someone has some great news for me.
Cheers, guys. -KB.
Hi,
This library is awesome and I appreciate you putting the work into porting to Python.
I am trying to use this library in the micropython environment so I can use it with a Digi Xbee3.
I was able to locate a smbus library that provides an SMBus class for use on micropython.
I used an arduino to confirm Sparkfun board and load cell are working as expected.
I am able to use a I2C scan example for the Xbee3 to confirm that I am detected the breakout board properly and it is at the expected address (0x2A).
I am able to get through myScale.begin() without issue, but it appears when getReading() is called I get hung up on the self.available() which is always false.
Any suggestions would be very appreciated.
Thanks!