Configure GPIO 33 as digital I/O

mdotali
Posts: 1
Joined: Thu Feb 07, 2019 12:01 pm

Configure GPIO 33 as digital I/O

Postby mdotali » Thu Feb 07, 2019 12:08 pm

I am using Arduino studio to program ESP32 and I am unable to configure GPIO33 as I/O. It is multiplexed to some other functionality as given in the matrix. But I'm not sure which is it.

So I have two questions:
1 - How do I know which functionality is assigned to GPIO33 or any GPIO from the Muxing Matrix. (where is this info of default mapping)
2 - How do I configure GPIO33 as general GPIO pin instead of mapping it to a peripheral.

I want to control a relay using this pin, and right now I don't have the flexibility of using any other I/O for this purpose.

kintara
Posts: 2
Joined: Thu Feb 07, 2019 3:59 pm

Re: Configure GPIO 33 as digital I/O

Postby kintara » Sat Feb 09, 2019 11:00 am

If I understand you correctly i think you just do this in void setup()

pinMode(33, OUTPUT); // GPIO as output
or
pinMode(33, INPUT); // GPIO as input
or
pinMode(33, INPUT_PULLUP); // GPIO as input utilising the internal pull-up resistor


Then when you want to set pin 33 high or low you use either

digitalWrite(33,HIGH);
or
digitalWrite(33,LOW);

If you want a bit more meaning to what pin 33 is doing for you, you can always add the following before void setup()

#define Red_LED 33 // now instead of referring to the pin by its number, you can use 'Red_LED' instead.

then change
pinMode to :-
pinMode(Red_LED , OUTPUT);

and digitalWrite to:-
digitalWrite(Red_LED ,HIGH);
or
digitalWrite(Red_LED ,LOW);

Kintara

idahowalker
Posts: 162
Joined: Wed Aug 01, 2018 12:06 pm

Re: Configure GPIO 33 as digital I/O

Postby idahowalker » Sun Feb 10, 2019 4:19 am

Keep a lot of notes. Here is a few to get you started.

IO32 IO33 are connected to the crystal. Docs say you can't use these 2x pins as GPIO unless you desolder some stuff on the module.

Input-only pins: IO34, IO35, Sensor_VP, Sensor_VN, are labeled in docs as GPI (note the lack of O), which may mean they're input-only pins.

There's 5 "strapping" pins, which effect how the ESP-32 boots depending on if they're pulled high or low. So it's possible that something you've hooked upto these pins may effect how it boots. These pins are: 0 2 5 12 15

On the ESP32 WROVER-B, the one with 8MB Flash, there are 2 more pins. There are 2 onboard LEDs that can be programmed to blink GPIO0 and GPIO27

Watch which printout for the ESP32 WROVER-B pinout you get, one of the pin printouts is in mirror view.

There are 2 SPI busses, both work. HSPI and VSPI. I do not suggest remapping them SPI pins.

You have access to 3 serial ports. Serial, Serial (1) and Serial (2). Serial is for the monitor. Serial 2 is easy to use. Serial 1 requires pin remaping, easy to do.

Serial.println(MOSI); // 23 Master Out Slave In, SDI, DIN
Serial.println(MISO); // 19 Master In Slave Out, SDO
Serial.println(SCK); // 18 Clock
Serial.println(SS); // 5 Slave Select, Chip Seclect

For the A:D converters use https://docs.espressif.com/projects/esp ... s/adc.html for a more stable A:D.

viewtopic.php?t=1746 by ESP_Sprite » Tue Apr 25, 2017 8:05 pm on some good GPIO info

I use #include <ESP32Servo.h> for PWM servo driving, easy to use. Be ware of the listed pins that the <ESP32Servo.h> and if you use a hardware timer use timer 4 ( #define TIMER_FOUR 3 ), leaving 0,1,2 for the PWM. Recommended servo pins include 2,4,12-19,21-23,25-27,32-33.

Hook your ESP32 into a good quality powered USB hub instead of directly into your computer. The hub isolated the ESP32 5 volt from the computers 5 volt supply. When/if the ESP32 power regulator fails the voltage failure can reflect into the connected computer if directly connected. Also, on the ESP32's that I had to press the button before they took a upload, adding the USB hub got rid of that 'issue.'

And give Koolban $5.00 for his PDF, it is a great resource.

Like I wrote above, keep lots of notes.

Pibbotley
Posts: 37
Joined: Fri Feb 16, 2018 7:06 pm

Re: Configure GPIO 33 as digital I/O

Postby Pibbotley » Sun Feb 10, 2019 7:55 pm

You cant use pinMode() in Arduino to set pins 32 & 33 to output as they are on a separate bus to 0-31

You can add the following function to your sketch however (that I created for my purposes based on someone else's work), and call as e.g.

Code: Select all

aPinMode(32, OUTPUT);

Code: Select all

void aPinMode(int pinNum, int pinDir) {
  // Enable GPIO32 or 33 as output. 
  if (pinNum == 32 || pinNum == 33) {
    uint64_t gpioBitMask = (pinNum == 32) ? 1ULL<<GPIO_NUM_32 : 1ULL<<GPIO_NUM_33;
    gpio_mode_t gpioMode = (pinDir == OUTPUT) ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT;
    gpio_config_t io_conf;
    io_conf.intr_type = GPIO_INTR_DISABLE;
    io_conf.mode = gpioMode;
    io_conf.pin_bit_mask = gpioBitMask;
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
    io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
    gpio_config(&io_conf);
  } else pinMode(pinNum, pinDir);
}

Who is online

Users browsing this forum: Google [Bot] and 15 guests