rasProject_01 / weSweetHome  R. 116 2026-05-14
process control       /     RasPi software         by   weinert-automation
Loading...
Searching...
No Matches
we1wire.c File Reference

Functions for 1-wire sensors. More...

#include "we1wire.h"
#include <sys/file.h>

Functions

int getTemp (oneWireDevice_t *const tempSensor)
 Get temperature.
void initTempSensor (oneWireDevice_t *const tempSensor, char const *const name, char const *const valueFile)
 Initialise a 1-wire sensor structure.

Detailed Description

Functions for 1-wire sensors.

Revision history

See file include/we1wire.h

Function Documentation

◆ getTemp()

int getTemp ( oneWireDevice_t *const tempSensor)

Get temperature.

This function tries a new measurement on the 1-wire temperature sensor provided. On success the new value is returned. On failure the last good value is returned, but at most 7 times after 7 or more good readings before. On total failure -99900 (-99.9 °C, 0 K, BAD_TEMP_READ ) is returned.

Additionally on temperature changes, the integer reading (.value) and the floating point string (valueGrdC[]) will be set in the structure.

Parameters
tempSensorpointer to the sensor's structure
Returns
the actual or last reading or -2721500 if no good / not enough past good readings

◆ initTempSensor()

void initTempSensor ( oneWireDevice_t *const tempSensor,
char const *const name,
char const *const valueFile )

Initialise a 1-wire sensor structure.

This function does basic initial settings for a 1-wire temperature sensor. tempSensor.name and tempSensor.valueFile are set by the respective parameters.
The temperature values are set to bad value; see BAD_TEMP_READ .

Parameters
tempSensorpointer to the sensor's structure (never NULL!)
namethe sensor's short name or its directory name; NULL / empty: no change
valueFilethe canonical absolute path to its value file; NULL / empty: no change