I am failing to read a DS18B20 with a RaspberryPi Pico programmed with Arduino.

I found several examples using MicroPython, however I want to do it with Arduino using the 'Raspberry Pi Pico/RP2040' plugin by Earle F. Philhower.

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 14

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

void setup() 

void loop() 
  float temp = DS18B20.getTempCByIndex(0);
  Serial.print("Temperature: ");


The code compiles, but leaves a warning

#warning "OneWire. Fallback mode. Using API calls for pinMode, digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture."

On the pico nothing works. Since not even the virtual com port appears, I assume the code fails before starting the loop.

I have tried different ports and also different versions of the code. Nothing works. Can anybody provide an example?

  • The warning may have something to do with the code. This does not seem valid Arduino OR c++
    – Milliways
    Feb 13, 2023 at 21:49

1 Answer 1


This is not an answer, this is only FWIW:

I've successfully used the "Philhower plugin for Arduino" on a couple of small projects, and it worked fine. However my devices used i2c - not "OneWire"; i.e. the device libraries I used were written for i2c.

I understand how i2c works, but I am quite ignorant on "OneWire" as I've never had to use it. I have heard that it's quite different from i2c, but I can neither support nor rebut that claim. The warning you got suggests that perhaps Philhower has added some code to his library to implement "OneWire", but that it may not be "ready for prime time". You should probably take the warning seriously.

Wrt "... not even the virtual com port appears", you should try another (simple) project to verify you have your environment set up properly.

A couple of things to ponder: If your DS18B20 has a library based on i2c, you should consider trying that. If not, drive on with "OneWire", and go to Philhower's GitHub repo to submit an issue or engage in discussion.

  • Thank you very much for the answer! Don't worry about "to verify you have your environment set up properly." I have transferred several projects to the RP2040. Furthermore, I have commented out this code until it runs and produces an output. Note, it is note enough to comment the code in the loop only.
    – qubit
    Feb 14, 2023 at 2:25
  • @qubit: OK, I'm not a good guesser wrt experience, and have come to believe it's better to under-estimate know-how than over-estimate it. So - what is the story on OneWire in Philhower's repo? Can you do OneWire w/ a Pico?
    – Seamus
    Feb 14, 2023 at 7:39
  • @qubit: Does this help?
    – Seamus
    Feb 17, 2023 at 8:11
  • @ Seamus: thanks for the link. However, I already know it. I had mixed success with it. I managed to get it to run in the pico-sdk. I can create a .uf2 file, load it on a RP2040zero and read a DS18B20 sensor. On the other hand, I never got anything working in the Arduino IDE. I also checked the original problem: The OneWire library, in particular the file util/OneWire_direct_gpio.h does not have definitions for the RP2040 architecture. Maybe someone adds that sometimes. Anyway, thanks for the constructive help.
    – qubit
    Feb 28, 2023 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.