[Release] HubDuino v1.1.9 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)

Great description and drawing. That really does help quite a bit.

For the thermistor, those typically use a library to help convert the analog input voltage to a temperature, correct? The reason I ask is because there is currently no support in my ST_Anything Arduino libraries for using thermistors. There is support for many other temperature sensors, like the DS18B20, DHT22, etc... My favorite is the DS18B20, although I am not certain how well it would work over a distance of "hundreds of feet away". :thinking: If you need to use a thermistor, I am sure we could add support for it without too much difficulty.

For the water level sensing, that is a pretty interesting, novel, and simple solution. Many folks like to use ultrasonic distance sensors to measure the level in a tank. I am not saying the ultrasonic solution is better, as I have zero first hand experience with tank level monitoring. If you do decide to look into ultrasonic, I have a HubDuino driver that actually can convert measured distance into current tank volume. It works for circular tanks, but could be modified as you see fit.

I wonder if there might be a way to wire your 'level sensing nails' in such a way that as each one is in contact with water, it could change the voltage seen by a single analog input pin? That would help reduce wiring even further... Just an idea. I do like the simplicity of your design.

Yes! All of the microcontrollers supported by HubDuino/ST_Anything use the Arduino IDE for programming. One does need to add the Board Manager entry for the ESP32 processors in the Arduino IDE first...but after that, it is really the same as using an Arduino.

I have to run right now... but happy to discuss further. This is pretty cool project, as it is not the same old things most users do with HubDuino! Keep us posted as your project progresses!

This is all great info and is really helping me. The DS18B20 looks perfect.

To clarify my situation even more. My Hubitat is in the house. The well house is about 50 feet away and I can’t get Zwave reliably in there. But WiFi is pretty decent there. This is where I need to measure air temperature and status of the pump.

The water level is actually the level of a pond 500 or so feet away. I manually fill the pond from the well when it gets low, but I’m looking to automate that. While the water temp of the pond would be interesting, that’s pretty far down my list, and getting data back over 500 feet will be challenging.

Very nice idea about sending back an analog value. That would be simple to do if you knew the resistance of the water. Unfortunately from my limited experiments it's highly variable based on the material you put in water (galvanized nails don't conduct well, for example). I think that would add an extra variable that would reduce the reliability. And it's reasonably cheap to get 5 or 10 conductor sprinkler wire that can be directly buried underground without a conduit. I'll probably wind up using a decent sized metal plate nailed into stick and solder (or maybe weld) everything I can to prevent corrosion.

Without getting into too many details, it’s a bit more complex than that. The pump can either provide water to the house or the pond. So I have a careful dance of when to send water where. I am thinking later to add additional sensors like water pressure and water flow rate. These would allow me to make smarter decisions and add in safety margins and do some other clever things. But I like to crawl, then walk, then run. So I'm starting slow.

2 Likes

hello i woud need some help. I woud like to connect Mega 2560 R3 on my hubitat but, i can`t compile raw Sketch [ST_Anything_Multiples_EthernetW5x00_MEGA]

Arduino ide: Compilation error: SmartThingsEthernetW5x00.h: No such file or directory
how i import [Sketches] and [libraries]
i`m noob on this thinks :slight_smile: thanks for help

I've got my ESP32 in and it's booting up and able to see my WiFi network. Let me know if you have instructions on the re-work of the HubDuino that you mentioned earlier and I'll be happy to start there.

Great! I'll put the new code in my GitHub repository and will let you know the details shortly.

ALL - Please do NOT upgrade your existing/working HubDuino systems to this new BETA code-base. This is a BREAKING Change for existing users! All of the new drivers do have unique names, so there is no risk of inadvertently upgrading/breaking one's system!

@jda03806 - I have uploaded the new BETA Hubitat Driver files to my GitHub repo.

The most important file for you to grab is the "hubduino-parent-ethernet-beta.groovy" file as circled below. Instead of requiring all of my old "Child ..." drivers, it uses Hubitat's built-in "Generic Component ..." child drivers instead, wherever possible. The "hubduino-component..." drivers shown below, are required only if you plan to use these types of devices, as Hubitat does not have built-in versions for these.

All,

My goal was to help make it simpler for users to get up a running, without the need to install so much custom code on their hubs. It also has some advantages in being more compatible with some other integrations. :wink:

