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?
-
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):
The software compiles but fails to detect a one wire accessory with the Spresence+ extension board:
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. -
Hey, @alfredoz
Just a thought.. Maybe the pin you're using is set to the wrong mode?
-
@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 -
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.
- replace instances of
-
yaay! I'm so happy for you.
Thank you for sharing your solution.
Might help other developers in the future.