get-temp-f

wayland/ds18b20/get-temp-f

Get temperature of DS18B20 device with specified address.
get-temp-f
@/get-temp-f
Get temperature of DS18B20 device with specified address.
DEV@/ds18b20-devices
One of more DS18B20 devices on a singe one-wire bus.
ADDR0byte
1st byte of address.
ADDR1byte
2nd byte of address.
ADDR2byte
3rd byte of address.
ADDR3byte
4th byte of address.
ADDR4byte
5th byte of address.
ADDR5byte
6th byte of address.
ADDR6byte
7th byte of address.
ADDR7byte
8th byte of address.
UPDpulse
Update
get-temp-f
DEV
ADDR0
ADDR1
ADDR2
ADDR3
ADDR4
ADDR5
ADDR6
ADDR7
UPD
TempF
DONE
DONEpulse
Pulse on read of temperature.
TempFnumber
Temperature in degrees Fahrenheit.
To use the node in your project you should have the wayland/ds18b20 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

node {

    void evaluate(Context ctx) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto sensors = getValue<input_DEV>(ctx);
                
        DeviceAddress devAddr;
        devAddr[0] = getValue<input_ADDR0>(ctx);
        devAddr[1] = getValue<input_ADDR1>(ctx);
        devAddr[2] = getValue<input_ADDR2>(ctx);
        devAddr[3] = getValue<input_ADDR3>(ctx);
        devAddr[4] = getValue<input_ADDR4>(ctx);
        devAddr[5] = getValue<input_ADDR5>(ctx);
        devAddr[6] = getValue<input_ADDR6>(ctx);
        devAddr[7] = getValue<input_ADDR7>(ctx);
        
        emitValue<output_TempF>(ctx, sensors->getTempF(devAddr));
        emitValue<output_DONE>(ctx, 1);

    }
}