I am trying the above example, puck is attached to the meter and blinks whenever the electricity meter is blinking. Looks good in my eyes. Unfortunately, when I try the dashboard code on my iPhone (yes, it connects) it only shows 100% battery power, everything else is black. I have let it run for 24 hours now (thought it needs some data first), but no change.
Any hint is welcome.
Btw - whenever I connect with my Macbook now (https://www.espruino.com/ide/#) it OVERWRITES the existing code on puck and all is gone. No chance to check anything. WTF?!
So you mean this example? https://www.espruino.com/Smart+Meter
Did you connect with WebBLE on your iPhone, or did you just use Safari? If you just used Saafari I can pretty much guarantee you it didn't connect, which is why it's not working.
Just connecting with the IDE should not overwrite the existing code - however obviously if you clicked the upload button, it'd upload the new code over the old code - and since previous readings are stored in RAM they would be lost.
If it's not working when you connect with your Macbook, you could look in the 'Chrome dev console' and see if any errors are reported. Typing Puck.debug=3 in the dev console before you connect will show you all communications between the Puck and the Mac
Hey Gordon, thank you for getting back so quickly. Yes, the electricity meter example.
I use WebBLE on my iPhone, the connection is definitely working. But as I said: all is black. Now I think this is because it uploads something everytime I connect - thus reseting the whole thing. How can I connect without uploading something?! One more question: what happens if the power runs out? Guess it not only shuts off, but all data is lost as well?
Ahh, that could be it. When you connect with WebBLE and the meter viewer it shouldn't reset anything, but yes, if you re-upload code with the Web IDE then it will.
You can connect with the Web IDE and it won't reset anything - just don't click the 'upload' button or type reset().
If the power runs out then the data will be lost as well. It'd definitely be possible to save the data to a file in flash memory (maybe each day at midnight) so it wasn't lost, but that wasn't implemented in the code for the tutorial.
Maybe I am blind, but I don't see any button / option to do this. How do I connect without uploading?
The button should be in the upper left corner but it is missing in your screenshot.
Could it be that an addon is "hiding" it? E.g. cosmetic filtering in uBlock Origin?
Did you sort this out?
I just tried WebBLE again here and it works fine for me - I see the connect icon
It's been my Adblocker misinterpreting the icon. Thank you!
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