Hi, does anyone have experience with the tone function on Nodemcu? I'm trying to do the retro reflective sensor described here:
I had to power the emitter down a "little bit" because I only need it to work for 1.5meters. I removed the transistor and added a 680ohm resistor to the IR led by trial and error.
It worked perfectly on a Nano and a Micro, but I really wanted it to be networked, so I moved to a Nodemcu, which is 3.3v.
The IR receiver seems to work fine because I tried with a IR led connected to a Nano.
But the emitter does not work. I can see the LED on a phone camera and it looks ok. I thought there was too little power so I removed the resistor, still nothing. Then I added the 2N2222 transistor and the LED is VERY bright on the phone camera. But sill the receiver only picks it up from 20cm, instead of 2m...
I simplified the code as much as possible:
void setup() {
pinMode(D3, INPUT);
pinMode(D7, OUTPUT);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
tone(D8,38000);
if (digitalRead(D3) == HIGH) {
Serial.print("BREAK");
digitalWrite(D7, HIGH);
}
else {
digitalWrite(D7, LOW);
}
}
So, I'm thinking that maybe one of these is the problem, can you help?
Is it possible that the tone does not work well on Nodemu?
Does the 3.3v instead of 5v mean more that I think? I don't really have much experience with electronics, I've done stuff with modules, but not low level components.
I'm clearly overpowering the LED right now at 3.3v with a transistor, maybe it looses the frequency somehow?
Thank you for any help, I'm really out of ideas.
Dan