muchu999 / Hubitat

Hubitat apps and drivers
8 stars 8 forks source link

Thermistor reporting on analog sensors 1 & 2 #4

Open pauldankers opened 3 years ago

pauldankers commented 3 years ago

Hi. I found you on here because you created a driver for Hubitat for the fibaro smart implant fgbs-222. (Thank you very much!) I downloaded and installed your driver. I have a pair of 10,000 ohm thermistors attached to the two analog inputs and I am using a 12 volt power supply. The thermistors are imbedded in my concrete driveway and I would like to use the reporting from the smart implant to trigger circulation pumps to heat the driveway when the driveway temperature falls below a certain temperature. I was wondering if you know of anybody who is using this device this way? The sensors are reporting voltages and I'm wondering if there might be any tips or tricks to converting the voltages to temperatures. I'm also curious what you are using it for and if you plan to keep the drivers up-to-date in the future? Thanks again - I really appreciate all that you have done!

~Paul

muchu999 commented 3 years ago

Hi, one of my analog input is actually connected to an analog temperature probe inside a Venmar HRV. The probe is original to the HRV. In order to minimize the impact of connecting it to the Fibaro, I first pass the signal through an op-amp (high impedance input). That also allows me to adjust the voltage gain to whatever I needed. The Fibaro input impedance is only 100kohms if I remember correctly so you will probably need to do the same thing. I calibrated the probe by taking measurements at 3 different temperature and it turned out it was a linear relation between voltage and temperature. I just coded it directly in my custom driver for the HRV. I use the Fibaro output to change the HRV state using mini relays and resistors.

I am still maintaining the code but there doesn't seem to be too many problems since I don't get much comments on the hubitat thread. I have no plan to stop support for now.

Cheers, Chris.

muchu999 commented 3 years ago

I say "you will probably need to do the same thing" but in your case you could just build a curve based on measurements or the thermistor data. The problem is that if the probe voltage vs temperature relationship is linear, the low input impedance of the fibaro will change that which will make it more complicated to calibrate and implement a curve/lookup table in the driver.

pauldankers commented 3 years ago

Wow, Chris, I had to read some articles and watch some videos to find out what an HRV was (I should have remembered, I installed one in my garage!) and then I had to look up op-amps, because I had no idea what that was. I'm a little bit less lost now than I was, but it's still pretty much over my head. I wish I had your knowledge! If you really think that I will need an op-amp, I probably won't be able to figure that one out on my own - if you are willing to tell me how to do it, I can probably do it. They look fairly inexpensive. Today the voltage started at about 4.25 volts at 11:30 AM and right now it's at about 3.79 at nearly 5 PM, so I'm guessing that my thermistor increases its resistance as it heats up - Colorado sun can be intense. I figured that I would monitor it for a few weeks and see if it reports fairly consistently. I would normally try to keep the driveway at around 40 degrees F, so I was thinking that when the driveway falls to 40 degrees, I would check the temperature and set a rule for the pump to come on when the voltage is at or above that level and then have the pump turn off when the voltage falls below that voltage. I have no idea how to modify the driver you created - but it would be cool if I could get it to report temperature instead of voltage. Regardless, thank you for replying. This is all new territory for me!

muchu999 commented 3 years ago

In your case, an op-amp is probably overkill. In my case, the Fibaro would have changed what temperature the HRV was seeing and that would have caused the defrost cycle to be screwed...

So forget about it, all you need is to calibrate the voltage vs temperature. If you don't have the device info and it is under the driveway, that could be tricky.

If you know the relationship, there are probably a couple of options, I could give you some pointers to modify the driver or maybe write a rule that takes the voltage, convert it and write it to a virtual device.

pauldankers commented 3 years ago

Thanks, Chris, I will track this for a while and let you know once I have some (hopefully) reliable data. It's so kind of you to take time for this!

muchu999 commented 3 years ago

If it were me I would probably drill a small hole in a good spot in the driveway and measure the temperature with an instant read digital kitchen temperature probe....

pauldankers commented 3 years ago

Hey Chris, I hate to pester you, but it seems that Hubitat is now including a driver with the latest update. I foolishly deleted my device and the drivers you created, did the update, then reinstalled my device and now I am not getting any voltage reporting on either of the sensors. I wanted to roll back to use your driver - and although it will let me select your driver for the device, all of the child devices are still using the stock ones from Hubitat. I have contacted their support team, but they haven't written back to me. Do you have any suggestions?

