Hi @anon35827816, @Wawa, @missdrew,
Back to this project! Unfortunately, I can only work a few hours a week.
I ordered different MOSFETs and I should receive them next week.
In the mean time, I wanted to try with a transistor. I have different types and I used the PNP-type: 2N3906. I made a simple circuit to make sure I understand the principle with a LED and the esp8266 nodemcu. It was flashing fine using the GPIO D5 (HIGH / LOW).
Then, I wanted to integrate it to my more complex project containing:
- the ESP12F from AZ delivery
- an ADS1115
- I regulate the voltage from the 18650 battery with the MCP1700-3302E + 1000uF capacitor (working fine)
- the 2N3906: I plugged it as shown below but the value I got from ADS.readADC(0) is 0.0! Before adding the transistor, the value I was getting was correct. I'm sure I did something wrong somewhere. Please, any help would be very appreciated.
My schematic (sorry for the poor quality) :
These are essential parts of my sketch:
...
#include "ADS1X15.h"
ADS1115 ADS(0x48);
...
int16_t sensorValue;
float sensValAvrg, potValue;
const int transistor = 14;
...
void setup() {
...
// ADS1115
ADS.begin();
ADS.setGain(2);
ADS.setMode(1);
ADS.setDataRate(0);
ADS.readADC(0);
...
}
void loop() {
...
// Turn the pot. ON
digitalWrite (transistor, HIGH);
delay(1000);
//Read Potentiometer
sensValAvrg = 0.0;
for (int i=0 ; i < 10 ; i++) {
sensValAvrg += ADS.readADC(0);
delay(100);
}
sensValAvrg /= 10;
...
// Turn the pot. OFF
digitalWrite (transistor, LOW);
delay(100);
...
}
Thank you again for your help!
Laurent
