LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
owTerm.h File Reference

1-Wire temperature sensing for thermostats. More...

#include <DallasTemperature.h>
#include "aJSON.h"
#include <Wire.h>
#include <DS2482_OneWire.h>

Go to the source code of this file.

Macros

#define SW_AUX0   0x40
#define SW_AUX1   0x80
#define SW_STAT0   0x4
#define SW_STAT1   0x8
#define SW_OUT0   0x20
#define SW_OUT1   0x10
#define SW_MASK   0xF
#define SW_INMASK   0xFC
#define SW_FIND   1
#define SW_DOUBLECHECK   2
#define SW_PULSE0   4
#define SW_PULSE1   8
#define SW_PULSE_P0   0x10
#define SW_PULSE_P1   0x20
#define SW_CHANGED_P0   0x40
#define SW_CHANGED_P1   0x80
#define SW_PULSE0_R   0x100
#define SW_PULSE1_R   0x200
#define t_max   20
#define TEMPERATURE_PRECISION   12
#define DS2482_100_I2C_TO_1W_BRIDGE

Functions

int owUpdate ()
 Scans the 1-Wire bus and logs the devices it finds.
int owSetup ()
 Initializes the 1-Wire bus and the temperature sensors, and applies the configured resolution.
void owLoop ()
 Periodic poll: reads each configured sensor and publishes its temperature to the item's /val subtopic.
void setupOwIdle (void(*)())
 Registers an idle callback invoked between 1-Wire operations.
void owSearch ()
 Triggers a 1-Wire device search/update.

Variables

aJsonObject * owArr
 1-Wire sensor configuration array from the JSON config.
OneWire * oneWire
 1-Wire bus handle (DS2482 bridge or software pin driver).
DallasTemperature * sensors
 DallasTemperature manager on top of the 1-Wire bus.

Detailed Description

1-Wire temperature sensing for thermostats.

Reads DS18S20/DS18B20 digital thermometers (device type 0x28) through a DS2482-100 I2C-to-1-Wire bridge (or a software 1-Wire driver on a dedicated pin). Each configured sensor is polled periodically and its temperature is published to the item's /val subtopic.

Macro Definition Documentation

◆ DS2482_100_I2C_TO_1W_BRIDGE

#define DS2482_100_I2C_TO_1W_BRIDGE

◆ SW_AUX0

#define SW_AUX0   0x40

◆ SW_AUX1

#define SW_AUX1   0x80

◆ SW_CHANGED_P0

#define SW_CHANGED_P0   0x40

◆ SW_CHANGED_P1

#define SW_CHANGED_P1   0x80

◆ SW_DOUBLECHECK

#define SW_DOUBLECHECK   2

◆ SW_FIND

#define SW_FIND   1

◆ SW_INMASK

#define SW_INMASK   0xFC

◆ SW_MASK

#define SW_MASK   0xF

◆ SW_OUT0

#define SW_OUT0   0x20

◆ SW_OUT1

#define SW_OUT1   0x10

◆ SW_PULSE0

#define SW_PULSE0   4

◆ SW_PULSE0_R

#define SW_PULSE0_R   0x100

◆ SW_PULSE1

#define SW_PULSE1   8

◆ SW_PULSE1_R

#define SW_PULSE1_R   0x200

◆ SW_PULSE_P0

#define SW_PULSE_P0   0x10

◆ SW_PULSE_P1

#define SW_PULSE_P1   0x20

◆ SW_STAT0

#define SW_STAT0   0x4

◆ SW_STAT1

#define SW_STAT1   0x8

◆ t_max

#define t_max   20

◆ TEMPERATURE_PRECISION

#define TEMPERATURE_PRECISION   12

Function Documentation

◆ owLoop()

void owLoop ( )

Periodic poll: reads each configured sensor and publishes its temperature to the item's /val subtopic.

◆ owSearch()

void owSearch ( )

Triggers a 1-Wire device search/update.

◆ owSetup()

int owSetup ( )

Initializes the 1-Wire bus and the temperature sensors, and applies the configured resolution.

Returns
true on success.

◆ owUpdate()

int owUpdate ( )

Scans the 1-Wire bus and logs the devices it finds.

Returns
true on success.

◆ setupOwIdle()

void setupOwIdle ( void(* ptr )())

Registers an idle callback invoked between 1-Wire operations.

Parameters
ptrFunction to call while the bus is idle.

Variable Documentation

◆ oneWire

OneWire* oneWire
extern

1-Wire bus handle (DS2482 bridge or software pin driver).

◆ owArr

aJsonObject* owArr
extern

1-Wire sensor configuration array from the JSON config.

◆ sensors

DallasTemperature* sensors
extern

DallasTemperature manager on top of the 1-Wire bus.