Strange issue with DHT22 devices. I have 4 of them connected to the Arduino. Somehow it appears that I have things mixed up. 2 seem to work just fine. The other two I am not sure what is going on. Between the two of them I ony have a single temp and a single humidity reading. and They appear in HE the same way. Sorta like Location A has the temp but not the humidity and ocation B has the humidity but not the Temp. When I disconnect wither one reporting is the same. Can somone look at my Sketch to make sure I have at least that written OK?
//******************************************************************************************
// ST_Anything Library
//******************************************************************************************
#include <Constants.h> //Constants.h is designed to be modified by the end user to adjust behavior of the ST_Anything library
#include <Device.h> //Generic Device Class, inherited by Sensor and Executor classes
#include <Sensor.h> //Generic Sensor Class, typically provides data to ST Cloud (e.g. Temperature, Motion, etc...)
#include <Executor.h> //Generic Executor Class, typically receives data from ST Cloud (e.g. Switch)
#include <InterruptSensor.h> //Generic Interrupt "Sensor" Class, waits for change of state on digital input
#include <PollingSensor.h> //Generic Polling "Sensor" Class, polls Arduino pins periodically
#include <Everything.h> //Master Brain of ST_Anything library that ties everything together and performs ST Shield communications
#include <PS_DS18B20_Temperature.h> //Implements a Polling Sesnor (PS) to measure Temperature via DS18B20 libraries
#include <PS_AdafruitBME280_TempHumidPress.h> //Implements a Polling Sensor (PS) to measure Temperature, humidity, and Pressure using BME280 via I2C
#include <PS_TemperatureHumidity.h> //Implements a Polling Sensor (PS) to measure Temperature and Humidity via DHT library
#include <PS_Water.h> //Implements a Polling Sensor (PS) to measure presence of water (i.e. leak detector) on an analog input pin
#include <IS_Contact.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_DoorControl.h> //Implements an Interrupt Sensor (IS) and Executor to monitor the status of a digital input pin and control a digital output pin
#include <IS_Button.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin for button presses
#include <EX_Switch.h> //Implements an Executor (EX) via a digital output to a relay
#include <S_TimedRelay.h> //Implements a Sensor to control a digital output pin with timing/cycle repeat capabilities
#include <IS_Smoke.h> //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
//**********************************************************************************************************
//Define which Arduino Pins will be used for each device
// Notes: Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header).
// This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega.
// On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card.
// These pins cannot be used for general I/O. On the Mega, the hardware SS pin, 53,
// is not used to select either the W5100 or the SD card, but it must be kept as an output
// or the SPI interface won't work.
// See https://www.arduino.cc/en/Main/ArduinoEthernetShieldV1 for details on the W5100 Sield
//**********************************************************************************************************
//"RESERVED" pins for W5100 Ethernet Shield - best to avoid
#define PIN_4_RESERVED 4 //reserved by W5100 Shield on both UNO and MEGA
#define PIN_1O_RESERVED 10 //reserved by W5100 Shield on both UNO and MEGA
#define PIN_50_RESERVED 50 //reserved by W5100 Shield on MEGA
#define PIN_51_RESERVED 51 //reserved by W5100 Shield on MEGA
#define PIN_52_RESERVED 52 //reserved by W5100 Shield on MEGA
#define PIN_53_RESERVED 53 //reserved by W5100 Shield on MEGA
//Analog Pins
//#define PIN_WATER_1 A0 //SmartThings Capability "Water Sensor"
//#define PIN_WATER_2 A1 //SmartThings Capability "Water Sensor"
//Digital Pins
#define PIN_CONTACT_1 38 //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_2 39 //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_3 40 //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_4 41 //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_5 42 //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_6 43 //SmartThings Capability "Contact Sensor"
#define PIN_TEMPERATUREHUMIDITY_1 5 // DHT22
#define PIN_TEMPERATUREHUMIDITY_2 6 // DHT22
#define PIN_TEMPERATUREHUMIDITY_3 7 // DHT22
#define PIN_TEMPERATUREHUMIDITY_4 20 // DHT22
#define PIN_SMOKE_1 13 //SmartThings Capability "MQ5 Gas Detector"
//Relay Outputs
#define PIN_SWITCH_1 22 //"Relay 1--Veg Lites"
#define PIN_SWITCH_2 23 //"Relay 2--Flower Lites"
#define PIN_SWITCH_3 24 // "Relay 3--Pool Pump"
#define PIN_SWITCH_4 31 // "Relay 10--Bedroom Heat"
#define PIN_SWITCH_5 32 // "Relay 11--Bathroom Heat"
#define PIN_SWITCH_6 33 // "Relay 12--Solar Valve""
#define PIN_SWITCH_7 35 // "Relay 13--Water Valve"
#define PIN_SWITCH_8 34 // "Relay 14--DHW Relay"
#define PIN_SWITCH_9 25 // "Relay 4 Flower Room Heater"
#define PIN_SWITCH_10 26 // "Relay 5 Smoker Fan"
#define PIN_SWITCH_11 27
#define PIN_SWITCH_12 28
#define PIN_SWITCH_13 29
//#define PIN_SWITCH_14 30
//Garage Door Pins
#define PIN_DOORCONTROL_CONTACT_1 44 //"Door Sensor North Door"
#define PIN_DOORCONTROL_RELAY_1 36 //"Door Control North Door"
#define PIN_DOORCONTROL_CONTACT_2 45 //"Door Sensor South Door"
#define PIN_DOORCONTROL_RELAY_2 30 //"Door Control South Door" Switched pin 30 & 37 because the relay connected to pin 37 is bad -- Relay 16
//******************************************************************************************
//W5100 Ethernet Shield Information
//******************************************************************************************
byte mac[] = {0x06,0x02,0x03,0x04,0x05,0x06}; //MAC address, leave first octet 0x06, change others to be unique // <---You must edit this line!
IPAddress ip(192, 168, 1, 50); //Arduino device IP Address // <---You must edit this line!
IPAddress gateway(192, 168, 1, 1); //router gateway // <---You must edit this line!
IPAddress subnet(255, 255, 255, 0); //LAN subnet mask // <---You must edit this line!
IPAddress dnsserver(192, 168, 1, 1); //DNS server // <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on
// Hubitat TCP/IP Address
IPAddress hubIp(192, 168, 1, 52); // hubitat hub ip // <---You must edit this line!
//Hubitat Hub TCP/IP Address: UNCOMMENT line that corresponds to your hub, COMMENT the other
const unsigned int hubPort = 39501; // Hubitat hub port
//******************************************************************************************
//st::Everything::callOnMsgSend() optional callback routine. This is a sniffer to monitor
// data being sent to ST. This allows a user to act on data changes locally within the
// Arduino sktech withotu having to rely on the ST Cloud for time-critical tasks.
//******************************************************************************************
void callback(const String &msg)
{
//Uncomment if it would be desirable to using this function
//Serial.print(F("ST_Anything_Miltiples Callback: Sniffed data = "));
//Serial.println(msg);
//TODO: Add local logic here to take action when a device's value/state is changed
//Masquerade as the ThingShield to send data to the Arduino, as if from the ST Cloud (uncomment and edit following line(s) as you see fit)
//st::receiveSmartString("Put your command here!"); //use same strings that the Device Handler would send
}
//******************************************************************************************
//Arduino Setup() routine
//******************************************************************************************
void setup()
{
//******************************************************************************************
//Declare each Device that is attached to the Arduino
// Notes: - For each device, there is typically a corresponding "tile" defined in your
// SmartThings Device Hanlder Groovy code, except when using new COMPOSITE Device Handler
// - For details on each device's constructor arguments below, please refer to the
// corresponding header (.h) and program (.cpp) files.
// - The name assigned to each device (1st argument below) must match the Groovy
// Device Handler names. (Note: "temphumid" below is the exception to this rule
// as the DHT sensors produce both "temperature" and "humidity". Data from that
// particular sensor is sent to the ST Hub in two separate updates, one for
// "temperature" and one for "humidity")
// - The new Composite Device Handler is comprised of a Parent DH and various Child
// DH's. The names used below MUST not be changed for the Automatic Creation of
// child devices to work properly. Simply increment the number by +1 for each duplicate
// device (e.g. contact1, contact2, contact3, etc...) You can rename the Child Devices
// to match your specific use case in the ST Phone Application.
//******************************************************************************************
//Polling Sensors
//st::PS_DS18B20_Temperature() constructor requires the following arguments
//- String &name - REQUIRED - the name of the object - either "temperature1" for a single sensor, or "temperature" for multiple sensors
//- long interval - REQUIRED - the polling interval in seconds
//- long offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//- byte pin - REQUIRED - the Arduino Pin to be used for the One-Wire DS18B20 sensor conenction
//- bool In_C - OPTIONAL - true = Report Celsius, false = Report Farenheit (Farentheit is the default)
//- byte resolution - OPTIONAL - DS18B20 sensor resolution in bits. 9, 10, 11, or 12. Defaults to 10 for decent accuracy and performance
//- byte num_sensors - OPTIONAL - number of OneWire DS18B20 sensors attached to OneWire bus - Defaults to 1
//- byte sensorStartingNum - OPTIONAL - Starting number for sending temperature sensor data when using multiple sensors on one pin - Defaults to 1
static st::PS_DS18B20_Temperature sensor1(F("temperature"), 60, 0, 11, false, 10, 6, 1); //DS1820 Sensors 1 -6
//static st::PS_DS18B20_Temperature sensor2(F("temperature"), 60, 5, 12, false, 10, 6, 7); //DS1820 Sensors 7 -12
//static st::PS_DS18B20_Temperature sensor3(F("temperature"), 60, 10, 13, false, 10, 6, 13); //DS1820 Sensors 13 -18
//static st::PS_AdafruitBME280_TempHumidPress sensor4(F("BME280_1"), 60, 0, "temperature9", "humidity1", "pressure1", false, 100, 0x77);
static st::PS_TemperatureHumidity sensor2(F("temphumid1"), 90, 50, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature7","humidity1");
static st::PS_TemperatureHumidity sensor3(F("temphumid2"), 90, 50, PIN_TEMPERATUREHUMIDITY_2, st::PS_TemperatureHumidity::DHT22,"temperature8","humidity2");
static st::PS_TemperatureHumidity sensor4(F("temphumid3"), 90, 50, PIN_TEMPERATUREHUMIDITY_3, st::PS_TemperatureHumidity::DHT22,"temperature9","humidity3");
static st::PS_TemperatureHumidity sensor9(F("temphumid4"), 90, 50, PIN_TEMPERATUREHUMIDITY_4, st::PS_TemperatureHumidity::DHT22,"temperature10","humidity4");
//Interrupt Sensors
static st::IS_Contact sensor5(F("contact1"), PIN_CONTACT_1, LOW, true, 500); //Back DoorBell
static st::IS_Contact sensor6(F("contact2"), PIN_CONTACT_2, LOW, true, 500); //Front Doorbell
static st::IS_Contact sensor11(F("contact3"), PIN_CONTACT_3, LOW, true, 500); //Solar Valve
static st::IS_Contact sensor12(F("contact4"), PIN_CONTACT_4, LOW, true, 500);
static st::IS_Contact sensor13(F("contact5"), PIN_CONTACT_5, LOW, true, 500);
static st::IS_Contact sensor14(F("contact6"), PIN_CONTACT_6, LOW, true, 500);
//static st::IS_Smoke sensor3(F("smoke1"), PIN_SMOKE_1, HIGH, true, 500);
static st::IS_DoorControl sensor7(F("doorControl1"), PIN_DOORCONTROL_CONTACT_1, LOW, true, PIN_DOORCONTROL_RELAY_1, LOW, true, 1000);
static st::IS_DoorControl sensor8(F("doorControl2"), PIN_DOORCONTROL_CONTACT_2, LOW, true, PIN_DOORCONTROL_RELAY_2, LOW, true, 1000);
//Executors
static st::EX_Switch executor1(F("switch1"), PIN_SWITCH_1, LOW, true);
static st::EX_Switch executor2(F("switch2"), PIN_SWITCH_2, LOW, true);
static st::EX_Switch executor3(F("switch3"), PIN_SWITCH_3, LOW, true);
static st::EX_Switch executor4(F("switch4"), PIN_SWITCH_4, LOW, true);
static st::EX_Switch executor5(F("switch5"), PIN_SWITCH_5, LOW, true);
static st::EX_Switch executor6(F("switch6"), PIN_SWITCH_6, LOW, true);
static st::EX_Switch executor7(F("switch7"), PIN_SWITCH_7, LOW, true);
static st::EX_Switch executor8(F("switch8"), PIN_SWITCH_8, LOW, true);
static st::EX_Switch executor9(F("switch9"), PIN_SWITCH_9, LOW, true);
static st::EX_Switch executor10(F("switch10"), PIN_SWITCH_10, LOW, true);
static st::EX_Switch executor11(F("switch11"), PIN_SWITCH_11, LOW, true);
static st::EX_Switch executor12(F("switch12"), PIN_SWITCH_12, LOW, true);
static st::EX_Switch executor13(F("switch13"), PIN_SWITCH_13, LOW, true);
//static st::EX_Switch executor14(F("switch14"), PIN_SWITCH_14, LOW, true);
//*****************************************************************************
// Configure debug print output from each main class
//*****************************************************************************
st::Everything::debug=true;
st::Executor::debug=true;
st::Device::debug=true;
st::PollingSensor::debug=true;
st::InterruptSensor::debug=true;
//*****************************************************************************
//Initialize the "Everything" Class
//*****************************************************************************
//Initialize the optional local callback routine (safe to comment out if not desired)
st::Everything::callOnMsgSend = callback;
//Create the SmartThings EthernetW5100 Communications Object
//STATIC IP Assignment - Recommended
st::Everything::SmartThing = new st::SmartThingsEthernetW5100(mac, ip, gateway, subnet, dnsserver, serverPort, hubIp, hubPort, st::receiveSmartString);
//DHCP IP Assigment - Must set your router's DHCP server to provice a static IP address for this device's MAC address
//st::Everything::SmartThing = new st::SmartThingsEthernetW5100(mac, serverPort, hubIp, hubPort, st::receiveSmartString);
//Run the Everything class' init() routine which establishes Ethernet communications with the SmartThings Hub
st::Everything::init();
//*****************************************************************************
//Add each sensor to the "Everything" Class
//*****************************************************************************
st::Everything::addSensor(&sensor1);
st::Everything::addSensor(&sensor2);
st::Everything::addSensor(&sensor3);
st::Everything::addSensor(&sensor4);
st::Everything::addSensor(&sensor5);
st::Everything::addSensor(&sensor6);
st::Everything::addSensor(&sensor7);
st::Everything::addSensor(&sensor8);
st::Everything::addSensor(&sensor9);
st::Everything::addSensor(&sensor11);
st::Everything::addSensor(&sensor12);
st::Everything::addSensor(&sensor13);
st::Everything::addSensor(&sensor14);
//*****************************************************************************
//Add each executor to the "Everything" Class
//*****************************************************************************
st::Everything::addExecutor(&executor1);
st::Everything::addExecutor(&executor2);
st::Everything::addExecutor(&executor3);
st::Everything::addExecutor(&executor4);
st::Everything::addExecutor(&executor5);
st::Everything::addExecutor(&executor6);
st::Everything::addExecutor(&executor7);
st::Everything::addExecutor(&executor8);
st::Everything::addExecutor(&executor9);
st::Everything::addExecutor(&executor10);
st::Everything::addExecutor(&executor11);
st::Everything::addExecutor(&executor12);
st::Everything::addExecutor(&executor13);
// st::Everything::addExecutor(&executor14);
//*****************************************************************************
//Initialize each of the devices which were added to the Everything Class
//*****************************************************************************
st::Everything::initDevices();
}
//******************************************************************************************
//Arduino Loop() routine
//******************************************************************************************
void loop()
{
//*****************************************************************************
//Execute the Everything run method which takes care of "Everything"
//*****************************************************************************
st::Everything::run();
}
Hope this formatting is better
Thanks