Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By eetee
#77646 Hi,
I'm new to this board, so I hope I've posted this in the right subforum...
I have recently obtained a NodeMCU v1.0 (ESP 12-E) and would like to connect it up with a GY-BME280 "environment sensor" and GP2Y1010AU0F dust sensor and have run into a couple of problems.

The image below is exactly how everything is wired up
Image
The NodeMCU is being powered via the Vin pin using a 5V power brick. There is a 220µF capacitor used as a bypass right where I plug the brick into the breadboard

Both the GY-BME280 and GP2Y1010AU0F work on an Arduino Uno with no problems.

My first issue (in order of perceived seriousness)
  1. The ADC of the NodeMCU is reading a far lower voltage than expected from the GP2Y1010AU0F.
    • I have tested the the ADC of the NodeMCU on known references and it is producing reasonable readouts.
    • I have also tested the GP2Y1010AU0F on the Arduino Uno with the same breadboard and same wiring (the only difference is the Uno has 5V logic as opposed to 3v3 logic the NodeMCU has).
    I can only think the 2N2222 BJT I'm using may not be the most appropriate transistor to use in this situation, however, a LTSpice simulation suggests it should be OK...
  2. I am using the AdaFruit library for the BME280 module and the command
    Code: Select allbme.takeForcedMeasurement()

    not only does not work but causes the NodeMCU to hang... This is an issue as I know from experience that if I run the BME280 module in MODE_NORMAL, it runs hot (however it does "work" with MODE_NORMAL). The sketch runs past the command
    Code: Select all  bme.setSampling(Adafruit_BME280::MODE_FORCED,
                      Adafruit_BME280::SAMPLING_X1,
                      Adafruit_BME280::SAMPLING_X1,
                      Adafruit_BME280::SAMPLING_X1,
                      Adafruit_BME280::FILTER_OFF   );

    But when it's time to take a measurement, I either get nothing [because I don't use the command takeForcedMeasurement()] or the whole thing hangs [right after the takeForcedMeasurement() command]
  3. I cannot get the wire the BME280 to pins D5, D6, D7 and D8. Originally I wanted to run the module in SPI mode, however I am unable to upload the code when this pins were connected to the BME280 module. In addition, after uploading (by disconnecting GPIOs D5-D8) and the reconnecting said pins, the NodeMCU does not seem to switch on!

    This last problem isn't an urgent issue for me anymore, since I can run it in I2C mode instead but I would appreciate explanations for potential future projects...

If anyone can help or even just explain why things aren't going to plan, it will be much appreciated!
User avatar
By schufti
#77670 1) never ever switch ground on sensors

2) default for i2c on nodeMCU is D1,D2, did you change this pin definition accordingly?

3) from the gpios you selected for spi at least gpio15 is special (has to be pulled to gnd for start)
see esp docs for standard spi pinout http://arduino-esp8266.readthedocs.io/e ... s.html#spi
User avatar
By eetee
#77671
schufti wrote:1) never ever switch ground on sensors

2) default for i2c on nodeMCU is D1,D2, did you change this pin definition accordingly?

3) from the gpios you selected for spi at least gpio15 is special (has to be pulled to gnd for start)
see esp docs for standard spi pinout http://arduino-esp8266.readthedocs.io/e ... s.html#spi


  1. I'm not sure what you mean by this...
    The Arduino and the NodeMCU are not connected to the GP2Y1010AU0F at the same time if that is your concern.
  2. Cheers! I was looking to see if there were some default I2C pins on the NodeMCU board, but apparently my Googlefu sucks...
    I used Wire.begin(D3, D4); in void setup{}
    I copied pasted code from someone else's NodeMCU Arduino IDE sketch (I will link later) with the same BME280 module and made slight changes based on my experience with the BME280 module with various Arduinos.
    The module DOES work in MODE_NORMAL, but this is suboptimal since it will run hot
  3. Again thanks for this information! I will try again with a different CS pin!
I will post again after the weekends to let you know how I go... Right now I'm about to go on a camping trip, but the fact that this mini project isn't working was keeping me awake so I had to check if anyone posted any solutions...
User avatar
By rudy
#77675
schufti wrote:1) never ever switch ground on sensors


The transistor is not switching the ground. It is just used to buffer the enable signal. The control input for the sensor is equivalent to a pull up resistor to 5 volts. The transistor just takes the 3 volt signal of the ESP and allows the control signal to be switched safely.

As far as the schematic, it is not right. The 150 Ohm resistor and the 220uF capacitor is not connected properly, Vcc into the chip should be directly from 5 volts, the 150 Ohm / 220uF capacitor connection is supposed to go to the led (pin 1). That is what the data sheet shows. I don't know if this would cause the problem you are having. I would think not. https://www.sparkfun.com/datasheets/Sen ... 10au_e.pdf See page 5.

Image