-
• #2
First thing I would try is:
var ow = new OneWire(B13); var temp = require("DS18B20").connect(ow); function onInit() { I2C1.setup({scl:B6, sda:B7}); lcd = require("HD44780").connectI2C(I2C1); setInterval(showData, 5000); } function showData() { lcd.clear(); lcd.setCursor(0,0); lcd.print("Current temperature:"); // Get the temperature var t = temp.getTemp(); // Round it to the nearest 0.1 t = Math.round(t*10)/10; lcd.setCursor(0,1); lcd.print("Temp = " + t + " C"); } onInit();
That way, we're not trying to talk to the display until after we've set up I2C.
-
• #3
And of course it just works now :)
Thanks ever so .. blindingly obvious now that you point it out, but was definitely working in that form, for some reason, on a previous version.
Thanks a million.
-
• #4
Great! Glad it's sorted...
I think in previous versions Espruino's software reset didn't reset the peripherals (like I2C). That'd mean that the very first upload wouldn't work, but after that I2C would stay set up from the last time...
-
• #5
Ah ! Nice to know what was going on, thanks.
I have been running this little program for months just to display temperature ..
I updated to 1.69 just now (actually not sure what the previous version was) and see this .. which means little to me :( Can anyone here tell me what might have broken and how to fix ? I've swapped the LCD for another, but the same problem ...