sht3x-device

rcb71/sht3x-temp-hum-sensor/sht3x-device

Create a SHT3X device.
sht3x-device
@/sht3x-device
Create a SHT3X device.
I2Cxod/i2c/i2c
I²C bus
ADDRbyte
I²C address.
Resetport
Reset pin.
sht3x-device
I2C
ADDR
Reset
DEV
DEV@/sht3x-device
To use the node in your project you should have the rcb71/sht3x-temp-hum-sensor 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

// Tell XOD where it can download the libraries:
#pragma XOD require "https://github.com/DFRobot/DFRobot_SHT3x"

//Include C++ libraries
#include <Wire.h>
#include <DFRobot_SHT3x.h>

node {

    meta {
        // Define our custom type as a pointer on the class instance.
        using Type = DFRobot_SHT3x*;
    }

    // check that a valid port has been specified for the reset pin
    static_assert(isValidDigitalPort(constant_input_Reset), "must be a valid digital port");

    // Reserve memory to store an instance of the DFRobot_SHT3x class,
    // and create the instance later:
    uint8_t mem[sizeof(DFRobot_SHT3x)];

    void evaluate(Context ctx) {
        // It should be evaluated only once on the first (setup) transaction
        if (!isSettingUp())
            return;

        auto wire = getValue<input_I2C>(ctx);
        auto addr = getValue<input_ADDR>(ctx);

        // Create a new object of the class DFRobot_SHT3x in the memory area reserved previously.
        Type sht3x = new (mem) DFRobot_SHT3x(wire, addr, constant_input_Reset);

        //while (sht3x->begin() != 0) {
            //raiseError(ctx);
            //return;
        //}
        
        //if(!sht3x->softReset()) {
            //raiseError(ctx);
            //return;
        //}
        
        emitValue<output_DEV>(ctx, sht3x);
    }
}