muchu999 commented 3 years ago

The simplest/cleanest solution would be to Z-wave exclude and then include the implant. Can you do that?

pauldankers commented 3 years ago

Hi Chris,

Thank you, I did try this. I used the z-wave remove feature. Then I reset the device and waited for it to restart. Then I unplugged it, waited and plugged it back in. Then I added it again. It automatically picks up the built-in driver. I can then change it to your driver, but by then, it has already installed the built-in drivers for the child devices and the option is greyed out, so I can’t change the child devices to your child device drivers. I suspect that this is the problem - but I don’t see any way to force Hubitat to use your driver instead of the system’s driver. When I click the “refresh” button for the analog inputs, I get this error:

2020-08-25 12:01:57.410 pm error http://192.168.1.194/device/edit/389groovy.lang.MissingMethodException: No signature of method: user_driver_christi999_Fibaro_FGBS_222_Smart_Implant_465.componentRefresh() is applicable for argument types: (com.hubitat.app.DeviceWrapper) values: [Fibaro Smart Implant Analog In 1] (componentRefresh)

I am getting these log messages:

dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:05:20.383 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 3 has value 4.02 - ep=3 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 146], size:2, scaledSensorValue:4.02) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:05:20.378 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 4 has value 4.08 - ep=4 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 152], size:2, scaledSensorValue:4.08) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:04:50.385 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 7 has value 31.5 - ep=7 sp=1 null SensorMultilevelReport(precision:1, scale:0, sensorType:1, sensorValue:[1, 59], size:2, scaledSensorValue:31.5) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:04:20.373 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 4 has value 4.06 - ep=4 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 150], size:2, scaledSensorValue:4.06) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:04:20.369 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 3 has value 4.02 - ep=3 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 146], size:2, scaledSensorValue:4.02) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:03:50.359 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 7 has value 31.5 - ep=7 sp=1 null SensorMultilevelReport(precision:1, scale:0, sensorType:1, sensorValue:[1, 59], size:2, scaledSensorValue:31.5) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:03:20.374 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 3 has value 4.02 - ep=3 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 146], size:2, scaledSensorValue:4.02) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:03:20.369 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 4 has value 4.08 - ep=4 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 152], size:2, scaledSensorValue:4.08) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:02:50.368 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 7 has value 31.5 - ep=7 sp=1 null SensorMultilevelReport(precision:1, scale:0, sensorType:1, sensorValue:[1, 59], size:2, scaledSensorValue:31.5) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:02:20.380 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 4 has value 4.08 - ep=4 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 152], size:2, scaledSensorValue:4.08) } dev:389 http://192.168.1.194/logs#dev3892020-08-25 12:02:20.375 pm debug http://192.168.1.194/device/edit/389{Sensor @ endpoint 3 has value 4.02 - ep=3 sp=1 null SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 146], size:2, scaledSensorValue:4.02) }

On Aug 25, 2020, at 5:34 AM, muchu999 notifications@github.com wrote:

The simplest/cleanest solution would be to Z-wave exclude and then include the implant. Can you do that?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/muchu999/Hubitat/issues/4#issuecomment-679970620, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQNNYS2LMKYX37LXSSVWFJ3SCOOVZANCNFSM4P3TL65A.

muchu999 commented 3 years ago

I see... I was going to tell you to remove the child devices but the option is greyed out when I tried on my system... The only solution I can see is to add a "reset' button that would re-initialize the driver to its original state. I might have something for tomorrow...

pauldankers commented 3 years ago

Chris, you are such a remarkable person to put time into this for a complete stranger. Regardless, thank you for looking into it.

On Aug 25, 2020, at 1:14 PM, muchu999 notifications@github.com wrote:

I see... I was going to tell you to remove the child devices but the option is greyed out when I tried on my system... The only solution I can see is to add a "reset' button that would re-initialize the driver to its original state. I might have something for tomorrow...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/muchu999/Hubitat/issues/4#issuecomment-680218844, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQNNYS7X5HTPEYYJZ7ZKRQTSCQEQBANCNFSM4P3TL65A.

muchu999 commented 3 years ago

