• Hi, I'm really enjoying playing with the Espruino but recently had a small issue, mainly due to still learning to adapt from classical µC programming style. I figure this may help someone else who Googles for the keywords I did.

    I got the NFC module running well, and then wanted it to persist after reboot so typed save(). When it rebooted the I2C interface couldn't be brought up (INTERNAL ERROR: Timeout on I2C...). It seems Espruino tries to restore the state when you saved it rather than re-run the program again, which was weird to me but I get it now.

    So I figured I'd use delay() to give the NFC I2C module enough time to init, but of course there isn't a delay() function because this isn't how Espruino is supposed to work :)

    Anyway, I found putting some code in an onInit() function with the I2C init code in there, it will get run every time it powers on. This may seem obvious but onInit() is not yet documented in the Espruino reference as far as I can see.

About

Avatar for thomc @thomc started