Hello ESP'ians!
This question might come out to be very stupid and basic, but its troubling us a little with our product development.
We are using SPI and I2C buses for various peripherals. I understand that functions that each GPIO pin performs on the ESP32 can be multiplexed, with a default function being assigned to the pins as-is on the board.
For ex: GPIO12, GPIO13, GPIO14 can be used ADC2 CH5, ADC2 CH4 and ADC CH6 respectively. They can also be used as TOUCH5, TOUCH4 and TOUCH6 respectively. And other functions are also listed against the same pins.
We need about 10-12 GPIO ports for my application. Yes, I can use a GPIO port expander, but I'm trying to keep additional hardware to a minimum.
So now if I wish to ue GPIO12, GPIO13 and GPIO14 (and some other ports) as standard digital I/O ports, how do I do it in Arudino IDE? I could paste my code, but I want to first check how do I assign one of the various functions a port is capable of performing, to that port?
Currently even when I write a simple program to toggle the GPIO pins ON and OFF, only one port (I think 14) keeps toggling, and none of the others toggle.
I've tried this on two WROOM32 boards with no luck.
Any information/direction in this regard would be helpful.
Regards,
Deepak
Using 12 GPIO ports on ESP32 WROOM32 board
-
- Posts: 166
- Joined: Wed Aug 01, 2018 12:06 pm
Re: Using 12 GPIO ports on ESP32 WROOM32 board
In setup I just do the thing like this:
pinMode( LIDAR_PowerControl, OUTPUT );
////
pinMode ( ReadSPIFF_LogPin, INPUT_PULLUP );
attachInterrupt(digitalPinToInterrupt(ReadSPIFF_LogPin), fInterruptReadSPIFFs, FALLING);
////
digitalWrite ( LIDAR_PowerControl, HIGH );
pinMode( BlinkLED, OUTPUT ); // for blink LED
Want serial ports?
You got 2/3 you can use:
#include <HardwareSerial.h>
HardwareSerial LIDARSerial( 0 );
// pin =RX, pin =TX
HardwareSerial GPSSerial ( 1 );
// pin 2=RX, pin 15=TX
HardwareSerial LIDARSerial ( 2 );
// pin 26=RX, pin 25=TX
SPI:
//temperature, pressure, altitude, sealevelpressure
#define DEVICE_PIN 5
// BME_SCK 18 // keep for reference info
// BME_MISO 19
// BME_MOSI 23
Adafruit_BMP280 bmp ( DEVICE_PIN ); // hardware SPI
Use the other SPI port:
SPIClass SPI0(HSPI);
pinMode( LIDAR_PowerControl, OUTPUT );
////
pinMode ( ReadSPIFF_LogPin, INPUT_PULLUP );
attachInterrupt(digitalPinToInterrupt(ReadSPIFF_LogPin), fInterruptReadSPIFFs, FALLING);
////
digitalWrite ( LIDAR_PowerControl, HIGH );
pinMode( BlinkLED, OUTPUT ); // for blink LED
Want serial ports?
You got 2/3 you can use:
#include <HardwareSerial.h>
HardwareSerial LIDARSerial( 0 );
// pin =RX, pin =TX
HardwareSerial GPSSerial ( 1 );
// pin 2=RX, pin 15=TX
HardwareSerial LIDARSerial ( 2 );
// pin 26=RX, pin 25=TX
SPI:
//temperature, pressure, altitude, sealevelpressure
#define DEVICE_PIN 5
// BME_SCK 18 // keep for reference info
// BME_MISO 19
// BME_MOSI 23
Adafruit_BMP280 bmp ( DEVICE_PIN ); // hardware SPI
Use the other SPI port:
SPIClass SPI0(HSPI);
Re: Using 12 GPIO ports on ESP32 WROOM32 board
Thanks. Looks like I just have to use the pinMode function. Much appreciated.
Regards,
Deepak
Regards,
Deepak
Who is online
Users browsing this forum: No registered users and 63 guests