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

Hi all. I'm currently using Hubduino for a few things around the house, including monitoring my swimming pool chemical supply levels and temperature. I've just purchased an Arduino compatible hydraulic pressure sensor from Aliexpress

I'd like to replace one of my filter pressure gauges with this sensor and monitor my filter pressure. I could then use a rule to warn of a dirty filter.
It's been some time since I set up the other devices and I'm pretty rusty on Hubduino setup. Can someone suggest a good place to start my research? I believe the sensor produces varying voltage, based on pressure. I could create a voltage measuring device but I would need a way to then convert that into a pressure scale.

I would recommend starting with a PS_Voltage device.

Here is the info

//******************************************************************************************
//  File: PS_Voltage.h
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  PS_Voltage is a class which implements the SmartThings "Voltage Measurement" device capability.
//			  It inherits from the st::PollingSensor class.  The current version uses an analog input to measure the 
//			  voltage on an anlog input pin and then scale it to engineering units.
//
//			  The last four arguments of the constructor are used as arguments to an Arduino map() function which 
//			  is used to scale the analog input readings (e.g. 0 to 1024) to Engineering Units before sending to SmartThings. 
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::PS_Voltage sensor1(F("voltage1"), 120, 0, PIN_VOLTAGE, 0, 1023, 0.0, 5.0);
//
//			  st::PS_Voltage() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- 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 as an analog input
//				- double s_l - OPTIONAL - first argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output - minimum raw AI value
//				- double s_h - OPTIONAL - second argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output - maximum raw AI value
//				- double m_l - OPTIONAL - third argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output - Engineering Unit Min (or Max if inverting)
//				- double m_h - OPTIONAL - fourth argument of Arduino map(s_l,s_h,m_l,m_h) function to scale the output - Engineering Unit Max (or Min if inverting)
//				- byte numSamples - OPTIONAL - defaults to 1, number of analog readings to average per scheduled reading of the analog input
//				- byte filterConstant - OPTIONAL - Value from 5% to 100% to determine how much filtering/averaging is performed 100 = none (default), 5 = maximum
//
//            Filtering/Averaging
//
//				Filtering the value sent to ST is performed per the following equation
//
//				filteredValue = (filterConstant/100 * currentValue) + ((1 - filterConstant/100) * filteredValue) 
//
//----------------------------------------------------------------------------------------------------------------------------------------------

Hi @ogiewon
A lifetime ago, you assisted me (in Smartthings) to change the Child Presence Sensor so that I could use the Arduino with an ultrasonic sensor to determine if a garage is occupied by a vehicle. (And in turn, us that in a webCore piston to determine which garage door should be opened.)
Would you mind looking at the changes you had made at the time to see if I would be able to use it with HE? The changed driver allowed me to enter a distance in settings which was used to determine if the garage is occupied or not. (If the distance between the ultrasonic sensor and the object below decreased below this number, the sensor reported "present")
The Smartthings DTH looked like this in the end:

/**
 *  Child Presence Sensor
 *
 *  Copyright 2018 Daniel Ogorchock
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *    2018-02-24  Dan Ogorchock  Original Creation
 * 
 */
metadata {
	definition (name: "Child Presence Sensor", namespace: "ogiewon", author: "Daniel Ogorchock") {
		capability "Sensor"
		capability "Presence Sensor"

		attribute "lastUpdated", "String"
        attribute "level", "Number"

		command "generateEvent", ["string", "string"]
	}

	simulator {

	}
    
	preferences {
		section("Prefs") {
			input "presenceTriggerValue", "number", title: "(Optional) Presence Trigger Value\nAt what value is presence triggered?", required: false, displayDuringSetup: false
            input "invertTriggerLogic", "bool", title: "(Optional) Invert Logic", description: "False = Present > Trigger Value\nTrue = Present < Trigger Value", default: false, required: false, displayDuringSetup: false
		}
	}
    
	tiles(scale: 2) {
		multiAttributeTile(name: "presence", type: "generic", width: 2, height: 2, canChangeBackground: true) {
			tileAttribute ("device.presence", key: "PRIMARY_CONTROL") {
            	attributeState "present", label: 'Occupied', icon:"st.tesla.tesla-car", backgroundColor:"#00A0DC"
				attributeState "not present", label: 'Vacant', icon:"st.doors.garage.garage-open", backgroundColor:"#ffffff"
            }
 			tileAttribute("device.level", key: "SECONDARY_CONTROL") {
    				attributeState("default", label:'    Level ${currentValue}')
            }
		}
        valueTile("lastUpdated", "device.lastUpdated", inactiveLabel: false, decoration: "flat", width: 6, height: 2) {
    			state "default", label:'Last Updated ${currentValue}', backgroundColor:"#ffffff"
		}
	}
}

