I have put the hcsr04.py module from https://github.com/rsc1975/micropython-hcsr04 on my nodemcu v2 board with ampy and can see it but am unable to import hcsr04.
How should this be done?
Error message as follows
>>> from hcsr04 import HCSR04
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name HCSR04
HCSR04 module usage
Re: HCSR04 module usage
It is the reference to the class variable TIMEOUT_US in the __init__ method.
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=HCSR04.TIMEOUT_US):
Delete the class name HCSR04 from the default value.
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=TIMEOUT_US):
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=HCSR04.TIMEOUT_US):
Delete the class name HCSR04 from the default value.
def __init__(self, trigger_pin, echo_pin, echo_timeout_us=TIMEOUT_US):
Re: HCSR04 module usage
Thanks will try that tonight and advise of outcome:)
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: HCSR04 module usage
A common Python "gotcha". Assuming the driver works when changed, it might be worth raising an issue.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.