Dark AI
Dark AI
GPIO Pin Configuration Error for DHT22 on AVR32UC with Zephyr OS
Thanks for the heads-up, @Dtynin . Let’s try a couple more troubleshooting steps. First, ensure that DT_LABEL(DT_NODELABEL(gpio0)) correctly matches the label in your DTS file. To gather more debugging information, modify your code as follows:
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>

#define DHT22_PIN 2
#define GPIO_PORT DT_LABEL(DT_NODELABEL(gpio0))

const struct device *gpio_dev;

void main(void)
{
printk("Starting DHT22 sensor integration\n");

gpio_dev = device_get_binding(GPIO_PORT);
if (!gpio_dev) {
printk("Failed to bind GPIO device: %s\n", GPIO_PORT);
return;
} else {
printk("Successfully bound to GPIO device: %s\n", GPIO_PORT);
}

int ret = gpio_pin_configure(gpio_dev, DHT22_PIN, GPIO_INPUT);
if (ret < 0) {
printk("Failed to configure GPIO pin %d, error: %d\n", DHT22_PIN, ret);
} else {
printk("Successfully configured GPIO pin %d\n", DHT22_PIN);
}
}
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>

#define DHT22_PIN 2
#define GPIO_PORT DT_LABEL(DT_NODELABEL(gpio0))

const struct device *gpio_dev;

void main(void)
{
printk("Starting DHT22 sensor integration\n");

gpio_dev = device_get_binding(GPIO_PORT);
if (!gpio_dev) {
printk("Failed to bind GPIO device: %s\n", GPIO_PORT);
return;
} else {
printk("Successfully bound to GPIO device: %s\n", GPIO_PORT);
}

int ret = gpio_pin_configure(gpio_dev, DHT22_PIN, GPIO_INPUT);
if (ret < 0) {
printk("Failed to configure GPIO pin %d, error: %d\n", DHT22_PIN, ret);
} else {
printk("Successfully configured GPIO pin %d\n", DHT22_PIN);
}
}
This will provide more information about where the failure is happening. Additionally, ensure there are no conflicts with other peripherals or pins. Can you run this modified code and share the output logs?
5 replies