def generateEvent(String name, String value) {
	//log.debug("Passed values to routine generateEvent in device named $device: Name - $name  -  Value - $value")
	if (value.isNumber()) {
    	sendEvent(name: "level", value: value)
       	if (presenceTriggerValue) {
        	log.debug "Presence received a numeric value. Perform comparison of value: ${Float.valueOf(value.trim())} versus presenceTriggerValue: ${presenceTriggerValue}"
        	if (Float.valueOf(value.trim()) >= presenceTriggerValue) {
                value = invertTriggerLogic?"not present":"present"
            } 
            else {
            	value = invertTriggerLogic?"present":"not present"
            }
//            if (invertTriggerLogic) {
//            	if (value == "present") { value = "not present" } else { value = "present" }
//            }
        }
        else {
        	log.error "Please configure the Presence Trigger Value in device settings!"
        }
    }
    else {
    	log.debug "Presence received a string.  value = ${value}"
    	if (value != "present") { value = "not present" }
    }
    
    // Update device
	sendEvent(name: name, value: value)
    
    // Update lastUpdated date and time
    def nowDay = new Date().format("MMM dd", location.timeZone)
    def nowTime = new Date().format("h:mm a", location.timeZone)
    sendEvent(name: "lastUpdated", value: nowDay + " at " + nowTime, displayed: false)    
}

def installed() {
}

I can't remember if you had to change the Parent-Ethernet driver as well. I can post the version of the parent DTH that I use as well if you need to look at that.

Many thanks.

@ogiewon, further question, please.

You also assisted with a child device to determine the level of a water reservoir. Would you mind looking at that as well, please?

/**
 *  Child Ultrasonic Sensor
 *
 *  Copyright 2017 Daniel Ogorchock
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *  Change History:
 *
 *    Date        Who            What
 *    ----        ---            ----
 *   
 *
 * 
 */
metadata {
    	definition (name: "Child Ultrasonic Sensor, Tank Gallons Modified", namespace: "Me", author: "Me") {
    		capability "Sensor"
            capability "Presence Sensor"
            
    		attribute "lastUpdated", "String"
            attribute "ultrasonic", "Number"

    		command "generateEvent", ["string", "string"]
        }

    	tiles(scale: 2) {
    		multiAttributeTile(name: "ultrasonic", type: "generic", width: 6, height: 4, canChangeIcon: true) {
    			tileAttribute("device.ultrasonic", key: "PRIMARY_CONTROL") {
    				attributeState("ultrasonic", label: '${currentValue}%', unit:"%", defaultState: true, 
    						backgroundColors: [
                            		[value: 80, color: "#44b621"], // Dark Green
                                    [value: 60, color: "#f1d801"], // Dark Yellow
                                    [value: 40, color: "#d04e00"], // Orange
                                    [value: 20, color: "#bc2323"]  // Red
                            		])
    			}
                tileAttribute ("device.gallons", key: "SECONDARY_CONTROL") {
            		attributeState "power", label:'Remaining: ${currentValue} litres', icon: "http://cdn.device-icons.smartthings.com/Bath/bath6-icn@2x.png"
                }    
            }
     		valueTile("gallons", "device.gallons", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        			state "default", label:'${currentValue} Left', unit:"gal", backgroundColor:"#000000"
            }
            valueTile("capacity", "device.capacity", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        			state "default", label:'${currentValue} Total', unit:"gal", backgroundColor:"#d04e00"
    		}
            valueTile("lastUpdated", "device.lastUpdated", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
        			state "default", label:'Last Updated ${currentValue}', backgroundColor:"#ffffff"
    		}
        }
        
        preferences {
            input name: "height", type: "number", title: "Height", description: "Enter height of tank full level in cm", required: true
            input name: "diameter", type: "number", title: "Diameter", description: "Enter diameter of tank in cm", required: true
            input name: "airgap", type: "number", title: "AirGap", description: "Enter Sensor Height Above Full Level", required: true
        }
    }
    def generateEvent(String name, String value) {
    	log.debug("Passed values to routine generateEvent in device named $device: Name - $name  -  Value - $value")
        double sensorValue = value as float
        
        //Tank total Capacity
        def volume = 3.14159 * (diameter/2) * (diameter/2) * height // Volume of Tank
        //double capacityLiters = volume / 3785 // divide by 3785 to get total capacity in gallons - Uncomment to use for gallons
        double capacityLiters = volume / 1000 * 2 // Use for litres
        capacityLiters = capacityLiters as int  // Remove decimals
        sendEvent(name: "capacity", value: capacityLiters) // This is the total capacity when full
        
        // Ramaining in Tank
        // double remainingVolume = 100 - ((sensorValue-airgap)/height * 100 )
        double remainingVolume = (volume - (3.14159 * (diameter/2) * (diameter/2) * (sensorValue-airgap))) / 1000 * 2 // Use this line for litres
        // double remainingVolume = (volume -  (3.14159 * (diameter/2) * (diameter/2) * (sensorValue-airgap))) / 3785 // divide by 3785 to get gallons
        remainingVolume = remainingVolume.round(2)
        sendEvent(name: "gallons", value: remainingVolume) // Use this for how much is left in the tank
        
        // Tank Percent full    
        double capacityValue = 100 - ((sensorValue-airgap)/height * 100 )  // Get the percent full
        if(capacityValue != 100)
        {
        	capacityValue = capacityValue.round(2)
        	sendEvent(name: name, value: capacityValue)
        }
        // Update lastUpdated date and time
        def nowDay = new Date().format("MMM dd", location.timeZone)
        def nowTime = new Date().format("h:mm a", location.timeZone)
        sendEvent(name: "lastUpdated", value: nowDay + " at " + nowTime, displayed: false)
    }

