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.
17.05.2016, 08:10 (This post was last modified: 17.05.2016, 08:13 by gjniewenhuijse.)
(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.
(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, but connected to the LM4 it gives strange results: see attached picture.
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.
17.05.2016, 08:38 (This post was last modified: 17.05.2016, 08:39 by gjniewenhuijse.)
Oke, i can do a reading and custom precision with:
Code:
require('ow')
value = ow.readfile('SENSORID', 'temperature', true) -- third argument will force a new conversion
log( round(value,1) )
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
if (addr[0] == DS18B20) // check we are really using a DS18B20
{
ds.reset(); // rest 1-Wire
ds.select(addr); // select DS18B20
ds.write(0x4E); // write on scratchPad
ds.write(0x00); // User byte 0 - Unused
ds.write(0x00); // User byte 1 - Unused
ds.write(0x7F); // set up en 12 bits (0x7F)
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).
(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).
17.05.2016, 11:43 (This post was last modified: 17.05.2016, 11:46 by gjniewenhuijse.)
something like this?
resident script every 60 seconds:
Code:
-- better to save the last 5 readings and avg them and then write to bus
require('ow')
require('user.nit_measurements')
-- second argument temperature10 (10-bit value)
-- third argument will force a new conversion
readValue = ow.readfile('28.690E0A070000', 'temperature', true)
function measValue (iMax,iValue)
-- init value array
if not measCount then
if iMax then
avgMax = iMax
end
measCount = 0
measValues = {}
for i=1,avgMax do
measValues[i] = iValue
end
end
measCount = measCount + 1
-- set values
for i=avgMax,2,-1 do
measValues[i] = measValues[i-1]
end
measValues[1] = iValue
--log(measValues)
-- reset counter
if (measCount == avgMax) then
measCount = 0
end
rValue = 0
for i=1,avgMax do
rValue = rValue + measValues[i]
end
rValue = rValue / avgMax
return rValue
end