This is the schematic I have drawn. and the code :
Code:
#include <NeoPixelBus.h>
uint64_t chipid;
const uint16_t PixelCount = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266
#define colorSaturation 20
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt0800KbpsMethod> strip(PixelCount, PixelPin);
RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
RgbColor white(colorSaturation);
RgbColor black(0);
RgbColor purple(colorSaturation, 0, colorSaturation);
HslColor hslRed(red);
HslColor hslGreen(green);
HslColor hslBlue(blue);
HslColor hslWhite(white);
HslColor hslBlack(black);
void setup() {
Serial.begin(115200);
strip.Begin();
}
void loop() {
chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
LED_strip_ON(green,6);
delay(1000);
LED_strip_ON(black,6);
delay(3000);
}
void LED_strip_ON(RgbColor colour,int number){
for (int i=0;i<number;i++)
strip.SetPixelColor(i, colour);
strip.Show();
}
I have also implemented a sensor but not currently using it. It is 12V proximity sensor using open collector transistor. I just use a voltage divider circuit to step the voltage down to 3.3V logic level and connect it to GPIO pin of my ESP32 device. I have tested and the sensor works, it outputs me 3.3V when there is no obstacle in front of it and 0V when I put my hand in front of it.
I have 2 seperate power supplies. 5V and 12V. The very weird problem I have , when i switch 12V supply ON to power the sensor (also sends HIGH signal to one of the GPIO), after switching on 5V, the onboard LED on my esp32 turns ON, but the board does not execute code!. When I do it the other way arround, first powering the board (5V) board immidiately starts executing code, I can see LEDS blinking then I can power up my sensor by enabling 12V.
basically:
1. turn ON 12V
2. turn ON 5V
3. Board turned ON but not executing code
1. turn ON 5V
2. Board immidiately starts working(executing code)
3. turn ON 12V.
When I disconnect the GPIO sensor pin from the board, the board works fine when enabling 12V first. Can someone explain me how does sending HIGH signal to one of the GPIOs before powering board not allowing it to execute code????