Thank you.

I just compared your old ST_Anything "Child Presence Sensor" DTH against the current HubDuino "Child Presence Sensor" Driver. I believe all of the necessary functionality is still contained in the HubDuino version. So that one should be fine.

I doubt the Parent needed any changes. You should be fine using the HubDuino version of that as well. All Hubitat specific drivers can be found at ST_Anything/HubDuino/Drivers at master · DanielOgorchock/ST_Anything · GitHub

In general, you will need to rebuild your sketch using the latest and greatest version of the ST_Anything Arduino libraries. You will also need to change your sketch to use port 39501 instead of 39500 for the Hub's port. You'll also want to change the Hub's IP address. (Make sure your Hubitat hub has a DHCP reserved IP address to prevent it from changing.)

1 Like

As for the "Child Ultrasonic" DTH... That one looks like it has been customized somewhat.

I would recommend starting with the HubDuino "Child Ultrasonic" Driver, and modify it with the same tweaks that were made to your old ST_Anything DTH. If you have questions along the way, please feel free to ask.

Thanks Dan, much appreciated. I'll have to start up the old PC (first find it) on which I originally used to flash the Arduinos. It was the first and last time I did something like that.
Best regards.

1 Like

Very happy to get to the bottom of this thread and still see the developer is active.

Sat and followed through your readme and it all worked as it should so really pleased to. Have succeeded so initial huge thanks to you.

So, to progress to what im trying to achieve. While doing my learning i saw tutorials of using a slider to control a servo via Blynk, so i assume what i need is possible.

Im using an esp8266 node mcu board and an sg90 servo, using the smarthings servo sketch im able to turn on and off in hubitat through the child device and the servo rotates from 0-180 degrees.

Id like to be able to use a dimmer/slider to be able to increment my changes so that for example it can be set to 20% which would be 18° turned.

Any chance i could get some help doing this? Please. :grin:

1 Like

I can try to assist, but it sounds like you've already managed the most difficult part. You have an ESP8266 controlling a servo motor. Now you just want a manual way of controlling it? Have you used the Hubitat Dashboard to add a simple dimmer device tile and associate it with your HubDuino servo device? Perhaps I misunderstood your question, though??? :thinking: Please let us know what you're trying to accomplish in a little more detail if using the Hubitat Dashboard (or one of the other dashboard solutions) is not the type of answer you were looking for.

Does anyone have an example Hubduino Sketch using Pulse Counting?

I have used Hubduino before for Voltage Measurement on a NanoIOT33 and it works brilliantly but I am coming unstuck with pulse counting as it doesn't appear in the sample Sketch and I am not sure of the settings.

I have a flow rate sensor (hall effect device) and A0 is already working on the NanoIOT33 in some trail interrupt software I have written.

Also am I right in thinking I need to use the power attribute to get this reading into Hubitat!

Thanks

I do not see a good/current example sketch in my repo for using the Pulse Counting device class either. However, at the top of every one of the .h/.cpp device files, you will find some decent documentation of how to use that particular device. There is a "For Example" line that demonstrates the declaration of the object in your sketch's setup() routine, as well as a description of all of the parameters for that device. Be sure your sketch has a '#include PS_PulseCounter.h' statement in it, determine which pins on your microcontroller you're going to use, and you should be in decent shape (assuming you start with one of the other example sketches to provide a decent starting point.)

