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

Got my genuine Arduino mega and 5500 shield setup and it works perfectly. Guess you get what you pay for. Also is there a way to offset the voltage value to “calibrate” a sensor?

I need a little more information... which ST_Anything device are you using that needs "calibration"?

I am using moisture sensors. Most of them work properly and show 0 when dry but I have one that shows 91 when it is dry so I’d like to be able to offset the value -91.

Which HubDuino/SY_Anything device are you using in your sketch? I understand you're using a moisture sensor, however I do not have a device called moisture. I have a device for detecting water leaks called PS_Water, but that only returns 'wet' or 'dry'. Are you using the PS_Voltage device? If so, read the documentation at the top of the PS_Voltage.cpp file and you'll see there are parameters that will allow you to scale the analog input value into engineering units. This will allow you to 'calibrate' the device as you see fit.

I’m sorry I mentioned voltage in a previous post but I should have been more clear. Thanks I’ll check it out

@ogiewon do you have a recommendation for a device I can connect an external temp sensor to?

I always like the NodeMCU ESP8266 boards. They are the most versatile, as long as you do not need a lot of GPIO pins.

Do have have a specific temperature sensor in mind?

Something like this https://www.amazon.com/dp/B07Q8RHK7D/ref=cm_sw_r_cp_api_i_YHHkDb8X7GPH4

I’ve never seen one of those before. Do you have any idea what type of temperature sensor is embedded within it?

I don't; I just need one I can install in my pool return valve. If I get one, any suggestions on how I should hook it up to see what I can get out of it.

A little research into the technology used within that specific sensor is in order. Until we know the specific technology, it’s impossible to know how to wire it up. It may just be a Thermistor, which is essentially a resistor that varies its resistance as function of temperature. If so, I’d recommend googling “Arduino wiring diagram for thermistor” as you’ll need another resistor to create a voltage divider. If this is the case, then the simplest HubDuino device to use is the PS_Voltage device which allows you to scale the analog input values to engineering units (like degrees F). If we name the PS_Voltage device in the sketch “temperature1” a child temperature device will be created on your Hubitat hub, instead of the typical “voltage1” device.

1 Like

Here is some info on how to use a thermistor with a esp8266.
https://www.electronicwings.com/nodemcu/thermistor-interfacing-with-nodemcu
But I suggest using one of these.

2 Likes

@ogiewon, got a question for you... In the constructor for a polling sensor, like this one:

static st::PS_Voltage sensor1(F("illuminance1"), 60, 0, PIN_LUM, 0, 1013, 5000, 0, 5, 95);

Is there any way to use a function instead of the polling time, like this:

static st::PS_Voltage sensor1(F("illuminance1"), pollTime, 0, PIN_LUM, 0, 1013, 5000, 0, 5, 95);

and then have that function defined in the loop along with the st:::Everything::run()? I was also thinking I could use the callBack function and use a dimmer switch in the same sketch and set the poll time equal to the dimmer level. Then I would control it from HE.

The reason I ask, is that I'm trying to use a luminescence sensor to detect dusk and dawn. During the day I don't really care about the reading and in the middle of the night I don't either. So, during those times I would only want the sensor to report every 20 minutes. but once it gets closer to night, I'd want the sensor to report back every minute. But there's no need to overwhelm the hub unnecessarily with all those extra reports if I don't have to. Does that make sense or am I doing a lot of work for no real benefit?

The polling schedule is pretty much set in the sketch. There actual was some code way back in the ThingShield days where you could send a configuration command to the Arduino to change a sensor’s polling interval.

Personally, once a minute is not going to hurt the hub, IMHO. I have a NodeMCU ESP8266 sending 5 temperature sensors’ worth of data to my hub every 30 seconds.

If you’d prefer a Zigbee solution, I really like @iharyadi’s Environment Sensor which does temperature, humidity, pressure, and illuminance. And, it is a Zigbee repeater!

Nah....I'm going to be mounting this to my window to get outside luminance and already have the sensor and the board (that window has Hubduino blinds and contact sensor of course). You're right, i'm probably overthinking the polling's effect on the hub. If it were trying to report every 3 seconds then it might be something. I will definitely restrict the rule that reacts to the sensor's value so that doesn't run every minute. Thanks!!

Even every 2 minutes would probably be plenty quick.

Yeah....true. It was a fun idea though. So, in general, the values in the constuctor have to be constants? I assume they get set at the beginning of the setup and aren't re-evaluated? So, it would be set to whatever it was initialized with?

Correct. However, within a polling sensor’s beSmart() routine, the code still exists to adjust the polling interval if the hub sends it... it’s just the groovy code doesn’t exist to send this data. It got dropped a while ago when I changed everything to the Parent Child model. I don’t think it would be too hard to put back in...:thinking:

	//SmartThings Shield data handler (receives configuration data from ST - polling interval, and adjusts on the fly)
	void PS_Illuminance::beSmart(const String &str)
	{
		String s = str.substring(str.indexOf(' ') + 1);

		if (s.toInt() != 0) {
			st::PollingSensor::setInterval(s.toInt() * 1000);
			if (st::PollingSensor::debug) {
				Serial.print(F("PS_Illuminance::beSmart set polling interval to "));
				Serial.println(s.toInt());
			}
		}
		else {
			if (st::PollingSensor::debug)
			{
				Serial.print(F("PS_Illuminance::beSmart cannot convert "));
				Serial.print(s);
				Serial.println(F(" to an Integer."));
			}
		}
	}

I was thinking of just using a dimmer child device. Couldn't you do that and then in the callback "send" the appropriate message? That would only get you 0-100 seconds but if you applied another multiplier, you could get 5-500 seconds (in 5 second intervals).

It would really be a simple Child Illuminance Driver change to add a command that allows you to specify a number of seconds interval. Rule Machine's custom action could call that command and pass the value as a parameter easily enough. I'll give it a try...