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

Add support for H2 chip #583

Merged
merged 1 commit into from
Nov 23, 2023
Merged

Add support for H2 chip #583

merged 1 commit into from
Nov 23, 2023

Conversation

rob4226
Copy link
Contributor

@rob4226 rob4226 commented Nov 23, 2023

Allows building for the ESP32-H2 chip. I tried it with a couple sensors and it seems to work fine.

@UncleRus UncleRus merged commit 47fabc5 into UncleRus:master Nov 23, 2023
40 checks passed
@g-chevalier
Copy link

Hi @rob4226

I tried the last version of the library with a DS18B20 on an ESP32-H2 (the ESP32-H2-DevKitM-1 exactly), and it doesn't work.
The exact same code is working well on an ESP32-C6- DevKitC-1.
I tried with two different devices and different GPIOs.
The issue starts at the very beginning: the ds18x20_scan_devices function returns 0 devices found.

Before investigating further, I just wanted to check with you if your tests included such DS18B20 device?

@rob4226
Copy link
Contributor Author

rob4226 commented Dec 6, 2023

Hi @g-chevalier

No sorry, I don't have a DS18B20 so I didn't try that one. I did throughly use a DHT-11 Humidity/Temperature sensor (which also uses a 1-wire interface) with a ESP32-H2-DevKitM-1 and that worked fine. That's strange that your C6 works but not the H2 as they are somewhat similar chips (biggest difference is no Wi-Fi on the H2). I used GPIO 22 for the 1-wire communication.

@g-chevalier
Copy link

Hi @rob4226

Thank you for your answer.

The DHT-11 although working with a single wire is not using the Dallas 1-Wire protocol used by the DS18B20. The implementation here relies on the "onewire" library.

However, I tested a bit more and discovered that it is working on the ESP32-H2-DevKitM-1 using GPIO22. Good news, and enough for me!
In comparison with GPIO 4 & 5 that I used formerly, the GPIO22 is solely a GPIO and not multiplexed with other functions on the H2. I suspect that there is something more to do during GPIO initialization in the onewire library (or before using it in my code?) to make it working in all cases.

By the way, the other test I did on the ESP32-C6-DevKitC-1 was with GPIO11, which appears also to be a "pure" GPIO (not muxed). If I find time, I'll try on another pin later with the C6.

@rob4226
Copy link
Contributor Author

rob4226 commented Dec 6, 2023

@g-chevalier Nice! Glad you got it working! Yes, that is why I chose pin 22, better chance of other things not interfering with the sensor on startup. Sometimes these 1-wire type sensors (not sure about Dallas tho) need the signal pin held a certain way, for a certain amount of time, to put it into "command mode". Otherwise, they won't respond on startup.

@g-chevalier
Copy link

Hi all,

Finally, it works also with multiplexed GPIO such as GPIO4.

In fact, the initialization code I used was taken from the examples in the lib, which are just doing
gpio_set_pull_mode(SENSOR_GPIO, GPIO_PULLUP_ONLY);

This seems to not initialize correctly the GPIO when it is one that is multiplexed between several usages.
The bellow code is working with GPIO4 on the H2:

static const gpio_num_t SENSOR_GPIO = 4;

io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_INPUT;  // The Onewire lib will take care of switchin input/output
io_conf.pin_bit_mask = (1ULL << SENSOR_GPIO);
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&io_conf);

Hope it may help others...

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