Here is the PS_PulseCounter information.

//******************************************************************************************
//  File: PS_PulseCounter.h
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  PS_PulseCounter is a class which implements the SmartThings "Power Meter"-style device capability.
//			  It inherits from the st::PollingSensor class.  The current version uses a digital input to measure the 
//			  the number of counts between polling intervals.  At the polling interval, the pulse count is converted
//			  to engineering units via a linear conversion (engUnits = slope x counts + offset).
//
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::PS_PulseCounter sensor3(F("power1"), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);
//
//			  st::PS_PulseCounter() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must be in form of "power1", "power2", etc...
//				- int interval - REQUIRED - the polling interval in seconds
//				- int offset - REQUIRED - the polling interval offset in seconds - used to prevent all polling sensors from executing at the same time
//				- byte pin - REQUIRED - the GPIO Pin to be used as an digital input (Hardware Interrupt)
//				- byte inttype - REQUIRED - which type of Arduino interrupt to trigger the ISR (RISING, FALLING, CHANGE)
//				- byte inputmode - REQUIRED - Mode of the digital input Pin (INPUT, INPUT_PULLUP)
//				- float cnvslope - REQUIRED - Conversion to Engineering Units Slope
//				- float cnvoffset - REQUIRED - Conversion to Engineering Units Offset
//

Ogiewon

I have done as you suggested.

So I have 1 Voltage and 1 Pulse counter setup.

Everything compiles OK, Child Devices are created and the voltage is working fine but I am getting nothing out of the pulse counter.

Using my meter I am sure the right pin is connected and it's getting a 3.3v square wave from the hall effect sensor.

However, I am not getting any pulses counted in Hubitat. Can you please cast your eye over the changes to your code in case I have a stupid mistake I can't see? If you say it should work then I will go and look at the sensor more deeply. (I am using a YF-S201 sensor with a supply voltage of 3.3 volts which seems to work fine and gives a high pulse of 3.3v)

Thanks

//******************************************************************************************
//  
//
//  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 Arduino NANO33IoT to implement a multiple
//            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 WiFiNINA onboard module.
//
//            ST_Anything_Multiples implements the following ST Capabilities in multiples of 2 as a demo of what is possible with a single Arduino
//              - 2 x Contact Sensor devices (used to monitor magnetic door sensors)
//              - 2 x Switch devices (used to turn on a digital output (e.g. LED, relay, etc...)
//              - 2 x Water Sensor devices (using an analog input pin to measure voltage from a water detector baord)
//              - 2 x Illuminance Measurement devices (using a photoresitor attached to ananlog input)
//              - 2 x Voltage Measurement devices (using a photoresitor attached to ananlog input)
//              - 1 x Smoke Detector devices (using simple digital input)
//              - 2 x Motion devices (used to detect motion)
//              - 2 x Temperature Measurement devices (Temperature from DHT22 device)
//              - 2 x Humidity Measurement devices (Humidity from DHT22 device)
//              - 2 x Relay Switch devices (used to turn on a digital output for a set number of cycles And On/Off times (e.g.relay, etc...))
//              - 2 x Alarm devices - 1 siren only, 1 siren and strobe (using simple digital outputs)
//
//            This example requires the use of an Arduino NANO33IoT.
// 
//  Change History:
//
//    Date        Who            What
//    ----        ---            ----
//    2019-08-17  Dan Ogorchock  New example sketch for use with the Arduino NANO33IoT
//
//******************************************************************************************
//******************************************************************************************
// SmartThings Library for Arduino NANO33IoT.
//******************************************************************************************
#include <SmartThingsWiFiNINA.h>    //Library to provide API to the SmartThings WiFi NINA Module

//******************************************************************************************
// 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_Voltage.h>      //Implements a Polling Sensor (PS) to measure voltage on an analog input pin
#include <PS_PulseCounter.h>   //Implements a Polling Sensor (PS) to measure pulse counts on an analog input pin

//**********************************************************************************************************
//Define which Arduino Pins will be used for each device
//  Notes: Arduino NANO33IoT communicates directly to the onboard WiFi NINA module without interfering 
//         with remaining NANO33IoT pins.  Thus A0-A7 and D0-D13 can be used for your sketch. 
//**********************************************************************************************************

