raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.84k stars 820 forks source link

[Question]: Pico gpio/dht_sensor Example not working #439

Open hasenradball opened 10 months ago

hasenradball commented 10 months ago

Dear Pico Fellows,

the DHT Sensor example does not work. I get always bad data. It seems the code is written not robust enough, and also less comments. Is it fine for you when I provide an improved code on basis on this: AM2302-sensor

With this approach you will be also possible if the error is caused by a timeout or checksum_error.

lurch commented 10 months ago

It's possible that https://github.com/raspberrypi/pico-examples/issues/423#issuecomment-1742244505 also applies here?

hasenradball commented 10 months ago

@lurch thank for you comment. I have additionally 2 questions (e.g.: for the dht example)

1) I generally see no usage of classes lets say, all code parts mainly placed in main.c files For example providing an dht class via include, create an object and do it object orientated. Doe this not work with the pico c SDK?

2) I saw it mainly in the code of dht -> function read_from_dht()

peterharperuk commented 10 months ago

All the examples stick to C because that's just keeps things simple. Yes there seems to be a quite a few issues with this example. I doubt anyone has looked at it for some time. The points you raise are valid. Feel free to improve it and add some comments - or else I'll look at getting one of those sensors and doing it myself.

hasenradball commented 10 months ago

Hi @peterharperuk,

thanks for your feedback I started to have a look at it. I currently reworked a DHT Class ( see here: AM2302-sensor )

So I know what happens and what should happen. I will check, but having a reviewer and discussion partner would be great! :-)

hasenradball commented 10 months ago

@lurch @peterharperuk

I proposed a PR #440. This code is adapted to the Pico c files and was mainly taken from here: AM2302-sensor

hasenradball commented 5 months ago

@peterharperuk Hi Peter, apologies for asking directly. Do you have an hint for an example for an Pi PicoW how to send an http request?

I want just to send some data to an server. Nothing complex.

peterharperuk commented 5 months ago

I've used the lwip http client. There's an example here...

https://github.com/raspberrypi/pico-examples/pull/385

I think this depends on the following PR's so it might not compile on its own... https://github.com/raspberrypi/pico-examples/pull/475 https://github.com/raspberrypi/pico-examples/pull/460

(I will get around to merging your PR's soon)

hasenradball commented 5 months ago

Thank for fast reply I will have an look on it.

Regarding the PR's,here some nice feedback for the DHT sensor lib which was the basis for the Pico Example update: Just for you information: https://github.com/hasenradball/AM2302-Sensor/issues/10

hasenradball commented 4 months ago

@peterharperuk Hi Peter,

do you have some hint about my PRs, when to lokk at? They are discussed a long time ago.

hasenradball commented 1 month ago

@lurch @peterharperuk,

any interests to merge this?

lurch commented 1 month ago

We've been a bit busy with other things recently :wink: