LightBlue Beans and JavaScript
The LightBlue Bean communicates with BLE. It comes with a built-in accelerometer, temperature sensor, and RGB LED. And it is Arduino compliant.
At the beginning, I wanted to install Firmata on it to play wit Johnny 5 or CylonJS, but unfortunately, impossible to compile the code(sketch) of an “adapted” Firmata version: https://github.com/jacobrosenthal/arduino/blob/bean/examples/StandardFirmata/StandardFirmata.ino. See this http://citizengadget.com/post/96226562047/firmata-on-lightblue-bean for more informations.
Finally, after a little digging, the author @jacobrosenthal of CitizenGadget is the creator of ble-bean.
@jacobrosenthal explains that:
You can program regular Arduino sketches on the Arduino, but the BLE transceiver is available no matter what sketch you have on the bean.
which means that you can chat directly with the toy …
Preparation
First of all, you have to
Now, some JavaScript
I’m using NodeJS v6, and ble-bean (do npm install ble-bean
).
We have 3 files:
beans-discover.js
, the main file
broker.js
, a kind of messages broker that allows notifications between objects
bean,js
, a kind of “wrapper” of ble-bean and noble-device**
beans-discover.js
will scan bluetooth beans, connect to them and request for temperature and acceleration, and blink the leds.
The broker: broker.js
For example, if you want that an object subscribe to an event/topic:
The bean: bean.js
The main file: beans-discover.js
And now , run it: node beans-discover.js
PS: I’ve done the test with 2 beans.
My next step: run it on a RaspberryPI 3 with some additional goodies. To be continued…
You can find the source here https://github.com/k33g/bean-soup.
That’s all for the moment…