Closed tanoko closed 4 years ago
Recently, I repeated tests of the temperature sensor DS18S20 with Tasmota V. 8.3.1. Here the plot with the pre-compiled version of tasmota.bin:
Then, I modified the file xsns_05_ds18x20.ino as described above and compiled the tasmota.bin using PlatformIO. The result may be seen on the plot below made under similar conditions as the first one:
Here the output of Status 2 on the console: 08:54:47 MQT: stat/tasmota_08DE86/STATUS2 = {"StatusFWR":{"Version":"8.3.1(tasmota)","BuildDateTime":"2020-07-03T10:58:41","Boot":31,"Core":"2_7_1","SDK":"2.2.2-dev(38a443e)","Hardware":"ESP8266EX","CR":"394/699"}}
Cool, Thanks for sharing. Please help us and provide a PR. Thanks.
PROBLEM DESCRIPTION
A clear and concise description of what the problem is. This problem was already addressed in issue #5375, which has been closed though user wecl wrote: 'But i didn't test the calculation when the temperature is lower than 0 degrees.'. I used a mix of sensors DS18S20 and DS18B20 to monitor temperatures in a refrigerator and observed strange zigzag shaped plots from DS18S20 sensor placed in the freezer (negative Centigrade). Checking the problem with different GPIO numbers and different modules (D1 mini, ESP-12F, ESP-3M) brought no difference. This behavior is illustrated on plots made with a DS18S20 and DS18B20 placed at the same point when crossing the 0°C mark:
Then I tried to analyze the code of the file xsns_05_ds18x20.ino and found out, that this part of the code must cause the problem: case DS18S20_CHIPID: { if (data[1] > 0x80) { data[0] = (~data[0]) +1; sign = -1; // App-Note fix possible sign error } float temp9 = (float)(data[0] >> 1) * sign; ds18x20_sensor[index].temperature = ConvertTemp((temp9 - 0.25) + ((16.0 - data[6]) / 16.0)); ds18x20_sensor[index].valid = SENSOR_MAX_MISS; return true; }
Instead of the unsigned variable temp9 I used a signed one, which I named tempS and replaced this part of the code by: case DS18S20_CHIPID: { int16_t tempS = (((data[1] << 8) | (data[0] & 0xFE)) << 3) | ((0x10 - data[6]) & 0x0F); ds18x20_sensor[index].temperature = ConvertTemp(tempS * 0.0625 - 0.250); ds18x20_sensor[index].valid = SENSOR_MAX_MISS; return true; }
The result you can see on these plots:
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Backlog Template; Module; GPIO 255
: 18:45:59 MQT: stat/tasmota/RESULT = {"NAME":"Fridge","GPIO":[0,148,56,149,4,0,0,0,5,0,6,0,0],"FLAG":0,"BASE":18} 18:45:59 MQT: stat/tasmota/RESULT = {"Module":{"0":"Fridge"}} 18:46:00 MQT: stat/tasmota/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"148":"Serial Tx"},"GPIO2":{"56":"Led1i"},"GPIO3":{"149":"Serial Rx"},"GPIO4":{"4":"DS18x20"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"5":"I2C SCL"},"GPIO13":{"0":"None"},"GPIO14":{"6":"I2C SDA"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"}} Configuration output here:weblog 4
for more debug information)