Closed MaxineMuster closed 2 months ago
Soldered sensor on BL602. Looks fine, now we need a way to publish this to mqtt or maybe better a flag to consider this temperature as device temperature. Heated with hair dryer:
And there is a bug in decimal formating, leading zero i omitted
Info:CFG:DS1820 - asked for conversion - Pin 1
Info:CFG:DS1820 - Pin=1 temp=+36.6
Info:CFG:DS1820 - High=2 Low=65 Val=577 Tc=3606
animated gif
I've merged also SDK changes, I can look into assigning channels, I may also clean the code up a bit. Note that this PR is now an orphan, as I merged changes separately.
@openshwprojects : If you would look in to the channel/mqtt part that would be great.
@divadiow : Did I see it right, that temperature is "lost" quite some time on BK7231N? Could you check the output in log if DS1820 isn't found (e.g. assign a "wrong" pin) - it should give some information about the timing then. BTW: which pin did you use? I had to use Rx or Tx (Pin 10/11) since PWM pins didn't work.
@MaxineMuster yes. Lost to 0 degrees and jumping around a bit ~30-50. Will check logs in a bit.
I am using this device so I'm fixed to P26 https://www.elektroda.com/rtvforum/topic4062365.html
I have a separate DS probe coming but not for a week. But maybe the chip is in the probe of the TYTE and I can just use it on dev board...
Or chip is buried in the black 3.5mm jack connector on PCB
this is with P26 correctly set. TC=6 is when it drops to 0degrees
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+31.12
Info:CFG:DS1820 - High=1 Low=242 Val=498 Tc=3112
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.12
Info:CFG:DS1820 - High=1 Low=114 Val=370 Tc=2312
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.12
Info:CFG:DS1820 - High=1 Low=114 Val=370 Tc=2312
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.12
Info:CFG:DS1820 - High=1 Low=114 Val=370 Tc=2312
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.12
Info:CFG:DS1820 - High=1 Low=114 Val=370 Tc=2312
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+31.12
Info:CFG:DS1820 - High=1 Low=242 Val=498 Tc=3112
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+55.18
Info:CFG:DS1820 - High=3 Low=115 Val=883 Tc=5518
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+31.18
Info:CFG:DS1820 - High=1 Low=243 Val=499 Tc=3118
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+55.18
Info:CFG:DS1820 - High=3 Low=115 Val=883 Tc=5518
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+23.18
Info:CFG:DS1820 - High=1 Low=115 Val=371 Tc=2318
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
That might be a timing issue. Could you please disconnect the sensor? Log should give some hint how long 100.000 of the own "us" last in ms.
I would expect that it differs from the expected 100ms ...
Thanks!
this if wrong pin.
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
Info:CFG:DS1820 - asked for conversion - Pin 20
probe unplugged:
20 - usleepds(50000) took 72 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 74 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 70 ms
Error:CFG:DS1820 - usleepds(100000) took 140 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.714285
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 72 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 130 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.769230
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 72 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 66 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 70 ms
Error:CFG:DS1820 - usleepds(100000) took 140 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.714285
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 70 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 72 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 72 ms
Error:CFG:DS1820 - usleepds(100000) took 138 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.724637
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 66 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 70 ms
Error:CFG:DS1820 - usleepds(100000) took 142 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.704225
Error:CFG:DS1820 - Pin=26 -- Reset failed
Error:CFG:DS1820 - usleepds(50000) took 68 ms
Error:CFG:DS1820 - usleepds(100000) took 132 ms
Error:CFG:usleepds duration divergates - proposed factor to adjust usleepds 0.757575
Error:CFG:DS1820 - Pin=
Could you try to compile a version with the number of "nop-lines" reduced to 4 or 5 ?
Maybe using theese nop-lines isn't really as portable as I thought and differs between different modules.
I don't have a scope, so I can't see the actual timing, but I suspect it's not as it should be.
I think that PowerSave should be disabled and loops should be unrolled for the best precision
Also, divadiow, you have DS1820, not DS18B20?
Also, divadiow, you have DS1820, not DS18B20?
my assumption was DS18B20 but I only have the TYTE-D1 boot log as an indicator at present.
[01-01 18:12:28 TUYA Err][lr:0x5adc9] ds18b20 reset fail
[01-01 18:12:28 TUYA Err][lr:0x5adc9] ds18b20 reset fail
After seeing this comment in the reviews for the single probe I bought this morning from Ali, I did wonder about doing the same to check the sensor in the TYTE-D1 to see if it's genuine and what model exactly.
I think that PowerSave should be disabled
damn. forgot to take powersave 1 into account. switched to powersave 0.
stability is improved with powersave 0 but it does drop to 0 degrees occasionally.
- Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.6
Info:CFG:DS1820 - High=255 Low=255 Val=1 Tc=6
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-3939.75
Info:CFG:DS1820 - High=9 Low=196 Val=63036 Tc=393975
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+30.25
Info:CFG:DS1820 - High=1 Low=228 Val=484 Tc=3025
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+30.25
Info:CFG:DS1820 - High=1 Low=228 Val=484 Tc=3025
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+29.25
Info:CFG:DS1820 - High=1 Low=212 Val=468 Tc=2925
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=-0.12
Info:CFG:DS1820 - High=255 Low=254 Val=2 Tc=12
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.25
Info:CFG:DS1820 - High=1 Low=196 Val=452 Tc=2825
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.31
Info:CFG:DS1820 - High=1 Low=197 Val=453 Tc=2831
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.31
Info:CFG:DS1820 - High=1 Low=197 Val=453 Tc=2831
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.31
Info:CFG:DS1820 - High=1 Low=197 Val=453 Tc=2831
Info:CFG:DS1820 - asked for conversion - Pin 26
Error:CFG:DS1820 - Pin=26 -- Reset failed
Info:CFG:DS1820 - Pin=26 temp=+28.31
Info:CFG:DS1820 - High=1 Low=197 Val=453 Tc=2831
Info:CFG:DS1820 - asked for conversion - Pin 26
Info:CFG:DS1820 - Pin=26 temp=+28.31
Info:CFG:DS1820 - High=1 Low=197 Val=453 Tc=2831
Info:CFG:DS1820 - asked for conversion
or maybe a family code checker can be added to existing driver
// Read ROM address
uint8_t address[8];
if (ds18b20_read_rom(address)) {
printf("DS18B20 ROM Address: ");
for (int i = 0; i < 8; i++) {
printf("%02X ", address[i]);
}
printf("\n");
// Check family code
if (address[0] == 0x28) {
printf("This is a DS18B20 sensor.\n");
} else {
printf("This is not a DS18B20 sensor, family code is: %02X\n", address[0]);
}
} else {
printf("Failed to read DS18B20 ROM address.\n");
}
To reduce number of loops we can only "squeeze" the numbers to wait to fit e.g. in g given multiple of us. If we would use 5 us this would obviously reduce the number of loops by 5, but we have 3 timings which wouldn't fit in. Actually I use:
#define OWtimeA 6
#define OWtimeB 64
#define OWtimeC 60
#define OWtimeD 10
#define OWtimeE 9
#define OWtimeF 55
#define OWtimeG 0
#define OWtimeH 480
#define OWtimeI 70
#define OWtimeJ 410
So we would have to be "inprecise" for A (6), B (64) and E (9) if we would just try the "next 5us value) or maybe need to introduce a second base with 3us for A and E.
Regarding DS18X20 I don't think we should /need to care. Maybe I can send a "set 9 bit resolution" command to make sure the conversion is the fastest we can get. But since we request if conversion is done before asking for the results, this should be no problem. So I am sticking to my best guess that the "sleeps" are not matching hence we simply measure at the wrong time...
Made a new PR for some fixes ...
Will need additional settings in SDK Makefiles: