I'm trying to connect my ESP32 to this CO2 measurement device. I admit I am clueless about connecting devices with independent power sources to one another.

I connected ground to ground and CLK to PIN2. Just to be on the safe side, I put a resistor between CLK and PIN2.

I started with 4.8KOhm of resistance. ESP's ADC measured 2.1V and it seemed fine. But when I switched to 1K resistor, trying to get closer to the level of "logical 1" (the way I understand it), something unexpected happened. ADC measured 2.65V, which is still beyond 3.3V ESP should be able to handle, and the built-in LED lit up, although nothing in my sketch called for it.

Though the configuration worked stably for some minutes while I was testing it, and no smoke appeared, I am afraid the LED lighting spontaneously might be a sign of an electrical breakdown.

The both devices are sitting on the same USB hub.

Here is the sketch I am using:

#define PIN_CLOCK  2

void setup() {
  pinMode(PIN_CLOCK, INPUT);
bool last = 0;

void loop() {
  int x = analogRead(PIN_CLOCK);
  bool val = x > 1500;  
  if (last != val)
    last = val;    

Can someone explain why the LED lights up?

Can someone recommend a good article/video on basic rules about interconnecting such devices?


You do not need a resistor in the circuit. Just connect the devices together directly as shown in the tutorial you link to. They are both 3.3V devices and operate perfectly together with no additional components.

Reading an analog value from a clock signal is pretty meaningless anyway, so there's really no point in your experiments at the moment. They prove nothing.

As to why the light came on - that is most likely because the ESP is configured to use that LED to indicate the WiFi status or something similar. The thing with an ESP32 is there is a whole lot more going on than just your code. Your code is just one thread in a complex system.

  • > The clock pin is an output from the ESP to the nRF24L01. Could you expand on that? I have probably misled you, by calling it "CLK". I meant I connected what in the tutorial called ZG-C to D2. nRF24L01 is a part of a different setup. Still the question is: "why the built-in led"? – Ilya I. Margolin Jan 22 at 12:47
  • Ah, so you're using section 3.2 of the tutorial? It still stands that you don't want a resistor in there. As to the internal LED - that may be being controlled by the WiFi code and have nothing to do with what you are doing. – Majenko Jan 22 at 12:50
  • A schematic would be a big help and maybe links to the particular modules your using and there data sheets. – Gil Jan 22 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.