Closed ZIMkaRU closed 8 months ago
Update: the issue is in the trigger section of the pulseRead
when the last trigger impulse is set to down then input is pulled up
I was able to fetch bits when added a third trigger value of 20
var bits = pulseRead(this.pin, 100, {
timeout: 25000,
startState: LOW,
mode: INPUT,
trigger: {
startState: HIGH,
interval: [10000, 18000, 20],
},
});
@communix several thoughts:
maybe when we set the INPUT
mode after the trigger
https://github.com/kaluma-project/kaluma/blob/c3071d6868a000607349aa29126f5a32c02c0f19/src/global.c#L276
we should set false
for gpio_set_dir(pin, false);
before setting gpio_set_input_enabled(pin, true);
https://github.com/kaluma-project/kaluma/blob/c3071d6868a000607349aa29126f5a32c02c0f19/targets/rp2/src/gpio.c#L73
in order to disable OUTPUT
mode before setting INPUT
one
https://github.com/kaluma-project/kaluma/blob/c3071d6868a000607349aa29126f5a32c02c0f19/targets/rp2/src/gpio.c#L66
I made this fix: https://github.com/kaluma-project/kaluma/pull/631 and built a beta release on my own: kaluma-rp2-pico-1.1.0-beta.4.zip works good
@ZIMkaRU Thank you for your contribution. Your code looks good and it's merged. Thanks to your code, I have a chance to review GPIO input/output code and add more code to fix this issue. Please try it with the latest code in the master branch.
@communix I've built and tested many versions of the combinations for gpio_set_dir
/gpio_set_input_enabled
and it works only if remove gpio_set_input_enabled(pin, false)
which is placed after gpio_set_dir(pin, GPIO_OUT)
for KM_GPIO_IO_MODE_OUTPUT
mode
https://github.com/kaluma-project/kaluma/blob/master/targets/rp2/src/gpio.c#L67
@ZIMkaRU Thank you. Let me revert my change. Please check #633 and close this issue.
Sure, thanks
checked, works well
Looks like
pulseRead
does not work withDHT22
used the last release https://github.com/kaluma-project/kaluma/releases/tag/1.1.0-beta.4 checked with this lib https://github.com/niklauslee/dht made simple example:
and
pulseRead
always returnsnull
: https://github.com/niklauslee/dht/blob/main/index.js#L74 I connected an oscilloscope to the signal pin of the sensor to make sure it works trigger pulses are processed successfully and the sensor returns a data packet but it looks like reading is not happening it seems the reading pin of the board isINPUT_PULLUP
mode and can't be reconfigured toINPUT_PULLDOWN
I think I'm not the only one having this problem https://github.com/niklauslee/dht/issues/2