Lopy4 onewire has SyntaxError
I am running on the latest firmware "1.18.2.r5" with the pysense board. I am using a DS18B20 temperature sensor connected to Pin 10. The code will work for awhile but eventually had this error:
Line 15 in main.py:
from onewire import DS18X20
Line 215 in onewire.py:
temp_msb = data
Any idea what could be causing this? I am using all the libraries supplied by Pycom for DS18X20 and onewire
robert-hh last edited by
@Dylan I just tried that code, and it works. Do you have a 4.7 kOhm Pull-up resistor between Vdd and Data of the DS18B20?
I've uploaded a few times, uploads with no errors. I've got a work around by doing:
def get_temp(): temp_value = None count = 0 while temp_value == None: try: count = count + 1 print(temp_value) temp2.start_conversion() time.sleep(1) temp_value = temp2.read_temp_async() time.sleep(1) if count == 2: machine.reset() except SyntaxError: print("\n") print("\n") print("\n") print("\n") print("syntax error") print("\n") print("\n") print("\n") time.sleep(0.5) machine.reset() return(temp_value)
I know machine.reset() is probably not the best approach but it's the simplest that I know :P
Also check that you don’t have any files with the same name lying around which could cause confusion.