How to connect I2C at nodeMCU

  • Hey there,

    I use a nodeMCU as ESP8266 gateway and wanted to add a few sensors to it to avoid using a sensor node right next to the gateway. I first tried with a temp sensor Si7021. But how to connect it to? Vin and GND is obvious, but SDA and SCL...
    Somewhere I found to connect them to D1 and D2, but the NRF is already at D2 with its CE pin. Is it possible to define them freely to other GPIOs without interfering with MySensors lib? I though about using GPIO09 and 10, as they are free and near to my Si7021.

  • I found out some part via google, but still some trouble. Maybe someone can help:
    I have the SDA and SCL connected to GPIO9 and GPIO10 of my nodeMCU (labeled SD2 and SD3). When uploading my normal ESP8266OTA sketch everything works fine and gateway is running. I added the Wire.begin(9,10) at the beginning of setup to set the pins used for I2C.

    void setup() {
      Wire.begin(9, 10);
      ArduinoOTA.onStart([]() {
        Serial.println("ArduinoOTA start");
      ArduinoOTA.onEnd([]() {
        Serial.println("\nArduinoOTA end");
      ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100)));
      ArduinoOTA.onError([](ota_error_t error) {
        Serial.printf("Error[%u]: ", error);
        if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
        else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
        else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
        else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
        else if (error == OTA_END_ERROR) Serial.println("End Failed");
      Serial.print("IP address: ");
      //    if (!bmp.begin())
      //    {
      //      Serial.println("Could not find a valid BMP085 sensor, check wiring!");
      //      while (1) {}
      //    }
      //metric = getConfig().isMetric;

    But as soon as I enable the sensor.begin() or bmp.begin() it's not working anymore. I get resets with the following message in serial monitor:

     ×Åü1¤ñþ0;255;3;0;9;Starting gateway (RNNGE-, 2.0.0-beta)
    0;255;3;0;9;Radio init successful.
    state: 0 -> 2 (b0)
    state: 2 -> 3 (0)
    state: 3 -> 5 (10)
    add 0
    aid 5
    connected with WiFi, channel 1
    IP address:
    ü!m!„þæÊõþ0;255;3;0;9;Starting gateway (RNNGE-, 2.0.0-beta)

    When using the BMP085test example sketch from the library I get

     ets Jan  8 2013,rst cause:4, boot mode:(3,7)
    wdt reset
    load 0x4010f000, len 1264, room 16 
    tail 0
    chksum 0x0f
    csum 0x0f

    Does anyone knows if that is a problem of incompatible library or any other hint how to solve?