Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read() hangs with MkrWiFi + MkrConnector Board #67

Closed
ToineSiebelink opened this issue Nov 4, 2021 · 66 comments
Closed

read() hangs with MkrWiFi + MkrConnector Board #67

ToineSiebelink opened this issue Nov 4, 2021 · 66 comments
Assignees
Labels
bug Something isn't working

Comments

@ToineSiebelink
Copy link

I have 6 DHT22 sensor connected to a WifiMkr1010 Board (sensors connected via a MKR Connector Carrier board on D0-D5)
Until recently I used DHTStable library (1.0.1) which worked fine but I ran onto a bug when outdoor temp dropped below 0c.

So I changed over to DHTNew (0.4.9) but unfortunaly it doesn't seem to work in combination with this board. I have another set of sensors on an ESP8266 (wemos Mini) board and they word firn with the DHTNew library.

On the MKR1010 it seems to hang on the read() method.
if I precede .read() with .setType(22) it does continue but reports unknown error -5 on the first attempt followed by unknown error -8 on subsequent attempts.

I have attached my sourcecode at the top you'll see do defined statement to enable DHTNEW and a basic debug option...

Any idea what could be wrong any suggestion to troubleshoot?

Thanks
main.zip
!

@RobTillaart RobTillaart self-assigned this Nov 4, 2021
@RobTillaart RobTillaart added the bug Something isn't working label Nov 4, 2021
@RobTillaart
Copy link
Owner

Hoi Toine,
Not familiar with the board, is it a 3V3 board?
Did you use pullups? If so which value?

You state the DHTStable worked except for negative temperatures. I assume you mean temp Celsius.

I will check later this evening, as I have another thing to fix too (in house not sw)

@RobTillaart
Copy link
Owner

@ToineSiebelink

The DHT11/22 low level protocol is quite sensitive for timing, spent quite some time on it.

Had a quick look and the DHTStable might still have a "negative bug" as the way temperature is calculated differs from DHTNew. So I made a patch for DHTStable to have the same math as DHTNew for temperature.

Can you please test this by replacing the read() function in the DHTStable library?

int DHTStable::read(uint8_t pin)
{
    // READ VALUES
    if (_disableIRQ) noInterrupts();
    int rv = _readSensor(pin, DHTLIB_DHT_WAKEUP);
    if (_disableIRQ) interrupts();
    if (rv != DHTLIB_OK)
    {
        _humidity    = DHTLIB_INVALID_VALUE;  // NaN prefered?
        _temperature = DHTLIB_INVALID_VALUE;  // NaN prefered?
        return rv; // propagate error value
    }
    // CONVERT AND STORE
    _humidity  = word(bits[0], bits[1]) * 0.1;
    int16_t t = ((_bits[2] & 0x7F) * 256 + _bits[3]);
    if (t == 0)
    {
      _temperature = 0.0;     // prevent -0.0;
    }
    else
    {
      _temperature = t * 0.1;
      if((_bits[2] & 0x80) == 0x80 )
      {
        _temperature = -_temperature;
      }
    }
    // TEST CHECKSUM
    uint8_t sum = bits[0] + bits[1] + bits[2] + bits[3];
    if (bits[4] != sum)
    {
        return DHTLIB_ERROR_CHECKSUM;
    }
    return DHTLIB_OK;
}

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 4, 2021 via email

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 4, 2021

OK, will wait for your results tomorrow.

// ik begrijp dat je ook NL spreekt, maar hou de discussies op GitHub bij voorkeur in EN.

@ToineSiebelink
Copy link
Author

agreed, we wont more Double Dutch :-)

@RobTillaart
Copy link
Owner

The DHTStable library is not out of support for bugs but new ideas and features will all be in the DHTNew .
As the negative temperature is probably a bug in the code for temperature so that will be fixed if the patch works.

