Wemos R1 + D4184 Mofset + Sensor SR501 + Active Buzzer

Hi

Im trying to use this code, simple for test a sensor alarm but after a power on buzer active and non stop. I checked all connections and is apparently fine. Here the code and photos,

boolean alarma = false;

void setup() {
pinMode(4, OUTPUT); //definir pin como salida
pinMode(6, INPUT);
}

void loop(){
alarma = digitalRead(6);
if (alarma == HIGH) {
digitalWrite(4, HIGH); // poner el Pin en HIGH
delay(500); // esperar 5 segundos
}
else {
digitalWrite(4, LOW);
}
delay (1000);
}

PWM to D4 of D4184
Powersupply + and - D4184
D4184 Load - of Active Buzzer (with rectifier Diode)

  • Active Buzzer to + of D4184

Sorry for my basics of electronic but im learning :wink:


What is wired to pin 6? Are you sure it is not always reading HIGH since that will keep the buzzer on all the time. A schematic, even hand drawn would be better than those photos.

Im really bad for schematic, D6 is going to output of sensor 501. I measured the ping D4 of wemos and i get constant 3v can be the fault? i changed the code to use D5 of wemos instead of 4 but now i dont get any buzzer. I checked pin d6 and i get voltage when sensor detect movement.

Regards!!

Hi @enito

Pin 6 (GPIO6) is not D6.
Pin 6 does not exist on Wemos D1 R1.
D6 is the GPIO12

See the tables below.

RV mineirim

Hi thx for the reply ,I connect in D6 position of board . If I touch sensor I get 3.6v in D6 is working this part. The pwm part other pin is not working I see D4 have constant voltage that's the reason I get activatio of buzzer when I poweron. I changed program to use another port and nothing. Apprenñy pwm in WeMos is different, is like Made via software not hardware . Regards

Finally you have the exact solution, the real trouble of me is using D instead of GPIO real numbers you give. I changed using this and now finally works!!! thx!!!

When working with ESP8266, you need to specify Dx

alarma = digitalRead (D6);

If you want to use the notation printed on the board. If you dig down into the libraries, you will find a pins_Arduino.h file that have all these Dx defined to the GPIO pins.

Hi @enito
FYI
https://rabbithole.wwwdotorg.org/2017/03/28/esp8266-gpio.html
See table GPIO Behaviour Summary

RV mineirin

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.