Sony's Developer World forum

    • Home
    • Forum guidelines

    Upcoming maintenance 

     

    Dear Customers and Partners.

    This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.

    This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.

    We apologize for any inconvenience.

     

     

    Compatibility (software/hardware) with onewire library?

    Spresense
    2
    5
    1279
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alfredoz last edited by

      Hi,
      I have been attempting to use the DS18B20 water temperature probe with Spresense and its extension board.

      The sketch with the main program can be found here:
      https://wiki.dfrobot.com/Waterproof_DS18B20_Digital_Temperature_Sensor__SKU_DFR0198_

      and then the latest OneWire library 2.3.7. from the Arduino "manage "libraries" tool has been installed in the Arduino SDK.

      The software compiles and runs well on Arduino (uno):

      f695918a-3474-4a7f-97f2-a72a71976d19-onewire-ok-small.jpg

      The software compiles but fails to detect a one wire accessory with the Spresence+ extension board:

      b164a57a-79ec-4f9a-b305-024bff79d83f-onewire-nok-small.jpg

      I wondered if this could be a result of the 1Kohm pull up to V+ on the Spresence extension board being a bit strong for the accessory to pull down, but a subsequent test with the Arduino including a 1K pull up to V+ was successful, suggesting that the accessory ought to be compatible hardware-wise.

      So, my attention has turned to the Onewire library. Appreciate any pointers where to start, as the code is happy to compile but fails to detect one wire devices.
      Best,
      alfredo.

      C 2 Replies Last reply Reply Quote
      • C
        CamilaSouza DeveloperWorld @alfredoz last edited by

        Hey, @alfredoz
        Just a thought.. Maybe the pin you're using is set to the wrong mode?
        d1d670a5-120f-49b1-a0c5-affc447a0942-image.png

        cedaad3e-b073-47e7-b700-0ad95d74cd47-image.png

        1 Reply Last reply Reply Quote
        • C
          CamilaSouza DeveloperWorld @alfredoz last edited by

          @alfredoz
          Also.. since your sketch works on Arduino.
          Please check out this section of the documentation if you haven't already
          https://developer.sony.com/develop/spresense/docs/hw_docs_en.html#_differences_between_spresense_and_arduino_uno

          1 Reply Last reply Reply Quote
          • A
            alfredoz last edited by

            Hi Camille,
            Thanks for the pointers. I have managed to get the 1-wire temperature probe working now.

            The key steps involved:

            • replace instances of
              DIRECT_MODE_INPUT(baseReg, bitmask);
              DIRECT_WRITE_LOW(baseReg, bitmask);
              in the library OneWire::reset,write_bit, read_bit, write, write_bytes, read etc with
              pinMode(pin#, INPUT)
              digitalWrite(pin#, LOW|HIGH)
              in this order i.e. pinMode() set first before digitalWrite().

            The Arduino code does not seem to care as much about the order but the Spresence code does. If you reverse the order in Spresence then instead e.g. of a sustained LOW output you will see a short 2.5-5us low spike instead.

            C 1 Reply Last reply Reply Quote
            • C
              CamilaSouza DeveloperWorld @alfredoz last edited by CamilaSouza

              @alfredoz

              yaay! I'm so happy for you.
              Thank you for sharing your solution.
              Might help other developers in the future.

              1 Reply Last reply Reply Quote
              • First post
                Last post
              Developer World
              Copyright © 2021 Sony Group Corporation. All rights reserved.
              • Contact us
              • Legal