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

    DS18B20 not working in WiPy 2.0

    Scheduled Pinned Locked Moved WiPy 2&3
    ds18b20wipy 2.0
    4 Posts 3 Posters 1.1k 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.
    • C Offline
      ColombianAus
      last edited by seb

      Hello There

      I have copied and paste following code

      from machine import Pin
      from ds18x20 import DS18X20
      d=DS18X20(Pin((Pin.exp_board.G23, mode=Pin.OUT)))
      result=d.read_temps()
      print(result)
      

      The only difference is that I am using the WyPy expansion board. it throwing following error in Atom

      Traceback (most recent call last):
      File "<stdin>", line 28
      SyntaxError: invalid syntax

      Line 28 is

      result=d.read_temps()

      any ideas?

      Cheers
      Colombian1976

      1 Reply Last reply Reply Quote 0
      • sebS Offline
        seb
        last edited by

        First thing I notice is that you are passing Pin a tuple:

        (Pin.exp_board.G23, mode=Pin.OUT)
        

        I think you have used one too many pairs of parentheses.

        Secondly, can you share all your code? because the code you posted is only 5 lines long but the error says line 28

        1 Reply Last reply Reply Quote 0
        • C Offline
          ColombianAus
          last edited by

          @seb

          hey mate,...

          OK so all code below, but as you can notice first 24 lines are commented. Furthermore, I have deleted extra parentheses for the line

          d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)

          it now throws following error:

          Traceback (most recent call last):
          File "<stdin>", line 28, in <module>
          TypeError: function does not take keyword arguments

          line 28 is

          result=d.read_temps()

          """
          import time
          from machine import Pin
          import onewire, ds18x20

          the device is on GPIO23, expansion board

          dat = Pin(Pin.exp_board.G23, mode=Pin.OUT)

          create the onewire object

          ds = ds18x20.DS18X20(onewire.OneWire(dat))

          scan for devices on the bus

          roms = ds.scan()
          print('found devices:', roms)

          loop 10 times and print all temperatures

          for i in range(10):
          print('temperatures:', end=' ')
          ds.convert_temp()
          time.sleep_ms(750)
          for rom in roms:
          print(ds.read_temp(rom), end=' ')
          print()
          """
          from machine import Pin
          from ds18x20 import DS18X20
          d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)
          result=d.read_temps()
          print(result)

          Thank you for your assistance mate

          Cheers
          Wilson

          L 1 Reply Last reply Reply Quote 0
          • L Offline
            livius @ColombianAus
            last edited by

            @colombianaus said in DS18B20 not working in WiPy 2.0:

            d=DS18X20(Pin.exp_board.G23, mode=Pin.OUT)

            now you miss Pin class...
            d=DS18X20(Pin(Pin.exp_board.G23, mode=Pin.OUT))

            think about people first, then computers

            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