No sweat...I made the changes in a GitHub branch called "reinstall", only the file "Fibaro FBGS-222 Smart Implant.groovy" changed. In the device, under the new "reinstall" command you select "yes" and then press "reinstall". Let me know how that goes.

pauldankers commented 3 years ago

Chris, you miracle worker! You did it! I really don’t know why Hubitat didn’t just use your driver. Beside the fact that their driver doesn’t work, it certainly doesn’t have all of the functionality that yours has. I don’t know if you even want them to use your driver, but if there is a way for me to suggest this or vote for it, I’m happy to do so. I’m also happy to contribute to the cost of maintaining this driver if you tell me how - I honestly do not even know what would be a fair contribution on my part, so please don’t hesitate to be honest with me. I’m just a hard working musician - I’m not rich, but I don’t expect a free ride. (Especially if there is a chance that you can add functionality that would allow me to convert the analog voltages to temperatures - which, I would guess would need an additional function that allows you to invert the relationship between voltage and temperature. In most of the documentation I have read, the thermistors seem to increase in resistance as they get colder, but my thermistors increase in resistance as they get warmer, so the voltage rises as the driveway cools and the voltage falls when the driveway gets hot.) I can make this work without all that, since I just need to create a rule to turn on a switch when the voltage goes above a set point - and it is awesome that I will be able to see if the heat is on or off for the driveway, but it would be helpful to see what the temperature is.)

I also really wonder if there might be a market for controls for radiant heat systems like mine. Regular furnaces have great smart thermostats like Ecobee and Nest (that probably spy on you) but they really don’t work well with radiant heat. There is a company (in Vermont? It’s called Radiantec if you want to look it up) that does a lot of Radiant heat business and they might be interested in this as a smart alternative to the “dumb” controls that they sell with their systems. Using the fibaro Smart Implant with Hubitat and light switches to control radiant heating/cooling zones has an elegant simplicity. Two big advantages over the system they currently sell with their kits: With this system, you’re not dependent on the internet for it to work, but when the internet is up, you can monitor it from anywhere. You could even program it to adjust according to the weather.

Regardless, THANK YOU!

~Paul Dankers

On Aug 25, 2020, at 4:13 PM, muchu999 notifications@github.com wrote:

No sweat...I made the changes in a GitHub branch called "reinstall", only the file "Fibaro FBGS-222 Smart Implant.groovy" changed. In the device, under the new "reinstall" command you select "yes" and then press "reinstall". Let me know how that goes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/muchu999/Hubitat/issues/4#issuecomment-680295667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQNNYS42GYV55ZUHR3RMYTTSCQZQTANCNFSM4P3TL65A.

muchu999 commented 3 years ago

Glad it worked...I think Hubitat wants a version that is simple to use and exposes only a minimum functionality that works for most people. Mine exposes everything which makes it a bit complicated. I am sure Hubitat took a look at my driver to make theirs. Both can coexist separately depending on the type of user.

As far as using the Fibaro as thermostat... The problem is reliability, a dumb thermostat will never fail. Using something as complicated as Hubitat to control temperature when it is -30 deg outside is risky. I wrote an app to make my Z-Wave thermostat use remote temperature sensing to adjust heating/cooling. It failed 3 times in less than a year because the Hubitat Hub was partially crashed/improperly working. Not fun to wake-up with cold temperature in the house.

norburban commented 3 years ago

Hi Chris, I just came across this and read through the thread. I have a 10K Ohm thermistor for my inground pool. It's designed to be inserted into the PVC pipe between the pump and the filter. I simply want to remotely monitor the pool temp. I currently have the HE native drivers loaded and it's not seeing the analog probe. Next chance I get, I'll pull the drivers and install yours. Do I have to make a code change anywhere to have it see the analog probe connected to GND & IN2 ?

muchu999 commented 3 years ago

You just need to change the parameter "Input 2 - operating mode" to "analog input without internal pull-up" or "analog input with internal pull-up". I never investigated what the "internal pull-up" resistor value is or how it is implemented so you will have to do some experimentation with that one to see if/how it works with your thermistor without providing some voltage as you have it connected now.

Using the "without internal pull-up" mode, you will have to put some voltage on your thermistor, 12V would do, something like this (photocell here instead of thermistor, same principle) https://cdn.sparkfun.com//assets/parts/2/4/6/2/Photocell.jpg. You can then go the the analog child device, do a refresh and see what values you get. You can then implement an equation there to convert it to temperature...

