CuVoodoo STM32F1 firmware template
Functions | Variables
sensor_ds18b20.c File Reference

library for Maxim DS18B20 digital temperature sensor (using 1-Wire protocol) (code) More...

Go to the source code of this file.

Functions

void sensor_ds18b20_setup (void)
 setup 1-Wire peripheral to communicate with sensors on bus
 
uint64_t sensor_ds18b20_number (void)
 get number of DS18B20 sensors on bus More...
 
bool sensor_ds18b20_only (void)
 verify if only DS18B20 sensors are on the bus More...
 
bool sensor_ds18b20_list (uint64_t *code)
 send all DS18B20 slaves on the bus More...
 
bool sensor_ds18b20_convert (uint64_t code)
 start converting (e.g. More...
 
float sensor_ds18b20_temperature (uint64_t code)
 get converted temperature More...
 
bool sensor_ds18b20_precision (uint64_t code, uint8_t precision)
 set conversion precision More...
 

Variables

uint64_t sensors = 0
 remember number of DS18B20 sensors on 1-Wire bus for certain functions
 
bool only = false
 remember if only DS18B20 sensors on 1-Wire bus for certain functions
 
uint64_t last = 0
 remember code of last sensor
 

Detailed Description

library for Maxim DS18B20 digital temperature sensor (using 1-Wire protocol) (code)

Author
King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info
Date
2017
Note
peripherals used: 1-Wire (timer timer used to measure 1-wire signal timing, GPIO GPIO used for 1-wire signal)
Warning
this library does not support parasite power mode and alarms

Definition in file sensor_ds18b20.c.

Function Documentation

◆ sensor_ds18b20_convert()

bool sensor_ds18b20_convert ( uint64_t  code)

start converting (e.g.

measuring) temperature

Warning
conversion time to wait before reading temperature depends on the resolution set (9 bits: 93.75ms, 10 bits: 187.5ms, 11 bits: 375ms, 12 bits: 950ms)
Parameters
[in]codeROM code of sensor to start conversion on (0 for all, if only DS18B20 sensors are on the bus)
Returns
if conversion started

Definition at line 87 of file sensor_ds18b20.c.

◆ sensor_ds18b20_list()

bool sensor_ds18b20_list ( uint64_t *  code)

send all DS18B20 slaves on the bus

Parameters
[out]codeROM code for sensor (0 if error occurred)
Returns
if an additional sensors have been detected

Definition at line 78 of file sensor_ds18b20.c.

◆ sensor_ds18b20_number()

uint64_t sensor_ds18b20_number ( void  )

get number of DS18B20 sensors on bus

Returns
number of DS18B20 sensors on bus

Definition at line 46 of file sensor_ds18b20.c.

◆ sensor_ds18b20_only()

bool sensor_ds18b20_only ( void  )

verify if only DS18B20 sensors are on the bus

Returns
if only DS18B20 sensors are on the bus

Definition at line 72 of file sensor_ds18b20.c.

◆ sensor_ds18b20_precision()

bool sensor_ds18b20_precision ( uint64_t  code,
uint8_t  precision 
)

set conversion precision

Parameters
[in]codeROM code of sensor to start conversion on (0 for all, if only DS18B20 sensors are on the bus)
[in]precisionprecision in bits (9-12)
Returns
if operation succeeded

Definition at line 144 of file sensor_ds18b20.c.

◆ sensor_ds18b20_temperature()

float sensor_ds18b20_temperature ( uint64_t  code)

get converted temperature

Note
85.0 C is the default temperature when no conversion has been performed
Parameters
[in]codeROM code of sensor
Returns
temperature (NaN if error)

Definition at line 113 of file sensor_ds18b20.c.