• Hi, I've been trying out the DIY smart meter project, however, whenever I try to read the information via the example web page, I get the error:

    Unable to decode "<- Serial1\r", got SyntaxError: Unexpected token < in JSON at position 0
    

    I was on version 2.03 at the time. I updated to 2.04 and the problem persists. I've tried stripping out all but the essential code on both the puck and the web page, but still I'm getting the JSON error. The strange thing is that once it worked correctly and the value came through to the web page. I don't think I did anything special that time and I haven't been successful since.

    Any ideas what could be causing this?

  • Hi - please can you try again now?

    The <- Serial1 error is because the Puck is saying that it's changed the REPL from being on Serial to being on Bluetooth when it's first connected, and that's unfortunately getting read in as the result to the eval, rather than the actual value.

    I just tweaked it so that the code writes something first to connect, then evals 0.5 sec later - that should fix it I hope.

    I think going forward I should probably make the Puck.js lib wait automatically if the first command used is eval

  • Yes, that seems to fix it. Works every time now. Many thanks!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Puck.js Error: Unable to decode "<- Serial1\r", got SyntaxError: Unexpected token < in JSON at position 0

Posted by Avatar for Fisu @Fisu

Actions