Lopy4 onewire has SyntaxError
-
Hello,
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:
Traceback (most recent call last):
File "main.py", line 15, in <module>
File "onewire.py", line 215
SyntaxError: invalid syntaxLine 15 in main.py:
from onewire import DS18X20
Line 215 in onewire.py:
temp_msb = data[1]
Any idea what could be causing this? I am using all the libraries supplied by Pycom for DS18X20 and onewire
-
@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
-
@Dylan have you checked that the onewire.py file has been correctly uploaded? Maybe try to re-upload it.
Also check that you don’t have any files with the same name lying around which could cause confusion.