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

It works! Many many thanks for the work you've done and your help.
Now I just need to clean the code and build a nice PCB where fix the boards and "print" the buttons.

1 Like

Glad to hear you’ve got it working! Please keep us posted on how this performs in real-world applications. Always great to see and hear about unique applications like yours.

Yes, for sure!
I would post a video, but I don't know how to do it here (without uploading somewhere, but I would not do it...)
Edit: I've done a GIF to show how it works. It needs a way to identify where the buttons are, otherwise it's going to be a bit hard to push the correct ones :wink:
CapacitiveTouchTest

1 Like

I've noted that sometimes the loop hangs, like if it waits/is blocked by something.
In this case I get no log, and the sensor is not working. Then, after several seconds (almost 1 minute), all the actions I've done are sent all together. Anyway, this doesn't happen always, sometimes it stays there, doing nothing.

Could it be something related to the sensor or is something connected to the way the manager works (not to point the finger, just to know in which direction should I investigate more)?

Without seeing your sketch, along with your new MPR121 device code, I really cannot assist in troubleshooting very effectively. If I had to guess, the MPR121 touch sensor is probably triggering events too frequently, thereby causing issues either on the microcontroller side, or the Hubitat hub side. It is always a good idea to make sure your code does not send a bunch of events in rapid succession. For a normal digital input, I typically implement 'debounce logic' to prevent this from happening. Perhaps that is worth a try in your code as well?

If you want to have a look, the code is here: ST_Anything branch.
The board can be programmed for a custom debounce. I've set 3 for push and 2 for release.

Anyway, I've read also that the board is really susceptible to any field nearby (of course!) that can cause a "lock". In my attempts I have had the power line close to the board, hence it could be that the problem was this.

Today is working since some hours without stop.

Edit: sketch is just create button device, add to handler, run loop.

Really nice shop!! I'd like to see a video tour.

Hi! Is there a "child-button.groovy" at the repository ?

No. The Parent Device acts as the Button Controller device. There is no need for a child button driver.

Hi Mr. Oigewon. I´m really new on all of this. Please forgive-me If I do ask something too basic or stupid :wink:
I was able to successfully install your codes on my ESP32 and my Hubitat hub.
Because of that I became very excited with all the possibilities, to create hardware for a handful of applications. Thank you for that!
I´m running, for tests purpose, 2 thermometers: one with DS18B20 and the other with the DTH22, both working just fine :blush:
I could understand that the sketch running on my ESP32 creates all the devices on my Hubitat hub, since there is a “.groovy” Driver for it.
That was the reason I asked before about the "child-button.groovy". I do have the “Button” on my ESP32 sketch, but I didn’t find any “device Button” on my Hubitat´s devices list. That was the moment I tried to find the .groovy Driver.

So, how can I implement the “Button Device” on my Hub, to answer for the Button on the Sketch?
Thanks in advance :wink:

As I mentioned, the HubDuino Parent Device that you manually added, is the Button Device. Just select the Parent device in any App that you’d like to use the button devices in.

Got it! Thank you pretty much.

