ESP-01 remove control of light (not relay) - beginner

Hi, I would like to ask you (already search for that on this forum and on many google pages) and I would like to ask you for advice what I am doing wrong (please, be constructive).

First at all, my home simple project is about using ESP-01 to control light (let stripes).
How to control? By button and by wifi. (button, not switch).

Using DC 9V adapter + stepdown on 3.3V for ESP-01 + button + MOS module. Programming over programer module with extended button for “writing code”.

Questions:

  1. So I am using StepDown on 3.3V to power my esp01, but step down have Vo- (output minus). Didnt find better way than just switch it with gnd to make it positive (its looking very very ugly, but can someone provide better solution?) Because this one one works (I have +3.3V)

  2. Trying to implement simple code which every 0.5s check if button is pressed, if yes = turn on MOS module. If in next checking will be button pressed again - its mean that user want to turn off the light = MOS module off. But didnt handle pins as GPIO/2 well because it do nothing. Can someone look on that scheme and code and say me what I am doing wrong?

// kitchen light v1
const int BUTTON=2;
const int LED=0  ;

bool power = false;
unsigned long lastMeasurement = 0;

void setup() 
{
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, INPUT);
  
  digitalWrite(LED, power);
}


void loop()
{
  if(millis()-lastMeasurement >= 500)
  {
    if(digitalRead(BUTTON) == HIGH)
    {
      if(power)
        power = false;
      else
        power = true;
    }
    digitalWrite(LED, power);
    lastMeasurement = millis();
  }
}

ESP01 is oriented into that holder as on picture.

Button is connected to + and to GPIO2
MOS module is connected to GPIO0

The connections on the step-down converter are very strange. Can you post a link to the spec for it?

Have you established that your uploaded sketch is running on the esp when on the breadboard? I suggest uploading the standard blink sketch and attaching an ordinary led (+series resistor) to an output, to prove to yourself that the sketch has uploaded correctly and is running on the breadboard.

I suspect, even if it is being powered correctly, that the sketch is not running. To get the sketch to run, several pins on the esp-01 must be pulled high: CH_PD, RESET must be pulled high full-time and GPIO0, GPIO2 must be pulled high at power-on/reset. I don’t see anything in your circuit to achieve that.

Also I suspect the pin that the button is connected to is floating. When the button is pressed, it is connected to Vcc, but when not pressed, it is connected to nothing, and will not necessarily read LOW as you might be expecting. You should pull the GPIO pin to Vcc with, for example, 10K, and have the button pull the GPIO pin to ground when pressed.

You have a number of very questionable solder joints on your home brew 8 pin ESP adapter board.

Hello
I´ve made some mods to your sketch.

  1. changed INPUT to INPUT_PULL —> connect the button to GND now.
  2. simplification and modifications of the actions inside the millis() timer.

The sketch has been tested on an UNO. You have to arange the pin setting to your application.

// kitchen light v1.1 - //   pinMode(BUTTON, INPUT_PULLUP); 
const int BUTTON = A0;
const int LED = 2  ;
bool power = false;
unsigned long lastMeasurement = 0;
void setup()
{
 // button ist conneted to GND   
  pinMode(BUTTON, INPUT_PULLUP); 
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
}
void loop() {
  if (millis() - lastMeasurement >= 500)
  {
    lastMeasurement = millis();
    if ((!digitalRead(BUTTON)))
      digitalWrite(LED, digitalRead(LED) ^ 1);
    else
      digitalWrite(LED, LOW);
  }
}

I can say that I agree that connection of step down look strange.
Could not find datasheet anywhere. But at least what google say:
stepown_back

Problem is that when I have V0- output it give me negative 3.3V, ground is common. But when I switch Vo- and Gnd, I will get positive 3.3V.
At least everything is shining (esp). That was my part of question that I am getting negative -3.3 V if I connect multimeter on Vo- and Gnd.

Also when I have this connection I can put MOS module ON/OFF

About uploading code, thats good idea just try one led.
Even I expected that when I upload code I didnt find any error in log:

True, I had some difficulties but they are now clean and no short circuits.
esp4 esp3

I know, crazy but its working. Check and no short circuits.

Do you mean during uploading code or during running?
Can you show me how exactly you mean it?
It will help me a lot! :slight_smile:

So it’s a negative DC converter? This is a specialist part intended for use where a negative output voltage is required for a circuit. You may be able to power the esp with it by swapping the wires as you have done, but I do not think your MOSFET module will operate correctly like this. The MOSFET module is designed to switch a positive voltage with a positive control voltage. Your control voltage will be negative, so I do not think the MOSFET module will switch on and may even be damaged by this.

You should replace your DC converter with a normal one which outputs a positive voltage.


As you can see from the above, in order to get the esp-01 to boot from flash memory and run your uploaded sketch, you need CH_PD and RESET connected to 3.3V. You can connect these with 10K resistors or simply use wires.

By the way, if you wanted to add an extra button to reset the circuit, you would need to connect the RESET pin to 3.3V with 10K (not a wire) and connect a button from RESET pin to ground.

For GPIO0 and GPIO2, you need a 10K pull-up to 3.3V to get the esp-01 to boot into the correct mode. You can connect your on/off button from GPIO2 to ground. You will need to change your code to check for a LOW reading when the button is pressed, and to output LOW to GPIO0 in setup() to switch the MOSFET module off. Unfortunately, this does mean your light may flash on briefly at startup.

Hi, thank you for your answers. Really like that I have some interaction with someone who have more experiences with that.

Also I have now two programmer boards.

The smaller programmer board: by manual I connect over button GND and GPOI0. Which I need to press during connecting USB. After that I release button and succesly upload code. (In another case it search for connection during uploading code). After that it ask me to push reset button (don’t have any button around), So I unplug it and plug it without pressing any button.
In that moment I open serial monitor and see that my code was uploaded correctly because my code is printing loop (also read that serial print is on the same channel as diod so it always blink blue diode in moment of printing text).
loop
code:

int count = 0;
void setup() {
   Serial.begin(115200);
   Serial.println("Serial start");

}

void loop() {
  Serial.println("Loop: " + String(count));
  count++;
  delay(1000);
}

So I guess that uploading code is “ok”.

Now the part of running board without programmer board. (Just ESP01+power+some wires)

These are the two proper programmer boards for the ESP-01:
Aliexpress item
At least, that is the manual switching version; here is the automatic version which while it does have the reset button, initiates the programming directly from the Arduino IDE:
Aliexpress item