Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By EdCasati
#55550 I am using an ESP-07 as basically a doorbell. (It's a much more complex project, but this is what is giving me problems.) Imagine you press the button and a tone is generated.
tone (4,1000,250);

Before the button is pressed for the first time, the speaker is completely silent.
After the button is pressed for the first time, the tone command runs, but then the problem happens.
From then on, there is a constant low level background noise emanating from the speaker. Looking at it with a scope, it is a 200mV pulse at about an 8 cps rate.

The output of GPIO4 is feeding a high impedance amplifier. I tried putting a big capacitor across the VCC and GND pins, made no difference.

My question is what could cause the GPIO port to become unstable once it is used, but not before?
I suspect the 'tone' commmand is leaving the port somehow 'on'.
Any ideas?
User avatar
By EdCasati
#55571 Found a solution for the problem.

The GPIO needs to be kept as an input until it is used, them toggled to output and when done back to input.
The real solution (I suspect) is that a pulldown resistor is needed on the GPIO n order to keep it from floating and being noisy.

pinMode(4, OUTPUT);
tone (4,500,250);
delay (250);
pinMode(4, INPUT);