Ian Posted October 16, 2024 Posted October 16, 2024 Hi All, I want to link my existing underfloor heating NTC temperature sensor to an Add-On, I have followed the NTC connection instructions and as this is connected to an analogue input I get a % displayed value, is it possible to convert this % value into Centigrade so I can automate based on temperature. Many thanks Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Members thgoebel Posted October 16, 2024 Members Posted October 16, 2024 (edited) The script library, accessible with every generation 2 and 3 Shelly, lists a specific script to handle NTC temperature sensors: Just click ‚Library‘ in menu tab ‚Scripts‘. And use the WebUI for entering the configuration menu. Edited October 16, 2024 by thgoebel Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Ian Posted October 16, 2024 Author Posted October 16, 2024 Thanks thgoebel, I've changed the peripheral input from analogue to voltage and installed the code, daft question, where does it show the conversion of voltage to temperature? I've not made any changes to the script, just directly imported it. Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Members thgoebel Posted October 16, 2024 Members Posted October 16, 2024 If I understand the script correctly, the calculated temperature is delivered in a variable „T“. You‘ll have to print the variable to the debug console or transfer it to another function. Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Ian Posted October 16, 2024 Author Posted October 16, 2024 3 minutes ago, thgoebel said: If I understand the script correctly, the calculated temperature is delivered in a variable „T“. You‘ll have to print the variable to the debug console or transfer it to another function. Ah, I fear this may be outside of my very limited knowledge. Really appreciate your help here, off to google and YouTube again lol Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Ian Posted October 17, 2024 Author Posted October 17, 2024 (edited) I've done a fair bit of searching and this has come up a lot before but without any satisfactory resolution for basic shelly users. The common scenario is that a Shelly1PM and Add-On are bought together to replace existing Under Floor Heating controls which have floor embedded NTC temperature sensors, unfortunately, although the Add-On specifies NTC compatibility, this only gives a displayed output of either a voltage or percentage when connected, NOT temperature straight out of the box, which is a massive disappointment as NTC thermistors only measure temperature! I'll add to the Shelly 'wish list' the ability to select 'NTC thermistor' from the peripheral list. Hope this helps others. Edited October 17, 2024 by Ian Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Members thgoebel Posted October 17, 2024 Members Posted October 17, 2024 Try to add more clarity to the NTC script in the library: (a) At first, one has to read (and possibly understand) the code of the script: // SH Coefficient Calculator // https://rusefi.com/Steinhart-Hart.html // // Thermistor wiki page // https://en.wikipedia.org/wiki/Thermistor /**************** START CHANGE HERE ****************/ let CONFIG = { scanInterval: 30, //secs, this will run a timer for every 30 seconds, that will fetch the voltage voltmeterID: 100, //the ID of the voltmeter - When we install the add on, the device will define this number /** * Applies some math on the voltage and returns the result. This function is called every time the voltage is measured * @param {Number} voltage The current measured voltage * @returns The temperature based on the voltage */ calcTemp: function (voltage) { const constVoltage = 10; const R1 = 10000; const A = 0.0011252791214670555; const B = 0.00023471763897744966; const C = 8.563489971304025e-8; const R2 = R1 * (voltage / (constVoltage - voltage)); const logR2 = Math.log(R2); let T = 1.0 / (A + (B + C * logR2 * logR2) * logR2); T = T - 273.15; // Celcius //T = (T - 273.15) * 9/5 + 32; // Fahrenheit return T; }, /** * This function is called every time when a temperature is read * @param {Number} temperature The current calculated temperature */ onTempReading: function (temperature) { //if the temperature is greater than 20.5 turn the first output off if (temperature > 20.5) { // Shelly.call("Switch.Set", { // id: 0, // on: false // }); } //if the temperature is less than 15, turn the first output on else if (temperature < 15) { // Shelly.call("Switch.Set", { // id: 0, // on: true // }); } }, }; /**************** STOP CHANGE HERE ****************/ function fetchVoltage() { //Fetch the voltmeter component const voltmeter = Shelly.getComponentStatus( "voltmeter:" + JSON.stringify(CONFIG.voltmeterID) ); //exit if can't find the component if (typeof voltmeter === "undefined" || voltmeter === null) { console.log("Can't find the voltmeter component"); return; } const voltage = voltmeter["voltage"]; //exit if can't read the voltage if (typeof voltage !== "number") { console.log("can't read the voltage or it is NaN"); return; } //get the temperature based on the voltage const temp = CONFIG.calcTemp(voltage); //exit if the temp isn't calculated correctly if (typeof temp !== "number") { console.log("Something went wrong when calculating the temperature"); return; } if (typeof CONFIG.onTempReading === "function") { CONFIG.onTempReading(temp); } } //init the script function init() { //start the timer Timer.set(CONFIG.scanInterval * 1000, true, fetchVoltage); //fetch the voltage at run fetchVoltage(); } init(); Above the complete script. (b) One function is remarkable, cause it gives an answer to @Ian 's question: /** * This function is called every time when a temperature is read * @param {Number} temperature The current calculated temperature */ onTempReading: function (temperature) { //if the temperature is greater than 20.5 turn the first output off if (temperature > 20.5) { // Shelly.call("Switch.Set", { // id: 0, // on: false // }); } //if the temperature is less than 15, turn the first output on else if (temperature < 15) { // Shelly.call("Switch.Set", { // id: 0, // on: true // }); } }, }; We learn that a switching function is implemented: Above 20,5 °C the relay of the hosting Shelly device is switches off. Below 15 °C, the relay is switches on! These limits can be amended at discretion. Replacing this function by another is even possible. And - may be - some help of forum's members will be available... Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Ian Posted October 17, 2024 Author Posted October 17, 2024 Hi, Thanks for the expanded explanation, as a really basic user, all I'm after is the device to show a temperature from the NTC in degrees, but I do appreciate the level of skill and expertise in compiling the script and the time taken to explain it. Ian Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Andyh747 Posted October 25, 2024 Posted October 25, 2024 I'm in the same boat as you @Ian and have been unable to get a simple temperature readout from the NTC thermistor in the floor. Like many systems installed these electric underfloor systems usually have NTC thermistors for temperature measurement. Have you got any further with this? It seems odd for the addon to support NTC connection as outlined in the wiring diagram for the addon yet not be able to output a displayed temperature. Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
GRTman Posted December 25, 2024 Posted December 25, 2024 I've got the same problem. What is the easiest and least technical way to interface a NTC thermistor to the Plus Add-on. I don't mind if it uses a voltage reading - but what is the relationship between voltage and temperature. Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
GRTman Posted December 26, 2024 Posted December 26, 2024 When I try to implement the code above, I get the attached error message. What am I doing wrong?? Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Heinz Posted January 9 Posted January 9 in order to really know what is happening and what the error is. Please directly on the device with the IP address via the Browser. Go the the script section and enable the debug mode. here you should get more information as to what the issue could be Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Heinz Posted January 9 Posted January 9 I tested the code i did not get the same error you did you should see something like this Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Stephane tuffier Posted January 14 Posted January 14 Dear all, After following the instructions above and some further modifications, I managed to get the calculated temperature on my dashboard: I will detail the procedure I followed to achieved that. Best, Stephane 1 Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Stephane tuffier Posted January 15 Posted January 15 (edited) Here are the steps I followed: Check Connections: Ensure that the Shelly 1 Gen 3 and the add-on are properly connected. If the NTC thermistor is recognized and configured as a voltmeter, you should see the voltage value reported by the Shelly 1. Also, make sure your computer is on the same Wi-Fi network as the Shelly 1. Find Voltmeter ID: To find the voltmeter ID, go to Shelly 1 -> Charts. The voltmeter data will be displayed here with an ID in parentheses (e.g., Voltmeter (100)). Create a Virtual Component: Create a virtual component for the Shelly 1 to report the temperature. In the Shelly 1 menu, click on the virtual component menu -> Components -> Create a virtual component. In the creation menu, name the temperature you want to measure, select the number type, and fill out the required values and units. I chose 1, 31, 5, and 16 for the minimum, maximum, steps, and default value, respectively. Note the ID of the component, which should look like number:20X (this can vary from 200 to 299). Create a Group for the Virtual Component: Create a group to display the temperature value. Name the group, check the virtual component you created, and toggle the "extract virtual group as device" option. This will display the group on the dashboard. Set Up the Script: Connect directly to the Shelly 1 by entering its IP address in a browser (found in the device parameters, e.g., 192.168.x.xx). Go to the scripts menu and import the RTC script from the library. Make the following modifications to the script: Line 10: Ensure the voltmeterID matches the one from step 2, and replace it if needed. Add the following lines after line 87 inside the fetchVoltage() function (see full script here https://gist.github.com/ste-tuf/10e892af67a93578e11e32e32199d917) : // Print voltage and temperature to the console console.log("Voltage: " + voltage + ", Temperature: " + temp); // Update the temperature virtual component let virt_temp = Virtual.getHandle("number:200"); // Change the text wiht the ID of the virtual component virt_temp.setValue(parseFloat(temp.toFixed(1))); Replace number:200 in Virtual.getHandle("number:200") with your virtual temperature component ID. Save the script and launch it. You should now see the current voltage and the calculated temperature in the console. The virtual component value will also be updated if everything went well. Edited January 15 by Stephane tuffier Improving and typo mistakes 1 Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Heinz Posted January 15 Posted January 15 awsome thanks for the effort 1 Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Maw Posted May 9 Posted May 9 Thanks a lot for this - it helps and I am able to get the converted temperature reading, but I am not able to use this as an input for a room thermostat (like you did?) How did you manage to show the virtual component as a temperature sensor? For me it just shows as the bare number (or slider...) but I don't get to see the termometer icon and I can't select the virtual component as a sensor for the thermostat. Thanks. Quote Translate Revert translation? English (American) French German Italian Polish Portuguese (European) Spanish
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.