1-wire DS18B20 change resolution - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Hardware (https://forum.logicmachine.net/forumdisplay.php?fid=12) +--- Thread: 1-wire DS18B20 change resolution (/showthread.php?tid=301) |
1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 Is it possible to change the resolution from a 1-wire DS18B20 to 12 bits with a LogicMachine, like in this topic: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/ And i like to change the send delta to a lower value, now the range starts with 0.2 RE: 1-wire DS18B20 change resolution - admin - 17.05.2016 You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time. RE: 1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 (17.05.2016, 08:02)admin Wrote: You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time. Oke, but i like to have my values with 0,1 precision. With a arduino and the same type sensor i can do this (theoretical ), but connected to the LM4 it gives strange results: see attached picture. RE: 1-wire DS18B20 change resolution - buuuudzik - 17.05.2016 (17.05.2016, 08:10)gjniewenhuijse Wrote:(17.05.2016, 08:02)admin Wrote: You can read 12-bit result via a script but there's no big point in doing that. Even though theoretical resolution is better the resulting value won't be stable due to how the measurement works. The better approach is to do over-sampling by averaging the resulting values over a specific period of time. You can add an event-based script which repeat this value with custom precision or you can use custom values for visualisation if this is only for visualisation purposes. RE: 1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 Oke, i can do a reading and custom precision with: Code: require('ow') I know its theoretical, but can i change the precision by lm4 or do i need to connect them to a arduino and execute the following code: Code: ds.search(addr); // address on 1wire bus RE: 1-wire DS18B20 change resolution - admin - 17.05.2016 You don't need to change the precision, reading "temperature" property will read the 12-bit value, by default LM uses 10-bit value ("temperature10" property). RE: 1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 (17.05.2016, 08:45)admin Wrote: You don't need to change the precision, reading "temperature" property will read the 12-bit value, by default LM uses 10-bit value ("temperature10" property). perfect.. thanks RE: 1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 something like this? resident script every 60 seconds: Code: -- better to save the last 5 readings and avg them and then write to bus user_library nit_measurement: Code: avgMax = 5 RE: 1-wire DS18B20 change resolution - admin - 17.05.2016 Here's a function you can use to calculate the average, this version will keep last count values and will returnt the average for every insert: Code: function avg(store, count, value) And here's how you can use it: Code: if not store then You can add an extra counter in your resident script if you want to send a new value for each X samples. RE: 1-wire DS18B20 change resolution - gjniewenhuijse - 17.05.2016 great! |