Thereafter we can find out how to get DHTNEw to work on the MKr1010.
(do you know where to buy them for a fair price?
https://www.kiwi-electronics.nl/nl/arduino-mkr-wifi-1010-3852?search=1010 is out of stock

@RobTillaart
Copy link
Owner

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 6, 2021

Hi Rob, I tested DHTSTable with the proposed modified read() method using my freezer and confirm it now correctly reports temperatures below 0 Celcius :-D

I had to make some small corrections as you used _bits[] instead of just bits[] on a few lines. Here is the corrected method I have running now:

int DHTStable::read(uint8_t pin)
{
    // READ VALUES
    if (_disableIRQ) noInterrupts();
    int rv = _readSensor(pin, DHTLIB_DHT_WAKEUP);
    if (_disableIRQ) interrupts();
    if (rv != DHTLIB_OK)
    {
        _humidity    = DHTLIB_INVALID_VALUE;  // NaN prefered?
        _temperature = DHTLIB_INVALID_VALUE;  // NaN prefered?
        return rv; // propagate error value
    }
    // CONVERT AND STORE
    _humidity  = word(bits[0], bits[1]) * 0.1;
    int16_t t = ((bits[2] & 0x7F) * 256 + bits[3]);
    if (t == 0)
    {
      _temperature = 0.0;     // prevent -0.0;
    }
    else
    {
      _temperature = t * 0.1;
      if((bits[2] & 0x80) == 0x80 )
      {
        _temperature = -_temperature;
      }
    }
    // TEST CHECKSUM
    uint8_t sum = bits[0] + bits[1] + bits[2] + bits[3];
    if (bits[4] != sum)
    {
        return DHTLIB_ERROR_CHECKSUM;
    }
    return DHTLIB_OK;
}

(added code tags for syntax highlighting)

@RobTillaart
Copy link
Owner

Thank you for testing, I will create a new release of it this weekend.
The bits and _bits , yes a hasty copy / paste action without testing but you figured it out. well done!
(I try to use _var for private and protected vars but I am not always consistent apparently :)

I will to give you credits in the code for your time (If you like)

@RobTillaart
Copy link
Owner

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 6, 2021

no problem!
I also went back to my main setup with Arduino MKR WiFi1010 board. I modified by code for easier and better switch between your 2 libraries and I tested on several pins, with and without MKR Connector Carrier board but to no avail. DHTNew hangs on read() while DHTStable,read22() successfully reads all 6 sensor I have attached.

If I use setType(22) I see several Timeout C and Timeout D messages but mainly 'waiting for read' until it fails.

I actually live in Ierland and order from Farnell.ie but a quick search for Dutch seller brought me here: https://www.robotshop.com/nl/nl/arduino-mkr-wifi-1010-schild.html?gclid=CjwKCAjwz5iMBhAEEiwAMEAwGLimOST3z9uRHgDC1zlAWWD3jinGGNFl1ZIXcZzM6FtUhC5hjkPDARoCjXAQAvD_BwE but I am not familiar with them...

Actually I see you found a cheaper option already

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 6, 2021

As we "saved the project" with the improved read, we should continue with fixing the DHTNew lib for Arduino MKR WiFi1010 board. (at least the read function is OK, it is definitely lower timing)

I will order one, so I can test to see what happens. Good to know which timeouts fail.
What is the clock freq of the Mkr1010?

Ireland, still on my list to visit - have seen pictures of Northern Ireland that were really beautiful (countryside) and the south west parts. The closest I came long ago was the island of Anglesey.

@ToineSiebelink
Copy link
Author

yep, moved here 20+ years ago, never regretted it :-) Still often visit my hometown of Breda though not too far from Gemert!

