ESP32 WROOM - Pin Won't Go HIGH when using Infrared4Arduino

I have no idea why my board is doing this, but here goes.

  1. I create a simple circuit, with the positive lead of an LED connected to one of many of the GPIO pins on the ESP32 WROOM.
  2. The negative lead, I connect to GND.
  3. In my code, I do pinMode(, OUTPUT) in setup(), and digitalWrite(, HIGH) in loop().
  4. I run the sketch.

For some reason I can't get the pin on the ESP32 to go high.

If I connect my LED directly to 3.3 V (or initially HIGH pins like pin 3) it lights up fine. If I connect a multimeter to the GPIO pin I'm trying to set to HIGH, I get 0V.

I've tried pins 18. 19, 22, etc to no avail.

Let's see the sketch. A picture of your setup may also prove helpful.

If this is your board, make sure to test at the purple location, not grey on the pinout diagram.

your code?

an image of your setup?

Ugh. Been trying to isolate the problem. The board seems fine if I create a very simple sketch with ONLY this code.

It looks like my pins drop to LOW (and I can't set them to HIGH) when I include an infrared library I've been using.

As soon as I comment out this:

#include <IrReceiverSampler.h>

I get my GPIO pin back and I can set it to high.

Very likely, the library code is using, or expects to use that pin.

I agree that it's possible. Per the docs there is a default PWM output pin for transmitting, but I don't see anywhere that tells me entire swaths of the GPIO is reserved.

I've tried multiple pins on the board, and as soon as I make that single include, I can't bring them HIGH anymore.

A look at the library code will make that absolutely clear.

Maybe if I was the author - there's dozens of files that get included as a result of that single include. Definitely trying to work through it on my own. Will send and update if I find anything.

You need a series resistor with any LED. put in 50-150 ohms and see if that doesn't fix it. The LED alone will sink more than the output pin can drive.

Series resistor is already in place - I can power and see the LED working just fine if I connecting it directly to the 3V3 pin, or one of the GPIO pins that stays HIGH (like RXO).

The problem seems to be that I lose the ability to set GPIO pins to high when I use the library.

Horse-feathers.

If one went to the web site and one was to read the things there are to read one would find there is a list of board specific hardware.

In the Infrared4Arduino/Esp32.h at master · bengtmartensson/Infrared4Arduino · GitHub one would begin to see things like #define PWM_PIN 5. Might or might not prove to be useful.

The library in question is using the ESP32's LEDC API to drive the PWM signal it generates. If the OP is using a hardware timer the LEDC APi being used by the infraredthingy library and the way the hardware timer is being assigned, a conflict of timer assignment by the API can happen. If the OP is using the ESP32's hardware timer, I recommend the OP use the 4th (timer3) timer to avoid issues.

@Idahowalker - my problem isn't related to PWM output of the library to send IR... that actually works great on the pin specified.

It's just this odd behavior that when I try to use the library, I suddenly lose the ability to control other GPIO pins for simpler LED uses (like having a LED blink when a signal is received or transmitted). No timer or PWM needed for my problem... just the ability to set the pin to HIGH.

Have you considered trying to use the ESP32's GPIO/RTC API to control the GPIO pins?

Here in setup() I use the ESP32's GPIO/RTC API in setup to do the pin thing.

void setup()
{
  //
  gpio_config_t io_cfg = {};
  io_cfg.mode = GPIO_MODE_OUTPUT;
  //bit mask of the pins to set
  io_cfg.pin_bit_mask = ( (1ULL << GPIO_NUM_0) | (1ULL << GPIO_NUM_15) | (1ULL << GPIO_NUM_4) );
  //configure GPIO with the given settings
  gpio_config(&io_cfg);
  REG_WRITE(GPIO_OUT_W1TS_REG, BIT0); // internal led
  REG_WRITE(GPIO_OUT_W1TC_REG, BIT15); // sunlamp
  gpio_set_level( GPIO_NUM_4, LOW); //air particle sensor
  //

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/gpio.html

@Idahowalker Crazy. If I do this it lights up:

gpio_set_direction(GPIO_NUM_21, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_21, HIGH);

If I do this, it does not:

pinMode(21, OUTPUT);
digitalWrite(21, HIGH);

Are these equivalent - does 21 = GPIO 21?

When using the ESP32 API it is best to use ESP32 API naming conventions.

Granted - I'm just curious to know if my pinMode/digitalWrite code is correct in just using 21. The gpio_* code definitely works and I'm no longer stuck, but it's a head scratcher to me to understand why the arduino core code doesn't work.

I was mostly asking if 21/pinMode/digitalWrite is the equivalent of GPIO_NUM_21/gpio_set_direction/gpio_set_level.

It's supposed to be but the Arduino ESP32's core is not as configurable as the ESP32's GPIO/RTC API.

@Idahowalker Well - thank you so much for offering the suggestion. Works for me, and I'm likely to stay on ESP32 (moving from Uno), so maybe trying to get the pinMode/digitalWrite version working isn't that important (for me).