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

Also, I’d use the IS_Water device, not a contact sensor. It works basically the same, but it’ll show up correctly as a water sensor. Just be sure to set the numReqCounts parameter to zero. Otherwise, it won’t trigger.

//******************************************************************************************
//  File: IS_Water.cpp
//  Authors: Dan G Ogorchock & Daniel J Ogorchock (Father and Son)
//
//  Summary:  IS_Water is a class which implements the Hubitat "Water Sensor" device capability.
//			  It inherits from the st::InterruptSensor class.
//
//			  Create an instance of this class in your sketch's global variable section
//			  For Example:  st::IS_Water sensor6(F("water1"), PIN_WATER, HIGH, true, 500);
//
//			  st::IS_Water() 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 input
//				- bool iState - REQUIRED - LOW or HIGH - determines which value indicates the interrupt is true
//				- bool internalPullup - OPTIONAL - true == INTERNAL_PULLUP
//				- long numReqCounts - OPTIONAL - number of counts before changing state of input (prevent false alarms)
//
//  Change History:
//
//    Date        Who            What
//    ----        ---            ----
//    2020-06-30  Dan Ogorchock  Original Creation
//
//
//******************************************************************************************

thanks for the excellent advise...i will play around

1 Like

Please explain the parameters for these sensors. I'm assuming the first (60) is 60 seconds, but I don't know if that is the update time or read value interval.

static st::PS_Illuminance sensor1(F("illuminance1"), 60, 20, PIN_ILLUMINANCE_1, 0, 1023, 0, 1000);
static st::PS_TemperatureHumidity sensor2(F("temphumid1"), 60, 40, PIN_TEMPERATUREHUMIDITY_1, st::PS_TemperatureHumidity::DHT22,"temperature1","humidity1");

The parameters are explained at the top of each device’s corresponding .cpp file in the comments section. In both of those examples, the 60 is the number of seconds the sensor is polled for fresh data. That data is sent to Hubitat immediately each time the sensor is polled.

1 Like

a little off topic but I'm using a HC-SR501 with Hubduino but only getting about 10' range....anyone have a recommendation for a longer range motion sensor that will interface with an 8266 ?

Another question -over the air ...looks like you have to add

  ArduinoOTA.handle();

in the loop function

Is that ok for hubduino ?

Give a try and let us know how it works. I recall adding OTA update support for one of the platforms…just don’t recall which one off the top of my head…probably the ESP8266…:thinking:

After hours of trying to get the OTA method that is part of the Arduino IDE, I gave up...it just kept saying could not connect.
I then tried the method from this website
https://www.mischianti.org/2021/10/26/esp8266-ota-update-with-web-browser-firmware-filesystem-and-authentication-1/
and that worked amazingly well and I now have it integrated into my Shade sketch.
What you get is web page like below

and you upload the bin created from the Arduino IDE

This will help a ton as I have 8266's all over and half the time I spend is getting serial communication to work.

@kuzenkohome
Here is the code (bugs removed : ) ...
the sketch has a motion sensor and an illuminance sensor (so I can decide whether to close shade)
and also OTA support

I assume you had this as well:

void initializeOTA(void)
{
    ArduinoOTA but.onStart([]() {
        Serial.println("Start");
    });
    ArduinoOTA.onEnd([]() {
        Serial.println("\nEnd");
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
    });
    ArduinoOTA.onError([](ota_error_t error) {
        Serial.printf("Error[%u]: ", error);
        if (error == OTA_AUTH_ERROR)
            Serial.println("Auth Failed");
        else if (error == OTA_BEGIN_ERROR)
            Serial.println("Begin Failed");
        else if (error == OTA_CONNECT_ERROR)
            Serial.println("Connect Failed");
        else if (error == OTA_RECEIVE_ERROR)
            Serial.println("Receive Failed");
        else if (error == OTA_END_ERROR)
            Serial.println("End Failed");
    });
    ArduinoOTA.begin();
    Serial.print("OTA Updates Ready ---> IP address: ");
    Serial.println(WiFi.localIP());
    Serial.println();
}
void processOTAUpdates(void)
{
    ArduinoOTA.handle(); //Do not modify
}

I believe that is the "Arduino IDE" option..which I could never get to work. See link above for "web" option

I use this on all of mine. Works great. Your network needs to be setup to allow the connection (subnet, client isolation, etc).

interesting...can you say more... not sure what you mean ? The device did show up under ports, so it saw it ...just would not download to it..
I turned off 5G in case to force 2.4G and tried a bunch of other settings people suggested and no go. I also disabled other network adapters as someone suggested.

If you’re using subnets, you either need to be on the same one or have it configured for traffic to pass.

When using Wi-Fi, client isolation is typically turned on by default. This isolates the clients from each other, preventing the upload.

Anyway, I use VS Code (previously used Arduino IDE) to push the updates. It works well for me.

Good luck.

Do you have Python installed on your Arduino IDE computer? I believe that is all one needs for the ESP8266 OTA updates to work within the Arduino IDE. I use it regularly without any additional code in my sketches. The OTA code for the ESP8266 is already built in.

Yes, I did install Python 2.7.18 (64 bit)..however when I look now I have 3.8.2 (32 bit) also installed
Sorry...now I'm really confused are you saying I didn't have to change my arduino sketch at all to be able to update over the air?
THAT would be cool.... but everywhere I read said you had to download OTA first serially before it will work (and you have to include the support in each sketch)

Yes, you have to load via USB initially from the Arduino IDE to the ESP8266 board. Afterward, the device will appear as a port in the Arduino IDE. You simply select that port (don’t change my other settings), and then simply use the Arduino IDE to compile and load the sketch. That’s it. As I mentioned, the OTA support (for ONLY the ESP8266) is already built into the correct code.

I am pretty sure this is what I used years ago to add ESP8266 OTA support.

from those directions

Are you saying that the StAnything code has this support?
I think I will delete the newer Python and give it another try

Yes, but ONLY for the ESP8266. I added the support years ago to the SmartThingsESP8266WiFi communications library.

OMG (and sorry for so many questions)... but I still have to do the BasicOTA to enable ? Even though you have support in the code? But then after that I'm good?
image