rasProject_01 / weSweetHome  R. 240
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. More...
 
void initTempSensor (oneWireDevice_t *const tempSensor, char const *const name, char const *const valueFile)
 Initialise a 1-wire sensor structure. More...
 

Detailed Description

Functions for 1-wire sensors.

Copyright (c) 2018 Albrecht Weinert
weinert-automation.de a-weinert.de
/ / /\
/ /___ / \ |
\ /____\ /____\ | _|__
\ /\ / \ / \| |
\/ \/ \__/ \__/|_

Revision history

Rev. 234 20.01.2021
Rev. 168 21.07.2018 : new

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 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 and BAD_TEMP_FLOAT

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