ESP01 - i2c

I’m trying to get an i2c device to work on an ESP01 device. Uploading a sketch using Arduino IDE works fine but I can’t get it to work when configuring ESPHome. ESP8266-Pinout

I use the PINOuts as per the above image and configured as per below. The logs always read “No I2C Devices found”

Should this work?

i2c:
  sda: GPIO2 
  scl: GPIO0
  scan: true

I would look for a datasheet, and check connections. Off the top of my head I recall pin 4 needs to be at 3.3 volts as well.

Do you use pullup resistors for I2C?

@Kdem / @myradon - as stated in my original post, If I use the identical circuit BUT use an Arduino Sketch, uploaded from the Arduino IDE - it works fine. So I assume the connections are right?

I just wonder about which GPIO ports to use or if ESPHome does not support I2C on this board as it has a tiny memory footprint I believe.

It does cause I used it for controlling PCA9685 PWM-controller. Let me check…;

esphome:
  name: ${name}
  platform: ESP8266
  board: esp01_1m
i2c:
  sda: GPIO0
  scl: GPIO2
  scan: true
  frequency: 50kHz

I don’t know what kind of device you’re connecting through I2C. You could need a pullup-resistor on SDA and SCL to get it working. 10Kohm to 3.3V works just fine. So in your diagram from yellow and white wires resistors to VCC. BUT you need to know if display has some pullups. Just google for specs and or schematics. Cause putting extra resistor in parallel would divide resistance and upping the current. So when display already has a let say 10K pullup, doesn’t sound obvious to me, 10/2 = 5K resistance. I suspect you are missing the much needed pullups. I2C doesn’t work without 3.3V on bus. I believe SDA and SCL pins on ESP just pulls bus down… when reading specifications. Now it’s in some floating state.

You are right! It’s pin6 Enable needs VCC as well;
Screen Shot 2021-12-08 at 11.37.41

1 Like

Thanks all - I’ll try that later. It’s the display in @Kdem 's circuit that I’m trying to connect.

Thanks for your help!

The docs say

Please note the ESP will enable its internal 10kΩ pullup resistors for these pins, so you usually don’t need to put on external ones

Managed to sort it out. It was a combination of broken bad wiring and a broken sensor. The wiring suggested by @Kdem does work with the ESP01 (without pullup resistors)

1 Like

Hi, will refresh topic.
Got ESP01S and trying to connect AHT20 using i2c but without success. Trying wiring sugested by @Kdem but it doesn’t work in my case. Did someone connect this sensor to ESP01?

Did you have a succes I stuck on same point :smiley:

Yaml and logs please

I fixed it. to be honest I don’t know what I did incorrectly :man_shrugging:
But interesting two days :smiley:

Nice of you to record what worked for you.

I am using this code in ESPHOME for an ESP01 and I keep getting GPIO4 &5 for SDA SCL
Would anyone be able to guide me as to why?
I would think that the wrong pins to start are the reason why I would not get any devices on the I2C bus…

i2c:
  id: i2c_component
  sda: GPIO0
  scl: GPIO2    
[12:37:20][C][i2c.arduino:053]: I2C Bus:
[12:37:20][C][i2c.arduino:054]:   SDA Pin: GPIO4
[12:37:20][C][i2c.arduino:055]:   SCL Pin: GPIO5
[12:37:20][C][i2c.arduino:056]:   Frequency: 50000 Hz
[12:37:20][C][i2c.arduino:059]:   Recovery: bus successfully recovered
[12:37:20][I][i2c.arduino:069]: Results from i2c bus scan:
[12:37:20][I][i2c.arduino:071]: Found no i2c devices!

Hello ,
I am just starting with connection of an DHT20 temperature / humidity sensor on ESP8266-01S . Would be great if anybody could confirm the wiring setup from Kdem works also for this setup . I am quite newbee , if you could support with some yaml code for this sensor in HA with ESP home. Thanks very much .

i2c:
  id: i2c_component
  sda: GPIO0
  scl: GPIO2 

should be

i2c:
  id: i2c_component
  sda: GPIO4
  scl: GPIO5

on ESP8266-01S there is no GPIO4 and GPIO5 , mmh

My code : but it doesn’t work

i2c:
  id: i2c_component
  sda: GPIO0
  scl: GPIO2


sensor:
  - platform: dht
    i2c_id: i2c_component
    temperature:
      name: "DHT20 Temperature"
    humidity:
      name: "BMP180 Humidity"
    address: 0x38
    update_interval: 60s

ups, sry :grinning:

Lets see,