muchu999 commented 3 years ago

I did some testing on my setup and in pull-up mode I measured 17.7Kohms pulled-up to 10volts so it should be fine to use as you described when you select "analog input with internal pull-up". The voltage at 75F (10Kohms) would be about 3.6V.

norburban commented 3 years ago

Thanks Chris. I removed the Smart Implant, added your drivers & re-added the Implant. That worked as expected. I'm seeing the implant's internal temp, but nothing is registering on IN2. It's setup as instructed. I powered the device, no change. I'm running the implant using 12V 1.25A. Thoughts?

muchu999 commented 3 years ago

The analog child devices are always suppose to be working, irrespective of configuration...

-"but nothing is registering on IN2": What do you mean, does it show 0v? -Are you certain you are using my driver, did you perform a "re-install"? -How did you configure IN2? -Enable debug logging, then "save preferences" -Go to the analog child devices, do a "refresh" (both for IN1 and IN2) -Post the resulting log output.

norburban commented 3 years ago

Hi Chris, Thanks for the quick response on a Friday, no less! Rookie alert! It's not your driver. I just read the documentation, starting over. I'll let you know how it goes!

muchu999 commented 3 years ago

In the Fibaro smart implant device page

-Change the "Type" to "Fibaro FGBS-222 Smart Implant", it is at the end of the list in the "User" section. -Press "save preferences" then press "re-install".

Then

-Configure "input 2- Operating mode" to "analog input with internal pull-up..." -Press save preferences -Press "configure" -Wait 45 seconds for configuration to be done.

norburban commented 3 years ago

You answered before I could edit my response. I did as you instructed and am now reading 3.65v. I see I have an opportunity to enter a temperature equation. Is there a resource you could point me to that explains it?

norburban commented 3 years ago

I've been searching for formulas. Would you have the variable names for the values in the sample equation? I believe the implant is sending 12v to the probe.

dev:772021-06-18 07:44:08.923 pm debug{Sensor @ endpoint 4 has value 3.78 - ep=4 Pool Sensor - Analog Input 2 SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 122], size:2, scaledSensorValue:3.78) } dev:772021-06-18 07:43:08.912 pm debug{Sensor @ endpoint 4 has value 3.78 - ep=4 Pool Sensor - Analog Input 2 SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 122], size:2, scaledSensorValue:3.78) } dev:772021-06-18 07:42:08.905 pm debug{Sensor @ endpoint 4 has value 3.78 - ep=4 Pool Sensor - Analog Input 2 SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 122], size:2, scaledSensorValue:3.78) } dev:772021-06-18 07:41:08.859 pm debug{Sensor @ endpoint 4 has value 3.78 - ep=4 Pool Sensor - Analog Input 2 SensorMultilevelReport(precision:2, scale:0, sensorType:15, sensorValue:[1, 122], size:2, scaledSensorValue:3.78) }

muchu999 commented 3 years ago

The sample equation is from my Venmar HRV and the temperature to voltage relationship is linear, I calibrated it using 3 points, more of an active temperature sensor than a thermistor. It probably does not apply to your situation.

Look here for thermistor equations https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation. The equation below (in degF) should probably get you close for the limited temperature range you are going to use (copy and paste in the temperature equation entry, then save preferences in the analog child device):

round(((1/(log(17000/10000rawVoltage/(10-rawVoltage))/3950+1/(25+273.15))-273.15)9/5+32)*100)/100

-17000 is the pull-up resistor value (I measured it more accurately this morning, along with the 10v) -10 is the pull-up voltage value (10V, implant supply voltage must be 12V or higher) -3950 is a constant associated with the thermistor -10000 is the nominal thermistor resistance (10K thermistor) -25 is the temperature corresponding to the thermistor nominal resistance (10K at 25degC in this case)

3.78V would get you 75.7degF 3.65V would get you 77.9degF

The best thing would be to get your thermistor specifications/curves and then adjust the thermistor constants accordingly (the 3950 and 25), you can also calibrate it at 2 or 3 points and adjust the curve until it fits those points.

norburban commented 3 years ago

