I have the following really small snippet...
// Create an I2C instance
i2c <- I2C(0);
// Set speed to 400 kHz
// Set address
local htu21d = HTU21D(i2c, 0x40);
temperature = htu21d.readTemp();
humidity = htu21d.readHumidity();
print("temp=" + temperature + "\n");
print("humid=" + humidity + "\n");
It runs and produces reasonable results the first time. However subsequent attempts to run it result in:
%%Runtime error [unable to open I2C device]
*FUNCTION [main()] sd:/htu21d_demo.nut line 
I'm sure I'm just doing something stupid...