//Analog Pins
#define PIN_VOLTAGE             A1  //SmartThings Capability "Voltage Measurement"
#define PIN_PULSE               A4  //SmartThings Capability "Power Meter"             

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

// Smartthings Hub Information
// IPAddress hubIp(192, 168, 0, 96);    // smartthings hub ip     //  <---You must edit this line!
// const unsigned int hubPort = 39500;   // smartthings hub port

// Hubitat Hub Information
IPAddress hubIp(192, 168, 0, 96);    // Hubitat hub ip     //  <---You must edit this line!
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)
{
  //Uncomment if it weould be desirable to using this function
  //Serial.print(F("ST_Anything_Multiples 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 
  static st::PS_Voltage               sensor1(F("voltage1"), 60, 55, PIN_VOLTAGE, 0, 1023, 0, 5.5);
  static st::PS_PulseCounter          sensor2(F("power1"), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);
   
  //*****************************************************************************
  //  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 WiFiNINA Communications Object
    //STATIC IP Assignment - Recommended
    st::Everything::SmartThing = new st::SmartThingsWiFiNINA(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::SmartThingsWiFiNINA(str_ssid, str_password, 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);

  //*****************************************************************************
  //Add each executor to the "Everything" Class
  //*****************************************************************************
  
  //*****************************************************************************
  //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();
}

Just a thought. I am using an Analogue pin on the NanoIOT33 A4 (which it says I can do) Do you think it would be better to use a digital one?

Reading further it says it's better to use A1, A5 A7 which are hardware interrupts. Would this work better in this instance?

If the device itself is emitting a square wave between 0v and 3.3v, and the GND side of the sensor's power supply and the microcontroller's GND are tied together (if using two different power supplies), then you'll need to make a small code change to not use the INTERNAL_PULLUP feature.

Change the following line FROM

static st::PS_PulseCounter          sensor2(F("power1"), 60, 5, PIN_PULSE, FALLING, INPUT_PULLUP, 1.0, 0);

TO

static st::PS_PulseCounter          sensor2(F("power1"), 60, 5, PIN_PULSE, FALLING, INPUT, 1.0, 0);

Yes, you'll need to use an input on your microcontroller that supports hardware interrupts. That is board-specific.

Everything seems to be working now
Just need to do all the Mechanical installation to complete the project.

Thanks again for your help.

Neil

Hi Dan, just migrated all my ST devices to Hubitat, including my ST_Anything aquariums temp and fan controls. It went fast and w/o a hitch! Wanted to ask about code maintenance. In ST, custom code was updated via GitHub, but I don't see a similar method with Hubitat. I saw there's a user contributed package manager, is that the way to go? Apologies if this is a basic question, still new to Hubitat. Thanks
Alex

I haven’t had to make many changes in the past few years, thus maintenance is not much of an issue. I also have not added any of my code to the HPM (Hubitat Package Manager) so no need to worry about that, unless you’re using other community developed code.

Just make sure you have email enabled in your settings for the community, so that you will be notified for threads you’re currently “watching”. Make sure you “watch” this thread and you know if I release anything significant.

I created new HubDuino project (just needed only one Contact Sensor) and
tested everything on my spare C-5 (running latest 2.3.3.122 sw version).
On C-5 everything works as expected but HubDuino version is a bit old
(not sure what version is but latest update was on 2020-09-19).
I installed latest 1.1.9 HubDuino on my main C-7, (Parent Ethernet and
Contact Child drivers only, C-7 still runs 2.3.1.142 sw) and
I am getting periodically this error messages in a log:

Of course project is not working on the C-7.

What could be wrong?

EDIT
Here is Parent Ethernet Config on C-5:

And C-5 log after pressing "refresh" button:

The same things on C-7 (confog is identical):

And C-7 log:

It looks like C-7 is not getting a response from HubDuino.
But why?

UPDATE 2

Everything is OK.
Stupid me, I forgot to point ESP8266 to C-7 IP.

1 Like

I'm pretty new to Hubitat and even newer to Hubduino. I'm trying to figure out if there's a specific command I can use from my ESP8266 to publish an event in hubitat, such as "button1 pushed" as seen in the serial monitor when said button is pushed. I see that, like NodeRed, Hubitat is listening for these events, and I'd like to use one button to send additional events though void callback.

Try as I might, digging through the libraries, I cant find a command that will work for it.

Are you attempting to write your own Arduino sketch? Or are you starting with one of the many HubDuino/ST_Anything example sketches that include Button devices?

If the latter, just configure the sketch and the HubDuino Parent device on the Hubitat hub will then become a Button Controller device that you can use to trigger any automations you’d like.