A Quick search on speed: Clock Speed | 32.768 kHz (RTC), 48 MHz
(see https://www.wia.io/things/arduino-mkr1010)

You think speed might be the issue?!

@RobTillaart
Copy link
Owner

Timeouts are based upon clock-speeds (it is just a bit bang protocol) and there is no uniform way to handle that in a neat way in the arduino world. E.g. there are different ways to get the clockspeed.

some places to tune: dhtnew.cpp

  • line 381 uint8_t count = 2; and set it to 1
  • line 343 + 349 set the waitfor timeout parameters to resp 80 and 100 but 70 and 90 are already high.

@ToineSiebelink
Copy link
Author

sorry Rob, tried that, no Joy, I went up to 90/110 even tried to double the original values 140/180 but stil the same response hanging on read() (with using setType()) and timeout C/D messages if I do set the type :-(

@RobTillaart
Copy link
Owner

FYI, I have merged the working read() into DHTSTable master.

@RobTillaart
Copy link
Owner

@ToineSiebelink
Do you use pullup resistors?
if so, which value?
What is the length of the wires? approx?

@ToineSiebelink
Copy link
Author

Hi Rob, I think the MKR1010 or the connector carrier board might have built in pull up resistors I am not sure.
Regarding the length of the cables. They vary from 1m to unknown but at least 6=7meters as I am using cabling the original connected wall thermostats to a central manifold system for the heating (I remove the electronics form the original thermostats and put a DHT22 inside the housing). I hope I have time later today to take out the MRK 1010 and put it on breadboard with up to 3 sensors to take out the unknowns about cabling and I can also add pull resistors...
But don't forget DHTStable still is performing fine in exactly the same setup! There must be a important software difference that makes DHTStable work and DHTNew fail. but I appreciate that hardware issues do complicate matters....

@RobTillaart
Copy link
Owner

Agree, the problem is definitely in the timing of the DHTNew lib.
unclear is if it is the first bit, last bit or another bit, or even a random bit that fails.

I ordered two MKR1010's so if time permits I can start investigating too.

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 8, 2021

I just tested using a breadboard with just 1 sensor with and without 10k pull up resistor. Still the same results :-(
I had a look at your library code but this hardware-related stuff in C++ is beyond me unfortunaly I cannot help. I am a fully time java developer and normally work on very different stuff (lookup toine.siebelink@est.tech)

I did notice hover that in DHTNew before reading you use "pinMode(_dataPin, INPUT_PULLUP);" but in DHTStable you just use "pinMode(pin, INPUT);" I might do some more testing around this later....

@RobTillaart
Copy link
Owner

Thanks for giving it a try,
Yes, C++ is different and low level embedded bit hacking is one of its extreme sides.
When board comes in I make a setup and hook it up to a oscilloscope to see if there is something awkward.

@RobTillaart
Copy link
Owner

I did notice hover that in DHTNew before reading you use "pinMode(_dataPin, INPUT_PULLUP);" but in DHTStable you just use "pinMode(pin, INPUT);" I might do some more testing around this later....

Good find, although I expect there is little difference as the internal PULLUP is often in the order of 50K for most noards.
Far higher than often used 4K7. But that said still worth a try.

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 12, 2021

@ToineSiebelink

Got my MKR1010 Wifi boards and I have a problem with uploading a sketch.

  • There appear two ports sometimes COM8 and COM10 but most of the time I see no port.
  • Pressing RST twice to go to bootloader mode (I googled this) did not help.
  • The IDE recognized the board and installed all stuff - board manager says I have latest version 1.8.10
  • ON led is on (green)
  • a small orange led is on

Any clue how to get that board more stable?

@RobTillaart
Copy link
Owner

Sometimes after reset the ORANGE led is fading in and out (frequency ~ 1 Hz)

@RobTillaart
Copy link
Owner

Removed and reinstalled the driver and boards stuff. It looked like it could upload once.

Pressing reset twice: The ORANGE led fading in/out => assumption: the system is in bootloader mode.
Pressing reset once: The ORANGE led is dark ==> assumption: the system is in run mode.

Followed guidelines - https://www.arduino.cc/en/Guide/MKRWiFi1010
Stil cannot connect the Serial monitor to the device

@RobTillaart
Copy link
Owner

See this often when trying to upload.

java.io.IOException: jssc.SerialPortException: Port name - COM8; Method name - setEventsMask(); Exception type - Can't set mask.
	at processing.app.Serial.dispose(Serial.java:173)
	at processing.app.SerialMonitor.close(SerialMonitor.java:147)
	at processing.app.AbstractMonitor.suspend(AbstractMonitor.java:113)
	at processing.app.Editor$UploadHandler.run(Editor.java:2065)
	at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM8; Method name - setEventsMask(); Exception type - Can't set mask.
	at jssc.SerialPort.setEventsMask(SerialPort.java:279)
	at jssc.SerialPort.removeEventListener(SerialPort.java:1064)
	at jssc.SerialPort.closePort(SerialPort.java:1090)
	at processing.app.Serial.dispose(Serial.java:170)
	... 4 more

Probably I miss one or two crucial steps but the first hour with the MKR1010 Wifi is not a success.

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 12, 2021

This looks like a successful upload

Uploading using selected port: COM10
C:\Users\Rob\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0-arduino3/bossac.exe -i -d --port=COM10 -U true -i -e -w -v C:\Users\Rob\AppData\Local\Temp\arduino_build_730126/BareMinimum.ino.bin -R 
Set binary mode
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
chipId=0x10010005
Connected at 921600 baud
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Atmel SMART device 0x10010005 found
write(addr=0x20004000,size=0x34)
writeWord(addr=0x20004030,value=0x10)
writeWord(addr=0x20004020,value=0x20008000)
Device       : ATSAMD21G18A
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
Chip ID      : 10010005
version()=v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Version      : v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
readWord(addr=0x41004020)=0xffff
none
readWord(addr=0x41004018)=0
Security     : false
Boot Flash   : true
readWord(addr=0x40000834)=0
BOD          : false
readWord(addr=0x40000834)=0
BOR          : false
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
chipErase(addr=0x2000)
done in 0.828 seconds

Write 14860 bytes to flash (233 pages)
write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)
[========                      ] 27% (64/233 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)
[================              ] 54% (128/233 pages)write(addr=0x20005000,size=0x1000)
writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)
[========================      ] 82% (192/233 pages)write(addr=0x20005000,size=0xa40)
writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0xa40)
[==============================] 100% (233/233 pages)
done in 0.122 seconds

Verify 14860 bytes of flash with checksum.
checksumBuffer(start_addr=0x2000, size=0x1000) = f307
checksumBuffer(start_addr=0x3000, size=0x1000) = 88a
checksumBuffer(start_addr=0x4000, size=0x1000) = 8ce8
checksumBuffer(start_addr=0x5000, size=0xa0c) = 987f
Verify successful
done in 0.014 seconds
CPU reset.
readWord(addr=0)=0x20007ffc
readWord(addr=0xe000ed00)=0x410cc601
readWord(addr=0x41002018)=0x10010305
writeWord(addr=0xe000ed0c,value=0x5fa0004)

especially the almost last line - Verify successful + status bar

image

But I can't connect with the Serial monitor. On the bright side, the weekend is coming :)

@RobTillaart
Copy link
Owner

  while(!Serial);

adding that line seems to make the difference for the Serial monitor ... as I was able to reproduce your error.
(seldom I was so happy to see an error :)

dhtnew_test.ino
LIBRARY VERSION: 0.4.9


1. Type detection test, first run might take longer to determine type
STAT	HUMI	TEMP	TIME	TYPE
Time out C error,	-999.0,	-999.0,	21688,	

Now I must learn to do this upload etc smoothly.

@RobTillaart
Copy link
Owner

After running for 24+ hours with 44200 full calls 4 fails ==> that is 1 in 11050 or 0.009 %
Not zero but not too bad either,

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
44196	0	0	0	4	0	0	0	44199	0	

TIM	CNT	STAT	HUMI	TEMP	TIME	TYPE
88710300	88400	WFR,	66.4,	19.8,	3,	22
88711301	88401	OK,	66.3,	19.8,	5344,	22
88712307	88402	WFR,	66.3,	19.8,	3,	22
88713308	88403	OK,	66.3,	19.8,	5347,	22
88714315	88404	WFR,	66.3,	19.8,	4,	22
88715316	88405	OK,	66.2,	19.8,	5254,	22
88716322	88406	WFR,	66.2,	19.8,	3,	22
88717323	88407	OK,	66.2,	19.8,	5252,	22
88718330	88408	WFR,	66.2,	19.8,	3,	22
88719331	88409	OK,	66.2,	19.8,	5254,	22

@RobTillaart
Copy link
Owner

This morning

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
63996	0	0	0	4	0	0	0	63999	0	

after ~35 hours still only 4 TOC errors so better than 1 in 10.000

test setup

Board: MKR1010 Wifi
Sketch: dhtnew_endless.ino
Wires: ~20 cm between sensor and board, no pull-up resistor
connected over breadboard (not soldered)
Power sensor: 3.28 volt
Power board: USB from laptop
Data-pin: 5

@RobTillaart
Copy link
Owner

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
83717	0	0	0	8	0	0	0	83724	0	

After 46+ hours, still in the order of 1 in 10.000

