Skip to content

Add additional C++ Example for AM2302-Sensor#450

Closed
hasenradball wants to merge 8 commits into
raspberrypi:developfrom
hasenradball:add_cpp_example_for_AM2302_sensor
Closed

Add additional C++ Example for AM2302-Sensor#450
hasenradball wants to merge 8 commits into
raspberrypi:developfrom
hasenradball:add_cpp_example_for_AM2302_sensor

Conversation

@hasenradball

@hasenradball hasenradball commented Dec 19, 2023

Copy link
Copy Markdown

Add a C++ Example for AM2302-Sensor.

@hasenradball

hasenradball commented Dec 19, 2023

Copy link
Copy Markdown
Author

@lurch Hi,

added in short a cpp example for the AM2302-sensor.
It is possible to add to the pico examples?

It makes the main file a little more cleaner :-)

@lurch

lurch commented Dec 19, 2023

Copy link
Copy Markdown
Contributor

As I might have mentioned before, I only provide "(hopefully) helpful comments", it's not my decision whether to merge PRs in pico-sdk or pico-examples. But my first helpful comment would be that you need to target your PR against develop instead of master 😉

@hasenradball hasenradball changed the base branch from master to develop December 19, 2023 08:04
@hasenradball

Copy link
Copy Markdown
Author

@lurch Thanks for the hint.
You are totally right.

:-)

@hasenradball hasenradball changed the title Add additional C++ Example for AM2302_sensor Add additional C++ Example for AM2302-Sensor Dec 19, 2023
@peterharperuk

Copy link
Copy Markdown
Contributor

How is this different from the DHT22 code you've added? Or are you adding this as an example of how to use C++?

@hasenradball

Copy link
Copy Markdown
Author

@peterharperuk
Hi Peter, the idea was to add this as C++ Example.
I got the info in the morning that cpp in gerneral is possible… using classes and instatiation and all this stuff.
Then I tried it directly.
It makes the main file a little cleaner.
Could be an example how it looks like in cpp style.
One thing is different here.
When call method begin() there is a check if sensor is connected.

And maybee here could also the check placed to distinguish between DHT11 or DHT22.

Best regards
Frank

@hasenradball

hasenradball commented Dec 19, 2023

Copy link
Copy Markdown
Author

@peterharperuk
One other thing ist also improved.
If you poll the sensor too often which means < 2 s .
Then status is -3 and the read function is not called.

So code is slightly improved.
please try it.

So in short:

  • added ìs sensor connected check
  • added check of read frequency

Comment thread gpio/AM2302_sensor/AM2302.cpp Outdated
@hasenradball

Copy link
Copy Markdown
Author

@lurch can you please give a review for this PR.

@hasenradball hasenradball requested a review from lurch January 30, 2024 09:57
@lurch lurch removed their request for review January 30, 2024 10:19
@lurch

lurch commented Jan 30, 2024

Copy link
Copy Markdown
Contributor

As I might have mentioned before, I only provide "(hopefully) helpful comments", it's not my decision whether to merge PRs in pico-sdk or pico-examples.

@hasenradball

Copy link
Copy Markdown
Author

@lurch I thought so because you are mentioned as reviewer, sorry for the missunderstanding.

@lurch

lurch commented Jan 30, 2024

Copy link
Copy Markdown
Contributor

I think GitHub just treats any comment on the code as a "review" 🤦

@hasenradball

hasenradball commented Apr 25, 2024

Copy link
Copy Markdown
Author

@peterharperuk

Added the following features:

  • better human readable error output
  • example with sensor array

Added screenshot how example looks:

20240425_16h59m19s_grim

Comment thread gpio/AM2302_sensor/AM2302-Sensor.cpp Outdated
Comment thread gpio/AM2302_sensor/AM2302-Sensor.cpp Outdated
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.

3 participants