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

Addition of test timing script #68

Merged
merged 10 commits into from
Mar 28, 2021
Merged

Conversation

yeyeto2788
Copy link

Hey guys!

I stumble across issue #66 and just wanted to create a script so we can test best timing on reading data from the DHT sensor.

Example output:

(venv) yeyeto2788@orangepilite:~/workspace/mudpi-core$ sudo /home/yeyeto2788/workspace/dht_test/venv/bin/python dht_time_calibration.py

Initializing test.

Using 'trig_wait' of 500
Total read(s): 4

Using 'trig_wait' of 600
Total read(s): 6

Using 'trig_wait' of 700
Total read(s): 6

Using 'trig_wait' of 800
Total read(s): 6

Using 'trig_wait' of 900
Total read(s): 6

Using 'trig_wait' of 1000
Total read(s): 5

Using 'trig_wait' of 1100
Total read(s): 5

Using 'trig_wait' of 1200
Total read(s): 10

Using 'trig_wait' of 1300
Total read(s): 9

Using 'trig_wait' of 1400
Total read(s): 10

Using 'trig_wait' of 1500
Total read(s): 9

Using 'trig_wait' of 1600
Total read(s): 8

Using 'trig_wait' of 1700
Total read(s): 8

Using 'trig_wait' of 1800
Total read(s): 6

Using 'trig_wait' of 1900
Total read(s): 6

Maximum reads: 10 with the following times: 1200 ,1400

Get latest code from upstream
Addition of a script to test best timing for DHT sensor.
Fix minor issue on printing best timing
@jposada202020 jposada202020 self-assigned this Mar 19, 2021
Add licensing so build does not fail.
@jposada202020
Copy link

@yeyeto2788 Thanks for the contribution, as discussed I will try on my side also after our discussion.
After this initial verification I can share my results and let people comment on this example, and then we could work on the code format in order to the CI to pass if you agree. Thanks for your contribution

@yeyeto2788
Copy link
Author

@jposada202020 Sure, no problem on my side.

@jposada202020
Copy link

@yeyeto2788 in case of need you cold take a look at these guide https://learn.adafruit.com/improve-your-code-with-pylint, however feel free to contact me to guide you in this process

Add more details on console output like the number of tries per trig_wait
Fix issues on linting.
Add more description and also what parameters were used on the test.
@yeyeto2788
Copy link
Author

Sample output for latest commit.

(venv) yeyeto2788@orangepilite:~/workspace/mudpi-core$ sudo /home/yeyeto2788/workspace/mudpi-core/venv/bin/python test1.py
[sudo] password for yeyeto2788:


Initializing test with the following parameters:

Maximum retries per waiting time: 10
Start time (ms): 500
End time (ms): 2000
Increment time (ms): 100

This execution will try to read the sensor 10 times
for 15 different wait times values.


Using 'trig_wait' of 500
Total read(s): 4

Using 'trig_wait' of 600
Total read(s): 2

Using 'trig_wait' of 700
Total read(s): 5

Using 'trig_wait' of 800
Total read(s): 6

Using 'trig_wait' of 900
Total read(s): 6

Using 'trig_wait' of 1000
Total read(s): 5

Using 'trig_wait' of 1100
Total read(s): 6

Using 'trig_wait' of 1200
Total read(s): 5

Using 'trig_wait' of 1300
Total read(s): 5

Using 'trig_wait' of 1400
Total read(s): 6

Using 'trig_wait' of 1500
Total read(s): 8

Using 'trig_wait' of 1600
Total read(s): 8

Using 'trig_wait' of 1700
Total read(s): 0

Using 'trig_wait' of 1800
Total read(s): 6

Using 'trig_wait' of 1900
Total read(s): 8

Maximum reads: 8  out of 10 with the following times: 1500, 1600, 1900

@jposada202020
Copy link

I have tested the code above, I did make some changes to use it with my RP4.

RP4 with a DHT22
Maximum reads: 10  out of 10 with the following times: 400, 700, 1200, 1300, 1400, 1600
Maximum reads: 10  out of 10 with the following times: 400, 700, 1300, 1600, 1700
Maximum reads: 10  out of 10 with the following times: 400, 500, 600, 900, 1100, 1200
Maximum reads: 10  out of 10 with the following times: 300, 600, 700, 1000, 1100, 1300, 1400, 1600, 1800, 1900
Maximum reads: 10  out of 10 with the following times: 500, 800, 1000, 1300, 170
Maximum reads: 10  out of 10 with the following times: 1600
Maximum reads: 10  out of 10 with the following times: 500, 700, 900, 1000, 1100, 1300, 1900
Maximum reads: 10  out of 10 with the following times: 400, 800, 1000, 1300, 1400, 1500, 1600, 1800, 1900
Maximum reads: 10  out of 10 with the following times: 1000, 1100, 1200, 1300, 1400