A few of my original child device types are not currently supported at all, including "Child Sound Pressure Level", "Child Weight Measurement", "Child RGB Switch", "Child RGBW Switch", and "Child Generic Sensor".

1 Like

Cool, so to be clear, I should follow all README instructions up to " Hubitat Elevation Hub Setup Instructions" and instead of grabbing all the goovy drivers, just grab this one?

I have to run to something for about 1.5 hours and will be back online then.

Correct. As long as the Child Devices you want to use are not in the two lists above, you only need the one Parent Beta driver. The rest of the process should be identical.

Made a few more updates to the latest BETA code. Nothing urgent, just tested a few more device types. Trying to knock this work out! :wink:

Worked for me I think. All pretty easy. Does this look right to you?

The values on the right took a few seconds to show up. This is still just run the example Multiples sketch file. This looks really cool! Now for me to integrate a real temp sensor. But that will have to be tomorrow.

1 Like

I see a bunch of child devices have been created. Looking at the code, I tried wiring up one of my new DS18B20's with data on pin6, but it's not reading anything. I'll mess around tomorrow deleting other devices to see if I can debug what's going on.

image

Hmmmm... Something is not quite correct. Those attribute values should not be appearing on the parent device.

These are the normal Parent Device attributes
image

It looks like the ones that are appearing are ones that require custom "HubDuino Component ..." drivers. Not having them installed on your hub is causing that particular behavior. I should be able to sort that out in the Parent Driver. If you look through your Hub's LOGS, you'll see errors when it is trying to create those child devices.

In the example "Multiples" sketch, you can simply comment out the devices you don't need in the SETUP routine. There are two sections...

  //Polling Sensors
  static st::PS_Water               sensor1(F("water1"), 60, 0, PIN_WATER_1, 500);
  static st::PS_Water               sensor2(F("water2"), 60, 10, PIN_WATER_2, 500);
  static st::PS_Illuminance         sensor3(F("illuminance1"), 60, 20, PIN_ILLUMINANCE_1, 0, 4095, 0, 10000);
  static st::PS_Illuminance         sensor4(F("illuminance2"), 60, 30, PIN_ILLUMINANCE_2, 0, 4095, 0, 10000);
  static st::PS_Voltage             sensor5(F("voltage1"), 60, 40, PIN_VOLTAGE_1, 0, 4095, 0, 3300, 1, 100);
//  static st::PS_Voltage             sensor5(F("voltage1"), 5, 1, PIN_VOLTAGE_1, 0, 4095, 0, 4095, 20, 75,  -0.000000025934, 0.0001049656215,  0.9032840665333,  204.642825355678);
  static st::PS_MQ2_Smoke           sensor6(F("smoke1"), 10, 3, PIN_SMOKE_1, 1000);
  static st::PS_TemperatureHumidity sensor7(F("temphumid1"), 15, 5, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
  static st::PS_DS18B20_Temperature sensor8(F("temperature2"), 60, 55, PIN_TEMPERATURE_2, false, 10, 1); 

  //Interrupt Sensors 
  static st::IS_Motion              sensor9(F("motion1"), PIN_MOTION_1, HIGH, false, 500);
  static st::IS_Motion              sensor10(F("motion2"), PIN_MOTION_2, HIGH, false, 500);
  static st::IS_Contact             sensor11(F("contact1"), PIN_CONTACT_1, LOW, true, 500);
  static st::IS_Contact             sensor12(F("contact2"), PIN_CONTACT_2, LOW, true, 500);
  static st::IS_Smoke               sensor13(F("smoke2"), PIN_SMOKE_2, HIGH, true, 500);
  static st::IS_Button              sensor14(F("button1"), PIN_BUTTON_1, 1000, LOW, true, 500);
  static st::IS_Button              sensor15(F("button2"), PIN_BUTTON_2, 1000, LOW, true, 500);
  static st::IS_CarbonMonoxide      sensor16(F("carbonMonoxide1"), PIN_CO_1, HIGH, true, 500);
  
  //Special sensors/executors (uses portions of both polling and executor classes)
  static st::IS_DoorControl         sensor17(F("doorControl1"), PIN_DOORCONTROL_CONTACT_1, LOW, true, PIN_DOORCONTROL_RELAY_1, LOW, true, 1000);
  static st::S_TimedRelay           sensor18(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, false, 3000, 0, 1);
  
  //Executors
  static st::EX_Switch              executor1(F("switch1"), PIN_SWITCH_1, LOW, true);
  static st::EX_Alarm               executor2(F("alarm1"), PIN_ALARM_1, LOW, true);
  static st::EX_Alarm               executor3(F("alarm2"), PIN_ALARM_2, LOW, true, PIN_STROBE_2);
  

and

  //*****************************************************************************
  //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(&sensor10);
  st::Everything::addSensor(&sensor11);
//  st::Everything::addSensor(&sensor12);
  st::Everything::addSensor(&sensor13);
//  st::Everything::addSensor(&sensor14); 
//  st::Everything::addSensor(&sensor15); 
  st::Everything::addSensor(&sensor16); 
  st::Everything::addSensor(&sensor17);
  st::Everything::addSensor(&sensor18);  
      
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  st::Everything::addExecutor(&executor1);
//  st::Everything::addExecutor(&executor2);
  st::Everything::addExecutor(&executor3);

As you can see above, for testing I have been commenting and uncommenting specific devices. :wink:

I have pushed a new version of the BETA Parent Driver to my github repo. This properly handles the missing child drivers issue, without creating spurious attributes on the parent device. Also improved the error logging for this case.

Thank you for testing and reporting this issue.

Thanks, that looks like you describe it now. But I'm still not able to get my temp probe to work. I tried commenting out the other sensors and I'm still getting -196.6 deg. I even swapped to another temperature probe to see if that one was bad and get the same result.

All I did was connect the yellow wire to pin 26 on the breakout board and the red wire to 3V3 and the black to GND.

Here's the sketch file I'm using, can you let me know if you see anything odd or can suggest any next steps?

//******************************************************************************************
//  File: ST_Anything_Multiples_ESP32WiFi.ino
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  This Arduino Sketch, along with the ST_Anything library and the revised SmartThings 
//            library, demonstrates the ability of one ESP32 to implement 
//            a multi input/output custom device for integration into SmartThings.
//            The ST_Anything library takes care of all of the work to schedule device updates
//            as well as all communications with the ESP32's WiFi.
//
//            ST_Anything_Multiples implements the following ST Capabilities as a demo of what is possible with a single ESP32
//              - 2 x Water Sensor devices (using an analog input pin to measure voltage from a water detector board)
//              - 2 x Illuminance Measurement devices (using a photoresitor attached to ananlog input)
//              - 1 x Voltage Measurement devices (using a photoresitor attached to ananlog input)
//              - 1 x Door Control devices (used typically for Garage Doors - input pin (contact sensor) and output pin (relay switch)
//              - 2 x Contact Sensor devices (used to monitor magnetic door sensors)
//              - 1 x Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//              - 1 x Smoke Detector device (using simple digital input)
//              - 1 x MQ-2 Smoke Detector devices (using simple analog input compared to user defined limit)
//              - 1 x Carbon Monoxide Detector device (using simple digital input)
//              - 2 x Motion devices (used to detect motion)
//              - 1 x Temperature Measurement device (Temperature from DHT22 device)
//              - 1 x Humidity Measurement device (Humidity from DHT22 device)
//              - 1 x Temperature Measurement device (Temperature from Dallas Semi 1-Wire DS18B20 device)
//              - 1 x Relay Switch device (used to turn on a digital output for a set number of cycles And On/Off times (e.g.relay, etc...))
//              - 2 x Button devices (sends "pushed" if held for less than 1 second, else sends "held"
//              - 2 x Alarm devices - 1 siren only, 1 siren and strobe (using simple digital outputs)
//
//    
//  Change History:
//
//    Date        Who            What
//    ----        ---            ----
//    2017-08-14  Dan Ogorchock  Original Creation - Adapted from ESP8266 to work with ESP32 board
//    2018-02-09  Dan Ogorchock  Added support for Hubitat Elevation Hub
//
//   Special thanks to Joshua Spain for his contributions in porting ST_Anything to the ESP32!
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for ESP32WiFi
//******************************************************************************************
#include <SmartThingsESP32WiFi.h>

//******************************************************************************************
// 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_Illuminance.h>  //Implements a Polling Sensor (PS) to measure light levels via a photo resistor on an analog input pin 
#include <PS_Voltage.h>      //Implements a Polling Sensor (PS) to measure voltage on an analog input pin 
#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 <PS_MQ2_Smoke.h>    //Implements an Polling Sensor (PS) to monitor the status of an analog input pin from a MQ2 sensor
#include <IS_Motion.h>       //Implements an Interrupt Sensor (IS) to detect motion via a PIR sensor on a digital input pin
#include <IS_Contact.h>      //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_Smoke.h>        //Implements an Interrupt Sensor (IS) to monitor the status of a digital input pin
#include <IS_CarbonMonoxide.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 <EX_Alarm.h>        //Implements Executor (EX)as an Alarm capability with Siren and Strobe via digital outputs to relays
#include <S_TimedRelay.h>    //Implements a Sensor to control a digital output pin with timing/cycle repeat capabilities
#include <EX_Switch_Dim.h>   //Implements an Executor (EX) for a switch (on/off) and pwm output (level) uses 2 digital output pins


//******************************************************************************************
//Define which Arduino Pins will be used for each device
//******************************************************************************************
//"RESERVED" pins for ESP32 - best to avoid
#define PIN_0_RESERVED             0  //reserved ESP32 boot/program upload
#define PIN_1_RESERVED             1  //reserved ESP32 for TX0
#define PIN_3_RESERVED             3  //reserved ESP32 for RX0
#define PIN_6_RESERVED             6  //reserved ESP32 for flash
#define PIN_7_RESERVED             7  //reserved ESP32 for flash
#define PIN_8_RESERVED             8  //reserved ESP32 for flash
#define PIN_9_RESERVED             9  //reserved ESP32 for flash
#define PIN_10_RESERVED           10  //reserved ESP32 for flash
#define PIN_11_RESERVED           11  //reserved ESP32 for flash

//Analog Pins
#define PIN_WATER_1               A0  //(GPIO 36) SmartThings Capability "Water Sensor"
#define PIN_WATER_2               A3  //(GPIO 39) SmartThings Capability "Water Sensor"
#define PIN_ILLUMINANCE_1         A6  //(GPIO 34) SmartThings Capability "Illuminance Measurement"
#define PIN_ILLUMINANCE_2         A7  //(GPIO 35) SmartThings Capability "Illuminance Measurement"
#define PIN_VOLTAGE_1             A4  //(GPIO 32) SmartThings Capability "Voltage Measurement"
#define PIN_SMOKE_1               A5  //(GPIO 33) SmartThings Capability "Smoke Detector" (MQ-2)

//Digital Pins
#define PIN_TEMPERATUREHUMIDITY_1 25  //SmartThings Capabilities "Temperature Measurement" and "Relative Humidity Measurement"
#define PIN_TEMPERATURE_2         26  //SmartThings Capabilty "Temperature Measurement" (Dallas Semiconductor DS18B20)

#define PIN_MOTION_1              27  //SmartThings Capability "Motion Sensor"
#define PIN_MOTION_2              14  //SmartThings Capability "Motion Sensor"
#define PIN_CONTACT_1             12  //SmartThings Capability "Contact Sensor"
#define PIN_CONTACT_2             13  //SmartThings Capability "Contact Sensor"
#define PIN_SWITCH_1              23  //SmartThings Capability "Switch"
#define PIN_SMOKE_2               22  //SmartThings Capability "Smoke Detector"
#define PIN_ALARM_1               21  //SmartThings Capability "Alarm"
#define PIN_ALARM_2               19  //SmartThings Capability "Alarm"
#define PIN_STROBE_2              18  //SmartThings Capability "Alarm"              
#define PIN_DOORCONTROL_CONTACT_1  5  //SmartThings Capabilty "Door Control" 
#define PIN_DOORCONTROL_RELAY_1   17  //SmartThings Capabilty "Door Control" 
#define PIN_BUTTON_1              16  //SmartThings Capabilty Button / Holdable Button
#define PIN_BUTTON_2               4  //SmartThings Capabilty Button / Holdable Button
#define PIN_TIMEDRELAY_1           2  //SmartThings Capability "Relay Switch"
#define PIN_CO_1                  15  //SmartThings Capability "Carbon Monoxide Detector"

//******************************************************************************************
//ESP832 WiFi Information
//******************************************************************************************
String str_ssid     = "Alderson";                           //  <---You must edit this line!
String str_password = "deadbeef64";                   //  <---You must edit this line!
IPAddress ip(192, 168, 86, 60);       //Device IP Address       //  <---You must edit this line!
IPAddress gateway(192, 168, 86, 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, 86, 1);  //DNS server              //  <---You must edit this line!
const unsigned int serverPort = 8090; // port to run the http server on

// Smartthings / Hubitat Hub TCP/IP Address
IPAddress hubIp(192, 168, 86, 37);    // smartthings/hubitat hub ip //  <---You must edit this line!

// SmartThings / Hubitat Hub TCP/IP Address: UNCOMMENT line that corresponds to your hub, COMMENT the other
//const unsigned int hubPort = 39500;   // smartthings hub port
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.
//******************************************************************************************
void callback(const String &msg)
{
//  String strTemp = msg;
//  Serial.print(F("ST_Anything Callback: Sniffed data = "));  //Standard serial port monitoring
//  Serial.println(msg);
//  SerialBT.print(F("ST_Anything Callback: Sniffed data = "));  // BlueTooth monitoring
//  SerialBT.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)
  //st::receiveSmartString("Put your command here!");  //use same strings that the Device Handler would send
//  if (strTemp.startsWith("temperature1"))
//  {
//    strTemp.remove(0,13);
//    Serial.println(strTemp);
//  }
//  if (strTemp.startsWith("humidity1"))
//  {
//    strTemp.remove(0,10);
//    Serial.println(strTemp);
//  }
}

//******************************************************************************************
//Arduino Setup() routine
//******************************************************************************************
void setup()
{
  //******************************************************************************************
  // Setup the default values for the ADC.  Used for analog voltage reads.
  //  Notes:  analogReadResolution(12) sets the resolution for all pins. 12 = 0-4095, 11 = 0-2047, 10 = 0-1024, 9 = 0-512 
  //          analogSetAttenuation(ADC_11db) sets the attenuation for all pins.  11db = 0-3.3v, 6dB range = 0-2.2v, 2.5db = 0-1.5v, 0db = 0-1v
  //          analogSetPinAttenuation(A7, ADC_11db) sets the attenuation for individual pins.
  //******************************************************************************************
  
  analogReadResolution(11);        // Default of 12 is not very linear.  Recommended to use 10 or 11 depending on needed resolution.
  analogSetAttenuation(ADC_6db);   // Default is 11db which is very noisy.  Recommended to use 2.5 or 6.
  
  //******************************************************************************************
  //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
  //static st::PS_Water               sensor1(F("water1"), 60, 0, PIN_WATER_1, 500);
  //static st::PS_Water               sensor2(F("water2"), 60, 10, PIN_WATER_2, 500);
  //static st::PS_Illuminance         sensor3(F("illuminance1"), 60, 20, PIN_ILLUMINANCE_1, 0, 4095, 0, 10000);
  //static st::PS_Illuminance         sensor4(F("illuminance2"), 60, 30, PIN_ILLUMINANCE_2, 0, 4095, 0, 10000);
  //static st::PS_Voltage             sensor5(F("voltage1"), 60, 40, PIN_VOLTAGE_1, 0, 4095, 0, 3300, 1, 100);
//  static st::PS_Voltage             sensor5(F("voltage1"), 5, 1, PIN_VOLTAGE_1, 0, 4095, 0, 4095, 20, 75,  -0.000000025934, 0.0001049656215,  0.9032840665333,  204.642825355678);
  //static st::PS_MQ2_Smoke           sensor6(F("smoke1"), 10, 3, PIN_SMOKE_1, 1000);
  //static st::PS_TemperatureHumidity sensor7(F("temphumid1"), 15, 5, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");
  static st::PS_DS18B20_Temperature sensor8(F("temperature2"), 60, 55, PIN_TEMPERATURE_2, false, 10, 1); 

  //Interrupt Sensors 
  //static st::IS_Motion              sensor9(F("motion1"), PIN_MOTION_1, HIGH, false, 500);
  //static st::IS_Motion              sensor10(F("motion2"), PIN_MOTION_2, HIGH, false, 500);
  //static st::IS_Contact             sensor11(F("contact1"), PIN_CONTACT_1, LOW, true, 500);
  //static st::IS_Contact             sensor12(F("contact2"), PIN_CONTACT_2, LOW, true, 500);
  //static st::IS_Smoke               sensor13(F("smoke2"), PIN_SMOKE_2, HIGH, true, 500);
  //static st::IS_Button              sensor14(F("button1"), PIN_BUTTON_1, 1000, LOW, true, 500);
  //static st::IS_Button              sensor15(F("button2"), PIN_BUTTON_2, 1000, LOW, true, 500);
  //static st::IS_CarbonMonoxide      sensor16(F("carbonMonoxide1"), PIN_CO_1, HIGH, true, 500);
  
  //Special sensors/executors (uses portions of both polling and executor classes)
  //static st::IS_DoorControl         sensor17(F("doorControl1"), PIN_DOORCONTROL_CONTACT_1, LOW, true, PIN_DOORCONTROL_RELAY_1, LOW, true, 1000);
  //static st::S_TimedRelay           sensor18(F("relaySwitch1"), PIN_TIMEDRELAY_1, LOW, false, 3000, 0, 1);
  
  //Executors
  //static st::EX_Switch              executor1(F("switch1"), PIN_SWITCH_1, LOW, true);
  //static st::EX_Alarm               executor2(F("alarm1"), PIN_ALARM_1, LOW, true);
  //static st::EX_Alarm               executor3(F("alarm2"), PIN_ALARM_2, LOW, true, PIN_STROBE_2);
  
  //*****************************************************************************
  //  Configure debug print output from each main class 
  //  -Note: Set these to "false" if using Hardware Serial on pins 0 & 1
  //         to prevent communication conflicts with the ST Shield communications
  //*****************************************************************************
  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 ESP32WiFi Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsESP32WiFi(str_ssid, str_password, 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::SmartThingsESP32WiFi(str_ssid, str_password, serverPort, hubIp, hubPort, st::receiveSmartString);

  //Run the Everything class' init() routine which establishes WiFi communications with 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(&sensor10);
  //st::Everything::addSensor(&sensor11);
  //st::Everything::addSensor(&sensor12);
  //st::Everything::addSensor(&sensor13);
  //st::Everything::addSensor(&sensor14); 
  //st::Everything::addSensor(&sensor15); 
  //st::Everything::addSensor(&sensor16); 
  //st::Everything::addSensor(&sensor17);
  //st::Everything::addSensor(&sensor18);  
      
  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  //st::Everything::addExecutor(&executor1);
  //st::Everything::addExecutor(&executor2);
  //st::Everything::addExecutor(&executor3);
      
  //*****************************************************************************
  //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();
}

// Callback routine for BlueTooth.  Uncomment to enable
//void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param){
//  if(event == ESP_SPP_SRV_OPEN_EVT){
//    Serial.println("Client Connected to BlueTooth!");
//    Serial.print("Client address is: ");
//     for (int i = 0; i < 6; i++) {
//      Serial.printf("%02X", param->srv_open.rem_bda[i]);
//      if (i < 6) {
//        Serial.print(":");
//      }
//     }
//  }
//  if(event == ESP_SPP_CLOSE_EVT ){
//    Serial.println("Client disconnected from BlueTooth");
//  }
// }

I believe you'll need to add a resistor that temperature probe circuit as well.

I thought of that after I left the house on my drive to work. I'll add a pullup resistor and report back. I'm sure that's the problem. Thanks!

1 Like

OK, got much further tonight, I'm nearly there :slight_smile: Thank you very much for all the help so far.

Temperature sensors are now working like a charm. One thing I'd like to add is a LCD Display so that I can monitor the temperature while I'm in the pump house but don't want to have to check my Hubitat app.

I have an LCD that I can display to, that's working well. But I'm not sure how to access the temperature while I'm in the loop() function.

temp1= st::PS_DS18B20_Temperature::getTemperatureSensorValue();

But the PS_DS18B20_Temperature instance isn't in scope for the loop() function. It's constructed in the setup function. So I'm really not sure how all this code is built and I'm not great at object oriented programming.

I'm not really sure how to access the static class, or if there's a better way to access the temperature in my loop() function.

In the example sketch you'll find a "callback()" routine with most of its contents commented out. Uncomment the logging statement(s) so you can see the data that is about to be sent to the Hubitat hub. You can add code in this routine that updates a LCD screen each time the data is sent to the Hub.

Perfect. You've got everything in there. Working great now! Fantastic help, can't thank you enough!

1 Like

I found one more puzzling thing last night. I added a contact sensor as an IS_Contact class. I see that the status is being output on the serial monitor for the ESP32, but the contact sensor is not showing up as a child device in Hubitat. I tried deleting all the children devices and my 2 temp sensors came back, but the contact sensor didn't. Any idea why that might be?