Hi gentlemen.
I think I have a slightly more interesting question today than the last one.
I created a device with an ESP32: 4 switches and a button.
I implemented the switches on the dashboard and everything is working: the hardware (ESP32) is following the manual commands just fine.
I implemented a "basic rule" that toggles one of the ESP32 switches when it`s button is "HELD". It’s also working fine!
I also implemented another "basic rule" that toggles other ESP32´s switch when it´s s button is "PRESSED". It NOT WORKED
If I change the object of the action (of the button when it´s pressed) to, by example, a Lamp on my system, It also WORK WELL (so the button is working in all conditions: Pressed; Held and Released).
So, the short version:
The Button:
Work well on ESP's Switch when the button is held.
Not work on ESP's Switch when the button is pressed (or released), but
Work fine on other device outside the ESP (like a lamp) on the pressed or released condition.

Somebody can give-me a clue how can I start to debug this situation?
Thanks.

The Hubduino package includes the drivers: "Child Dimmer Switch" and " Child RGB(W) Switch".
Is there some sketches (ESP or Arduino) already developed, to implement Hubitat control over RGB(W) Led strips and Dimmer control for Incandescent Lamps?
Thanks.

In my GitHub repo, along with all of the other sketches you'll find this example sketch - ST_Anything/Arduino/Sketches/ST_Anything_RGB_ESP8266WiFi/ST_Anything_RGB_ESP8266WiFi.ino at master · DanielOgorchock/ST_Anything · GitHub for using the RGB device.

At the top of each of the HubDuino/ST_Anything device specific C++ files, you'll find the documentation for using that particular device in a sketch. This explains how to use each of the devices.

For example:

//******************************************************************************************
//  File: EX_Switch_Dim.h
//  Authors: Dan G Ogorchock
//
//  Summary:  EX_Switch_Dim is a class which implements the SmartThings "Switch" and "Switch Level" device capabilities.
//			  It inherits from the st::Executor class.
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::EX_Switch_Dim executor1(F("dimmerSwitch1"), PIN_SWITCH, PIN_LEVEL, LOW, true);
//
//			  st::EX_Switch_Dim() constructor requires the following arguments
//				- String &name - REQUIRED - the name of the object - must match the Groovy ST_Anything DeviceType tile name
//				- byte pin - REQUIRED - the Arduino Pin to be used as a digital output
//				- byte pin_pwm - REQUIRED - the Arduino Pin to be used as a pwm output
//				- bool startingState - OPTIONAL - the value desired for the initial state of the switch.  LOW = "off", HIGH = "on"
//				- bool invertLogic - OPTIONAL - determines whether the Arduino Digital Output should use inverted logic
//

I am back for a bit more advice, my project is grinding along slowly but surely.

I have hubduino talking to Hubitat and the basic I/O functionality of my sketch up and running. It is an alarm I/O thing and I am adding a local display to the hardware box. I have the callback function enabled to sniff the data back to the arduino and can see it there in the serial monitor. So far so good!

What i'm unsure on now is the protocol for parsing that data out of the monitor for use in the sketch and then into the local display. For example do I set 'int tempreading = analogRead (pinxx)' etc as per a standard sensor, or is there more to it than that? Had a play at it tongight but drawn a blank so far, i wasnt sure if i shoud be trying to reference the hubduino device names.

Also - i have setup my LCD in the setup section and (for testing) added a static text and the standard uptime counter in the loop section. The sample sketches have a '//TODO: add logic here...' note in the callback section - should the LCD updates be going in there?

Learning fast, but not quite fast enough..

In the callback() routine, simply parse the text string into data that you can then use in the display.

No, I would not recommend this, as the data you need for display should easily be parsed out of the string that is passed into the callback() function.

Yes, that is where I would update the LCD screen.

Thanks @ogiewon , i can see now (having spent some more time digging) that the first point is not a question for here, it is a general arduino/code question. I will come back here if there is anything i think is specific to to Hubduino that I need some help with.

Noted on the second two points :+1:

1 Like

I need some help please.
I am not new to Hubitat or Arduino. However, I am not a software developer and know just enough to be dangerous!
My goal with this Hubduino project is to get accurate measurements from a 5v and 12v PSU into Hubitat.
So far, I have:
• Got the hardware working (Nano 33 IoT with a reference, and potential dividers to keep all the readings under 3v)
• Developed a simple sketch which calculates exactly the results I need in the form of 2 variables (v5Value, v12Value using the serial monitor)
• Installed the Hubitat Parent Ethernet Driver and set it up.
• Setup the Nano 33 IoT with a fixed Ip and ensure it works on the network.
• Added all the Arduino Libraries and the sample Sketches to IDE 1.8.15

However, I am now starting to flounder and I really need some guidance.

1/ The sample sketch (ST_Anything_Multiples_Nano33IoT) won’t compile and gives me 2 pages of errors.

A Sample of it looks like this.

C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\PS_PulseCounter.cpp: In constructor 'st::PS_PulseCounter::PS_PulseCounter(const arduino::__FlashStringHelper*, unsigned int, int, byte, int, byte, float, float)':
C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\PS_PulseCounter.cpp:83:72: error: no matching function for call to 'attachInterrupt(byte&, void (&)(), int&)'
   attachInterrupt(digitalPinToInterrupt(m_nInputPin), isrPulse, inttype);
                                                                        ^
In file included from C:\Users\neile\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/Interrupts.h:8:0,
                 from C:\Users\neile\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/ArduinoAPI.h:29,
                 from C:\Users\neile\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.11\cores\arduino/Arduino.h:23,
                 from C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\Device.h:22,
                 from C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\Sensor.h:22,
                 from C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\PollingSensor.h:27,
                 from C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\PS_PulseCounter.h:48,
                 from C:\Users\neile\OneDrive\Documents\Arduino\libraries\ST_Anything\PS_PulseCounter.cpp:44:
C:\Users\neile\OneDrive\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.11\cores\arduino/api/Common.h:111:6: note: candidate: void attachInterrupt(pin_size_t, voidFuncPtr, PinStatus) <near match>
 void attachInterrupt(pin_size_t interruptNumber, voidFuncPtr callback, PinStatus mode);

Is this because I need to remove everything not related to voltage!

2/ I see the voltage.h library. Do I somehow change this to include my code!

My Code Looks like this:

// Pin Defenitions
#define VrefPin 0                                             // pin A0 - the pin our reference is connected to
#define V5Pin 1                                               // use will use analog pin 1 for voltage x
#define V12Pin 2                                              // use will use analog pin 2 for voltage y

// Voltage conversion constants and variables
const float vRef = 2.5;                                       // the accurate value of your reference
const float v5multiplier = 1.69;                              // multiplier to get back to 5v from potential divider
const float v12multiplier = 4.25;                             // mulitplier to get back to 12v from potential divider
long n5, n12, nRef;                                           // the value we read from the ADC
float v5Value, v12Value;                                      // measured voltage values after calibration correction

// sampling parameters
int nSamples = 5;                                             // Number of Samples to take for each reading
int nTimes = 7;                                               //number of times to aggregate samples
int interval = 7;                                             //milliseconds interval between successive readings

void setup() {
Serial.begin(9600);
nRef = analogRead(VrefPin);                                   // dummy read to settle ADC Mux
delay(5);
}

void loop() {
n5=0; n12=0; nRef=0;                                          //initialise values to prepare for aggregation
  for(int m=0; m<nTimes; m++){
    nRef += readInput(VrefPin, nSamples, interval);
    n5 += readInput(V5Pin, nSamples, interval);
    n12 += readInput(V12Pin, nSamples, interval);
  }

v5Value = convReadings(n5, nRef, vRef, v5multiplier);
v12Value = convReadings(n12, nRef, vRef, v12multiplier);

// Print it Out
Serial.print("5V is ");
Serial.print(v5Value, 2);
Serial.print("; 12V is ");
Serial.print(v12Value, 2);
Serial.println(" ");
delay(2000);
}

//take a set of "count" readings from selected analog input, with a delay of "pause" between readings.
long readInput(int pin, int count, int pause) {
  int n = analogRead( pin);                                   // dummy read
  n = 0;                                                      // initialise for aggregation
  delay(pause);
  for (int i = 0; i < count; i++ ) {
    n += analogRead( pin);
    delay(pause);                                             //short delay between readings - could use millis instead
  }
return n ;                                                    //returns a number count * reading
}

// Convert the number reading to voltage
float convReadings(long nZ, long nR, float vR, float mC) {
  float voltage = mC * ((vR * nZ) / nR);                       
    }

Thanks for any advice.

@neil.e.vass - unfortunately, I am away from my development system where I would be able to help troubleshoot this issue. The example sketches should all just compile without any errors, assuming you’ve followed the ReadMe instructions when setting up the libraries and sketches. It’ll be a while before I can provide more assistance. Sorry about that.