@RobTillaart
Copy link
Owner

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
108191	0	0	0	9	0	0	0	108199	0	

after 60 hours, 100.000+ real reads => same failure rate (and all Timout C)

So that timeout seems the most critical / sensitive one

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 15, 2021 via email

@ToineSiebelink
Copy link
Author

Hi Rob, apologies for the delay, I have now added the line to allow the interrupts and all my 6 sensors seem to work fine now with DHTNew library :-) well done! So this proves it works well in a real world situation with long cables etc.
My system poll temperature every 90 seconds or so and reports to thinkSpeak every second iteration. I'l share my thinkspeak channel details with you later.

@RobTillaart
Copy link
Owner

No need to apologize, good to hear it works!

You might use setSuppressError(bool). to suppress error values in cases there is a timeout.
Your graphs might look much nicer without spikes :)

@ToineSiebelink
Copy link
Author

Channel #613783 Read API Key: JSGFE3HN1PPK9B3Q

I fall back on the previous value (store separately using my own code) to prevent spikes in my graphs ( I also don't want the heating to suddenly kick in/off for any good reason :-))

The first 5 fields have been pretty good since I started using DHTStable library a few months back. Just #6 (hot water) still is problematic:it starts failing after anything from 2 to 10 days. I'm pretty sure its a hardware issue, resetting the module using te reset button or even loading a new sketch doesn't fix it. But disconnecting power for a few seconds does fix it. I might try an external pull up resister 4.7K I think is what you advised earlier...

@RobTillaart
Copy link
Owner

Never used thingSpeak, how do I get to see the data - it says the channel is not public. (any URL?)
A screenshot is satisfying enough for me BTW :)

Measuring Hot Water can be a problem for the sensor. I had problems in the past with humidity "freezing at 100%". I think these sensors operating at the edge of their specs for longer time is not what they are meant for.

For temperature of water I prefer the watertight DS18B20. Stable over a wide temperature range (-55°C .. 125°C).
Several years ago I was involved in a project using them to measure temperatures on Antarctica.
Long stick in the snow and every 20 cm or so was a sensor.
As these sensors can be connected on one bus all 10 of them only used one pin.

@RobTillaart
Copy link
Owner

How long is the wire to the hot water sensor? you might even need a lower resistor like 2K2 or even 1K (> 10 mtr)

Have you checked the voltage at the end near the sensor?
If it drops below 3V3 it is out of spec and may "freeze" even near hot water :)

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 15, 2021

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 15, 2021

good, you got Thingspeak working! (its cool actually and free up to something like 3 million data entries per year :-))

'Hot Water' is just measuring on the outside of a copper tank, so it is dry and the range is not huge; room temperature to 50c max.
funny enough the hot-water is probably one of the shorter cables., about 2-3 meters. Does it make a difference what side the resistor is used ie. near the Arduino or near the sensor?

The Mkr Connector Carrier (https://store.arduino.cc/products/arduino-mkr-connector-carrier-grove-compatible) uses Grove connectors which are supplied with 5V so that is what I use for all sensors and I just check and measure 4.6 Volt at the sensor end. So what resistor size would you recommend? I got 220, 1k, 10k and 100k

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 15, 2021

Does it make a difference what side the resistor is used ie. near the Arduino or near the sensor?

Yes, no electrical engineer by profession but this is how I think it works.

suppose the wire is long and near the board the voltage is 5V and it drops to 4V (just for the idea)

Pull up on sensor side
If the sensor gives a HIGH it can only be 4V as its power is 4V and the pull up can only pull it up to 4V.
As the signal drops another volt on the way back the voltage can be as low as 3V on the data Pin.

Pull up on board side
If the sensor gives a HIGH it can only be 4V as its power is 4V.
As the signal drops another volt on the way back the voltage can be as low as 3V on the data Pin.
However there the pull up, can pull it up to the 5V again.

@RobTillaart
Copy link
Owner

So what resistor size would you recommend? I got 220, 1k, 10k and 100k

recommend 1K
220 ohm would give a constant current of ~25 mA (not much but not needed)
10 K and 100 K would be slower to raise the voltage.

I use this book as a reference - https://www.amazon.co.uk/Practical-Electronics-Inventors-Fourth-Scherz/dp/1259587541
There is quite some math in it, but most can be skipped.

For my commercial projects I work together with an Electric Engineer so he "fixes" my hardware schemes.

@ToineSiebelink
Copy link
Author

thanks for the tips. I'll try that!

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 15, 2021

FYI

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
128665	0	0	0	10	0	0	0	128674	0	

128000 real reads 10 fails => 1 in 10K still holds.

Unless there are other related questions, I think the issue can be closed?

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 15, 2021 via email

@RobTillaart
Copy link
Owner

Yes, the library did not change so I only need to

  • mention that the mkr1010 needs the extra line
  • add some comments in the endless sketch I used to do the long test.
  • add the While(!Serial) in the demo sketches
  • add some commented debugging code in the .cpp file

so a bit more than just the readme, but no breaking stuff.
Tomorrow, it is too late to start a new PR now ;)

