@Miles,
Start with the ST_Anything Arduino code. Install the libraries and then open the sketch.
Remove the sensors you don’t want and make copies of the sensors you want multiples of. So, if you just want 3 DH22’s, then set up your pins:
#define PIN_TEMPERATUREHUMIDITY5 5
#define PIN_TEMPERATUREHUMIDITY7 7
#define PIN_TEMPERATUREHUMIDITY8 8
Then define the sensors:
st::PS_TemperatureHumidity sensor5("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY5, st::PS_TemperatureHumidity::DHT22, "pin5t", "pin5h");
st::PS_TemperatureHumidity sensor7("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY7, st::PS_TemperatureHumidity::DHT22, "pin7t", "pin7h");
st::PS_TemperatureHumidity sensor8("temphumid", 120, 10, PIN_TEMPERATUREHUMIDITY8, st::PS_TemperatureHumidity::DHT22, "pin8t", "pin8h");
and add them to the class:
st::Everything::addSensor(&sensor5);
st::Everything::addSensor(&sensor7);
st::Everything::addSensor(&sensor8);
Two things to note here.
- The temperature humidity sensors are unique since one sensor returns
two things on one pin. Because of that, the call for that one is
different than the other sensors. On the other sensors, the name
that will be used in the ST cloud is the first parameter that is
passed. For the temp humid sensors, the names are optional
parameters at the end. (“pin5t”, “pin5h” for example)
- Based on the number of sensors you are talking about having, you
will need to increase the MAX number of sensors in Constants.h.
That should be enough to get them to start showing in the serial display when you run the Arduino code.
Then, create a device type in the smart things IDE (Following the instructions above) and do a similar modification, removing what you don’t want and duplicating what you do. So, remove all of the non temp and non humidity sensors and duplicate the existing ones changing the names to match what you called them when you defined them. Also remove any capabilities you will not be using.
So, your tile definitions for the three sensor example above would look something like this:
// Tile Definitions
tiles {
valueTile("pin5t", "device.pin5t", width: 1, height: 1) {
state("pin5t", label:'${currentValue}∞',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("pin7t", "device.pin7t", width: 1, height: 1) {
state("pin7t", label:'${currentValue}∞',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("pin8t", "device.pin8t", width: 1, height: 1) {
state("pin8t", label:'${currentValue}∞',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("pin5h", "device.pin5h", inactiveLabel: false) {
state "pin5h", label:'${currentValue}% humidity', unit:""
}
valueTile("pin7h", "device.pin7h", inactiveLabel: false) {
state "pin7h", label:'${currentValue}% humidity', unit:""
}
valueTile("pin8h", "device.pin8h", inactiveLabel: false) {
state "pin8h", label:'${currentValue}% humidity', unit:""
}
main(["pin5t","pin7t","pin8t","pin5h","pin7h","pin8h"])
details(["pin5t","pin7t","pin8t","pin5h","pin7h","pin8h"])
}
}
You’ll send up with something that looks like this:
Now, the only issue with this, is the Arduino can only trigger events off of the first of each type of thing. So, if you want to have something happen when the temp gets to a certain point, you can only do that for one sensor.
@ogiewon solved that for contact sensors and switches using virtual device types and a smart app to multiplex to the virtual devices.
This is as far as I have gotten on my temp humidity sensors. I am trying to figure out how to multiplex the temp and humid values to virtual device types, but I have not been successful yet.
If you just want to be able to see what the values are everywhere, this will work asis, however.
Good luck!
@Todd_Whitehead