Skip to content

Raspberry Pi PICO or RP2040 PIO Lib for DS18B20 Temperature Sensor

License

Notifications You must be signed in to change notification settings

jondurrant/RP2040PIO-DS18B20

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RP2040PIO-DS18B20

Raspberry Pi PICO or RP2040 PIO Lib for DS18B20 Temperature Sensor

Based on code from Harry Fairhead (2021): "The Pico In C: A 1-Wire PIO Program".

Dependencies

Pico SDK dependencies only (GPIO and PIO)

Example

See main.cxx

Include in own projects

Simply include DS18B20pio.cmake in your CMakefile Then add ds18b20pio into target_link_libaries

Usage

Construct object:

DS18B20 ds = DS18B20(pio0, 7);

Giving the pio being used, I've only used pio0. And the GPIO number, in this case 7.

Trigger the device to sample with the command:

ds.convert();

Then give the divise approx 1000ms to complete that before reading the temperature with:

float temp = ds.getTermperature();

About

Raspberry Pi PICO or RP2040 PIO Lib for DS18B20 Temperature Sensor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published