How can I track my error on onewire library

  • Hello

    I am trying to use the DS18x20 sensor.
    For this I download the library onewire and I pasted it into /flash/lib/

    Then I upload my code from Atom.

    I am surprised to read that error:

    Traceback (most recent call last):
      File "", line 5, in <module>
      File "/flash/lib/", line 1, in <module>
    NameError: name 'I' is not defined

    Because of that message I checked the line of the file /flash/lib/ and I Can NOT see the caracter I, which should be a variable undefined. As I does not exsist, how can I solve my problem?

    I imported as the following

    from onewire import DS18X20 #This is at line 5, as state in the error message
    from onewire import OneWire # for DS18D20

    Cheers and thank, have a nice evening

  • @robert-hh Hello. Thnak for your reply. Apparently, after the transfer, a H (or a I, etc) is added as the first caracter, as the following:

    H#!/usr/bin/env python3
    OneWire library for MicroPython

    It the reason why I got that error. The problem, I can not correct it directely because after saving it, the file become newer than the source and it will be overwritten at the next sync.

    Then I look at the other lib file and I observed than none of them has that line. I remove and it work until I got a message stating, it can not imported DS18X20.

    I first open my file with textwrangler, then I open it with Atom and I observed, the text was terribly formated (A lot on the same line).

    I reformat it and it's works but not always..

    Now the problem it state a

    Traceback (most recent call last):
      File "", line 9, in <module>
      File "/flash/lib/", line 2
    SyntaxError: invalid syntax

    here is line two:

    #!/usr/bin/env python3
    OneWire library for MicroPythonß
    import time
    import machine
    class OneWire:

    What is wrong?
    Then I gave a spave (return key) before the """ and I got the same error message

    Traceback (most recent call last):
      File "", line 9, in <module>
      File "/flash/lib/", line 1, in <module>
    NameError: name 'A' is not defined

    Then how can sync my onewire file without a formatting issue and with a unwish caracter before the first line?

    Does I need to check something on Atom?

    Thabk for your help

    OK. Problem seems to be solved. I copy again the content of to /Flash/lib/ and on Atom, at the bottom right, I changed LF to CRLF.

    The problem does not appear any more.
    That funny because my has LF (and not CRLF) and I do not have this problem with

  • @pierrot10 No, you do not need
    The error is strange, and looks for me like a pymakr "surprise". If you can connect with ftp, check that the files are where you expect them and what is in the files.

  • @pierrot10 However, I just read that file from the exemple
    I have not copy. Sorry for my question, but this is mandatory? Because it look like UART and do not use UART. That make sens?


Pycom on Twitter