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();
}