I bought the nano ESP32 to use with the cloud and neopixel strips. I have a number of neopixel strips already running with Xiao ESP32 boards set up running on the cloud. So I thought it would be easy to switch over, it wasn't quite that easy.
I have an RGBW neopixel strip and my new Nano ESP32 board set up on a bread board to test. In the "define pin number" I entered 2 for the Adafruit RGBW neopixel example.
First, I compiled on my computer, and it didn't work. So I tried compiling online and it still didn't work. So I checked my circuit board, I couldn't find anything wrong, but I replace the MOSFET on my voltage converter just to make sure. Still nothing. I switched back to the Xiao ESP32 and it worked fine. This had me going for a couple of days trying to think what could possibly be wrong. So I thought just for the heck of it, I would check every pin on the nano board. Lo and behold there is my signal on GPIO2 not D2.
I tried many other programs on the nano ESP32 and they all worked fine. I tried the blink sketch, the fade sketch, the ledcWrite sketch. All of them compiled correctly using the D2 pin or "2" for the pin definition, except for the Adafruit neopixel RGBW test sketch. This could lead to some confusion, but at least I know now to check the GPIO pin also.
Is this something that is just limited to the neopixel sketches? I tried FastLED also which didn't work. But I have yet to try recompiling those sketches.
Hello @xswatts and sorry for the confusion!
The Nano ESP32 has a different pin numbering scheme in order to be compatible with other Nano-series products from Arduino. This unfortunately may cause the issues you are describing: D2 and 2 refer to the pin labeled "D2" on the board PCB using the Arduino API, but the pin labeled "A1" on the PCB (which is GPIO2) when using libraries that access pins at the hardware level, such as NeoPixel and FastLED.
You can read all about this choice here, but in order to avoid such confusion in the future, there's an easy solution:
- In the IDE Tools menu, enter Pin Numbering and choose By GPIO number (legacy);
- Make sure the sketch always uses labels to refer to pins. If you used the number
2, replace this with the symbolD2everywhere.
This will switch to a more library-compatible scheme and avoid the above confusion. Happy hacking! ![]()