I2C on 8266 Errors (NodeMCU V2)


#1

Am running ZS r2.2.0 base and using the BME280 Example and on a Node MCU V2 this is the error I get:

start...
HardwareInitializationError @[0036:001B:0040:001F:0000:0033:0000:0000]
Error:  InvalidHardwareStatusError @[003A:005E:0042:000D:0040:004A:0000:0033]
Error2:  NameError @[0000:007A:0000:0000:0000:0000:0000:0000]

On an ESP32S board the code runs fine.

The 8266 doesn’t have hardware I2C so must be bit bashed and I see it’s mapped to:

D1: SCL
D2: SDA

Under Micropython I2C works fine (software implementation), I was trying to get an I2C display working and reverted to the BME280 example code to see if my driver code was faulty.

The example code I had to change the address for the Adafruit breakout incidentally:

################################################################################
# Temperature, Humidity and Pressure Example
#
# Created: 2019-01-18 08:47:18.498321
#
################################################################################

import streams
from bosch.bme280 import bme280

streams.serial()

try:
    # Setup sensor 
    print("start...")
    bme = bme280.BME280(I2C0, addr=0x77)
    print("Ready!")
    print("--------------------------------------------------------")
except Exception as e:
    print("Error: ",e)
    
try:
    while True:
        temp, hum, pres = bme.get_values()
        print("Temperature:", temp, "C")
        print("Humidity:", hum, "%")
        print("Pressure:", pres, "Pa")
        print("--------------------------------------------------------")
        sleep(5000)
except Exception as e:
    print("Error2: ",e)

Any thoughts please?


#2

I am sorry but I am not quite sure I get what you’re asking about.
first of all, You are saying the get values example of BME280 gives that error on the NodeMCU v2, right?

Second, regarding the 8266, Does the example also not work as expected?


#3

Hi,

Thanks for the reply.

Yes the example doesn’t work on the NodeMCU v2 but does on a ESP32, the only difference I can tell is the latter has a hardware I2C and the 8266 does not.

Same BME280 breakout board and same code on both.

Iain