RP4 with a DHT11
Maximum reads: 10  out of 10 with the following times: 15600, 15800, 16200, 16600, 17400, 17600, 18000, 18200, 18600, 19400, 20400, 21000, 21200, 23000, 23400, 23800, 24200
Maximum reads: 10  out of 10 with the following times: 15800, 16200, 16600, 16800, 17000, 17200, 17800, 18000, 18600, 18800, 19000, 19600, 19800, 20000, 20600, 21000, 21400, 22200, 22600, 22800, 24200
Maximum reads: 10  out of 10 with the following times: 15000, 15600, 16000, 16200, 16400, 17200, 17600, 17800, 18000, 18200, 20800, 21000, 21400, 22800, 23600, 24600, 24800
Maximum reads: 10  out of 10 with the following times: 16600, 17800, 18000, 18200, 22000, 22200, 22400, 24000, 24600
Maximum reads: 10  out of 10 with the following times: 15000, 15400, 15600, 16000, 16600, 17000, 17200, 17800, 18200, 19000, 19200, 19400, 19600, 20000, 20200, 20600, 21000, 21200, 22200, 22600, 23000, 23200, 23800
Maximum reads: 10  out of 10 with the following times: 15400, 16200, 16400, 17000, 17200, 17800, 18200, 18400, 20000, 20600, 20800, 22000, 22400, 22600, 23400, 24000, 24200, 24400
Maximum reads: 10  out of 10 with the following times: 15200, 15600, 15800, 16400, 16600, 16800, 17000, 17200, 17400, 17600, 18000, 18400, 18600, 19200, 21800, 22600, 23800, 24400
Maximum reads: 10  out of 10 with the following times: 16000, 16400, 17000, 17200, 17400, 17800, 18000, 18200, 18400, 19400, 19800, 20600, 21200, 22000, 22200, 22400, 22600, 24200, 24800
Maximum reads: 10  out of 10 with the following times: 15000, 15600, 16200, 16400, 16600, 17000, 17800, 18200, 19000, 19200, 19400, 19800, 20400, 20600, 21200, 22000, 22200, 22600, 23000, 23200, 23800, 24200, 24600, 24800

I have some comments for the code, I will given my feedback shortly thanks.

@jposada202020
Copy link

@yeyeto2788 Thanks again
I have a couple of comments. Please do not hesitate to contact me here or in discord if you need help/guidance with anything.

  1. Could you add the example to the following file : https://github.com/adafruit/Adafruit_CircuitPython_DHT/blob/master/docs/examples.rst this would allow the readthedocs documentation to use the example when building the docs. Just follow the conventions as for the previous example.
  2. I would suggest a change in the name of the example, maybe if you could add _advanced at the end. I think that this example uses a private attribute in the library and is in some ways higher level
  3. As discussed also, if you could add some description of the purpose of the script, as in example dht_to_led_display.py. that would help folks understand the purpose of the example.
    example of reading temperature and humidity from a DHT device
  4. Include the mention that, timing for the DHT11 and DHT22 are different. maybe add in the comments that usually they are 0.001 DHT22 and 0.018 for DHT11, but that always verify the datasheet.

Feel free to ignore the following comments if you disagree, there are just to have use the same standard as in other code and no a requirement.
Spaces between lines in the import libraries.

Thanks again for your contribution.

Add better description to the advance script.
Add the `venv` folder to be ignore.
Add the ussage of the script for the documentation.
Add new line on file
Copy link

@jposada202020 jposada202020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the revision just to minor changes, Ithink th CI will stop complaining after this.
Thanks :)

docs/examples.rst Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
Add longer heading underscore line.
@jposada202020 jposada202020 merged commit 4b8be0e into adafruit:master Mar 28, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 7, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 4.3.3 from 4.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#104 from kattni/main-fix
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_DHT to 3.6.0 from 3.5.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#68 from yeyeto2788/master
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch to 1.2.7 from 1.2.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_FocalTouch#20 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_RockBlock to 1.3.3 from 1.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_RockBlock#21 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.9.3 from 1.9.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#32 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO to 5.2.4 from 5.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#68 from brentru/validate-feed-keys-used
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_AVRprog to 1.3.7 from 1.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_AVRprog#21 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver to 1.1.6 from 1.1.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#14 from kmatch98/patch-2
  > "Increase duplicate code check threshold "
  > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#17 from FoamyGuy/pylintrc

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Radio to 0.3.5 from 0.3.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Radio#15 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_BoardTest to 1.2.6 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BoardTest#15 from adafruit/linting
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_datetime to 1.1.3 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_datetime#8 from adafruit/jepler-integer-total_seconds
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 2.18.3 from 2.18.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#150 from jposada202020/advanced_example
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#149 from jposada202020/optimizing_getting_font_info

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGBLED to 1.1.5 from 1.1.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGBLED#15 from adafruit/dherrada-patch-1
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_RSA to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RSA#18 from adafruit/linting
  > "Increase duplicate code check threshold "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants