Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    How can I track my error on onewire library

    Scheduled Pinned Locked Moved LoPy
    onewirelopy4nameerrords18b20
    5 Posts 3 Posters 909 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pierrot10P Offline
      pierrot10
      last edited by

      Hello

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

      Then I upload my code from Atom.

      I am surprised to read that error:

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

      Because of that message I checked the line of the file /flash/lib/onewire.py 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 onewire.py 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

      pierrot10P 1 Reply Last reply Reply Quote 0
      • pierrot10P Offline
        pierrot10 @pierrot10
        last edited by pierrot10

        @pierrot10 However, I just read that file from the exemple
        boot.py
        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?

        Tks
        Cheers

        L robert-hhR 2 Replies Last reply Reply Quote 0
        • L Offline
          livius @pierrot10
          last edited by livius

          @pierrot10
          look at example
          https://github.com/pycom/pycom-libraries/tree/master/examples/DS18X20

          think about people first, then computers

          1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @pierrot10
            last edited by

            @pierrot10 No, you do not need boot.py.
            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.

            pierrot10P 1 Reply Last reply Reply Quote 0
            • pierrot10P Offline
              pierrot10 @robert-hh
              last edited by pierrot10

              @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 "main.py", line 9, in <module>
                File "/flash/lib/onewire.py", 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 "main.py", line 9, in <module>
                File "/flash/lib/onewire.py", 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

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

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

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom