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!
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem