• Hi!

    Edit: tested some more boards:

    1. Espruino Wifi - ok! (hw I2C)
    2. Pixl.Js - ok! (hw I2C1)
    3. ESP32 - not OK, my original issue, details below
    4. ESP8266 - OK! There was some issue previously with maybe my wiring?
      Tried to read an SHT21 sensor with an ESP32, but the SHT2x module did not work. Failed with CRC error, and got some console warnings about NACK by the IIC slave.
      Wiring is good, there are other I2C sensors on the same board, and those works It does work. Tried the code on an Espruino wifi, and works without any problems.

    After digging into the datasheet, and the "hold master" measurement failed, tried the "no hold master" way of things...
    You start the conversion, and poll the sensor: the SHT21 responds with NACK while the measurement is not ready. Later managed to use the CRC check and retry reading until the sensor actually finished conversion, so I have working code on the ESP32 as well. (give me some time, and will post it)

    My guess is that the STM32 and ESP32 I2C implementation differs: on STM32 it tries to read until it gets proper response with ACK from the IIC slave, and discards NACKs. On the other hand the ESP32 just returns data even when the slave said NACK.
    Does anyone know whether this is true (without digging into the C source code)?
    If it's true, is there some "official" guidance how to handle this in modules? The code for the ESP32 is of course bigger, so I guess it wouldn't benefit everyone to overwrite the current module.

    ESP8266 - used software I2C, temperature reading fails. Hardware I2C does work. Just had some unknow problem...
    Temperature reading fails with an I2C Timeout error.
    Humidity measurement works. I guess the Espruino interpreter + soft I2C is slow enough that readHumidity does not time out before the humidity measurement is complete (22-29ms accoring to the datasheet) readTemperature consistently times out (takes 66-85ms).
    But this is not the same as the ESP32, where the I2C read succeeded & ignored the NACK.
    Funnily enough my ESP32 code does work, but I guess simply because the setTimeout + speed of the ESP8266 + software I2C is slow enough.

    Used the hardware I2C1 where I could:
    ESP32: I2C1.setup({sda: D21, scl: D22}); I got the pins right, right? :)
    Espruino Wifi: I2C1.setup({sda: B9, scl: B8});
    Pixl.JS: I2C1.setup({sda: A4, scl: A5});
    ESP8266: i2c.setup({sda: NodeMCU.D2, scl: NodeMCU.D1});

About

Avatar for AkosLukacs @AkosLukacs started