I have a multimeter, how do I measure the pull-up resistor value? I created a spreadsheet to play with the values. My sensor is a 7790, which to me seems it would be the 'constant' as opposed to 3950 in your example. What's strange is that I have it in a ice bath and the implant is measuring 6.65 volts. I tested the voltage into the implant, it's 12.15v.

muchu999 commented 3 years ago

6.65V gives me 31.9 degF with the equation I gave you, that's pretty darn close to 32degF (freezing point).

I measured the pull up resistance by measuring the voltage at 3 points using 3 resistors with known values (100K, 10K and 1K) and then calculating what the pull-up voltage and resistance should be to match those 3 values.

muchu999 commented 3 years ago

This link lists the beta value of the 7790 TS5L Linear NTC pool sensor to be beta=3977 (instead of the generic beta=3950 I gave you) . With that beta value, 6.65V gives 32.15degF.

7790 is just a model number, nothing to do with the beta value. I am a bit confused by the "linear" part of the part name though., Linear thermistors are usually PTC (positive temperature coeff.) and their curve is not really linear but the part description says linear NTC, maybe just some marketing stuff.

norburban commented 3 years ago

It's linear alright - using the equation you provided, I got a match on 10 data points with the following. Chart is V vs F Pull Res: 16500 Pull Volt: 12.15 Constant: 1700 Nominal Res: 10000 Nominal Temp C: 25

image

norburban commented 3 years ago

With the equation in place, the logs still only report the voltage. Do you know how I can get the calculated temperature to show. I haven't yet checked if I can see it in a dashboard.

muchu999 commented 3 years ago

It can appear linear when the temperature interval is short... You didn't include the measurement at freezing point (32degF, 6.65V)... With the pull-up voltage of 10.0V (you can measure it with your meter on IN2 with nothing attached) and a 17K pullup, and beta = 3977 the equation results in the green line: Capture1

Changing just the pullup to 16.5K (makes sense that tolerance from implant to implant could be as much as 5%, the 10V is probably generated by an internal voltage reference, usually quite accurate and the reason why at least 12V supply is needed) I get this: Capture2

This is the rest of the curve for those values (10V, 16.5K,B=3977), notice the 6.65V you measured for the freezing point (32degF) fits perfectly with this non-linear curve: Capture3

The debug logs are only for debugging and I never needed to log temperature.... The child device behaves just like any other temperature device so you can use it in the dashboard if you want. The calculated temperature shows up in the upper right portion of the child device page and in the device event log. I think you could add it to the debug log relatively easily.

norburban commented 3 years ago

Hmm.... my graph doesn't look like that. I must have a mistake in my Excel formula.

muchu999 commented 3 years ago

Note that the "log" function in the formula is the natural logarithm, ln() in excel

norburban commented 3 years ago

DOH - I had this: =ROUND(((1/(LOG(PullRes/NomRes[Raw Volt]/(PullVolt-[Raw Volt]))/Const+1/(NomTemp+273.15))-273.15)9/5+32)*100,2)/100

muchu999 commented 3 years ago

I made the same mistake at first...

norburban commented 3 years ago

Brilliant! Now I got it. So, now I'm going to plug it into HE and see what I get. Thanks for your help! I was wracking my brains yesterday.

muchu999 commented 3 years ago

Great... I could see we didn't seem to agree yesterday... Good luck

norburban commented 3 years ago

All good on the HE!! I'm going to publish this solution once I package it up and install it by the pool equipment. No one has used this setup from what I found. I was thinking of adding an actuator on the valve that switches 'water in' from the skimmer to pull from the drains. I think that may require 24v though. It's my next project.

norburban commented 3 years ago

My actuator, Goldline GVA-24 requires 24VAC and has 3 wires. Any ideas how I might do that? It has 3, ground, ON1 and ON2. I'll have to research how to utilize the implant to control that.

muchu999 commented 3 years ago

I read that this Jandy Valve was compatible so wiring must be similar. The manual shows how to connect it, you would basically need a 12V DC SPDT/DPDT relay (e.g. relay) to switch the 24VAC between the red and white wire (ON1 and ON2, not sure which is which). The relay coil just needs to be connected one side to ground and one side to the implant OUT1, the other side of OUT1 connects to +12V DC.

norburban commented 3 years ago

You’re awesome… so helpful! Thank you.