Oh, there is a difference. If you type gas.get() in the REPL, it prints out the result of the last statement. But if you call it somewhere in your code, it does not.
So it should be print(gas.get()); in the interval:
var i2c = new I2C();
i2c.setup({ scl : D5, sda: D4 });
var gas = require("CCS811").connectI2C(i2c);
setInterval(function() {
//gas.get(print);
print(gas.get());
//gas.on('data', print);
}, 3000);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Oh, there is a difference. If you type
gas.get()
in the REPL, it prints out the result of the last statement. But if you call it somewhere in your code, it does not.So it should be
print(gas.get());
in the interval: