Hey. I have two sensors with 3 outputs, +, -, and data (S). They need 5V on +. I have a NodeMCU and an external 5V power supply. I will connect the external power supply to VIN and G on the NodeMCU.
I have a 2n2222a331 bipolar transistor. I want to have the nodeMCU control the transistor so that the sensors are not on all the time. I don't understand common ground. How do I wire it up?. Right now im just getting 0-readings when I try to put the 5V trough the transistor and have the nodemcu control it.
The pin on the nodemcu gives 3V.
You have the wrong transistor to use for a "high side" power switch. It is an NPN, to over-simplify, you can only use it to switch something to GND.
What about the data lines? When your sensors are turned off, what is preventing voltage from the NodeMCU data line from leaking into the sensor data line?
I want to use it as a switch for the 5V supply on the sensor. I will show a diagram of how I have it hooked up now. That doesn't work (for only one sensor). Imgur: The magic of the Internet.
I put a 200 Ohm resistor.
I don't know what you mean by NodeMCU data line leak into sensor data line. This is the sensor(soil moisture): https://www.velleman.eu/downloads/29/vma303_a4v01.pdf
and the other sensor I have is for temperature/humidity
https://www.kjell.com/globalassets/mediaassets/745018_87086_manual_en.pdf?ref=A5605F6320.
I don't show this in diagram.