@RobTillaart
Copy link
Owner

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
146840	0	0	0	10	0	0	0	146849	0	

still going well

@RobTillaart
Copy link
Owner

PR created - #68

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
158037	0	0	0	13	0	0	0	158049	0

stable 1 in 10.000 ==> going to adjust timing a bit to see if that reduces it

@RobTillaart
Copy link
Owner

PR merged.

@RobTillaart
Copy link
Owner

update test with slightly longer timeout C (90 micros in stead of 70 micros)

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
34549	0	0	0	0	0	1	0	34549	0	

1x SNR - Sensor not Ready but no other (timeout) errors although I expected 2 or 3
(based upon the previous run which had 1 in 10K-15K )

so looks promising as an improvement.

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 17, 2021 via email

@RobTillaart
Copy link
Owner

You can't make the time shorter than the specs otherwise you don't have a measurement.

  • that is where the original 70us is based upon.

(backgrounder)
As far as we know there is a small processor in the sensor. Probably the clock of the sensor is 1MHz (assumption) but it is not very precise (±5% ?) . That assumption is based on the minimum pulse lengths mentioned in the protocol. The smallest common divider of the mentioned lengths is ~10us. To achieve that at least a 1MHz processor is needed.
A DHT22 probably has a faster core than a DHT11 as it is able to "wake up" much faster and is able to add decimal precision.

The varying of pulse length is a robust protocol as a difference between a 0 and a 1 are given in an large enough time frame. 50 + 27us = 0 50 + 70us = 1. Technically speaking the protocol could be 5-10x faster and still be workable for a 16 MHz UNO.
(end)

That said, if the internal processor is ~5% slower the 50+70 us of the spec become 70 + 5% = 75 us (approx) so to be able to handle this you need a sufficient large timeout, otherwise you will get too much failed readings - which is a serious waste of clock cycles in a RT system. BTW a faster processor would not need the max timeout so they will work as intended.

so, no I think it will make no sense to make the timeout configurable from the API.
And people who like to hack are welcome to clone and patch the library.

I will try to keep the setup running to see how much better it is . now at 41424, still no timeout, only one SNR

@ToineSiebelink
Copy link
Author

ToineSiebelink commented Nov 17, 2021 via email

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 18, 2021

So after 40+ hours and 74000++ reads no TOC error anymore, so time to prepare a PR.
at a rate of 1 in 10-15K somewhere between 5 and 7 TOC's were expected.
No statistical argumentation calculated (too early)

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
74024	0	0	0	0	0	1	0	74024	0

@RobTillaart
Copy link
Owner

DHTNEW 0.4.10 released

@RobTillaart
Copy link
Owner

RobTillaart commented Nov 19, 2021

going towards 80 hrs...still going strong.

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
142799	0	0	0	0	0	1	0	142799	0

92 hrs. tomorrow I stop the testrun.

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
165724	0	0	0	0	0	1	0	165724	0

114 hrs, ...

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
206399	0	0	0	0	0	1	0	206399	0

162 hrs

OK 	CRC 	TOA 	TOB 	TOC 	TOD 	SNR 	BS 	WFR 	UNK
293274	0	0	0	0	0	1	0	293274	0

@RobTillaart
Copy link
Owner

Note: found the define to set the IRQ flag in the library

  #ifdef ARDUINO_SAMD_MKRWIFI1010
  #error found
  #endif

intention to include this in the library sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants