Receiving data over WebBluetooth


I insalled Espruino 1.94 on the RuuviTag and try to use the Puck.js as presented in the tutorials to send commands and receive data.
While I manage to successfully connect to the RuuviTag and I can send the commands using the Puck.eval command - successfully, as I see the result printed on the IDE console - I never receive that data back.
All I get is a JSON error, because null is returned.

So my questions is, how can I receive any data (e.g. a variable with environmental data stored) over Web Bluetooth? My console remains empty, when successfully sending commands.

My goal is to setup ruuvi data collection similar to projects presented on the ruuvi page, but I would like to avoid an additional device such as a Raspberry Pi. Just walk up with you mobile phone, access a website with the display code and display the (collected) data.

Can you advice me how to proceed?


It should be doable. Does your website register to TX characteristic notifications?

This Espruino tutorial might help you to get started.


Hey Otso

I tried this tutorial and some others without luck.
I can connect to the RuuviTag. For example, the command:
The result is true.
I receive the device name and the device ID.

What do you mean by this line?

Does your website register to TX characteristic notifications?

I receive the same error when I use the “try me” link example provided in the linked tutorial.

For example I can send:
Puck.eval("E.getTemperature()", function(x) {console.log(x);})
I receive:
<BLE> Unable to decode "", got SyntaxError: Unexpected end of JSON input


It’s internals of the Bluetooth, but if you’re following the tutorials it should be ok.
Are you sure your usage of eval is correct? I haven’t tried it, but it looks like you might want to do something along the lines of

Puck.eval(“var x = E.getTemperature(); console.log(x)”);