- Temperature Sensor
- RGB LED
- Digital/Analog I/O
- SPI (Serial Peripheral Interface)
- I²C (Inter-Integrated Circuit)
- Built-in Protoboard
Communicate with the Bean
Wireless serial is the most often used way to communicate. The native Arduino Serial Library communicates with your BLE device using a virtual serial port. When using the loader app, you can enable this serial port in OS X as /tmp/tty.LightBlue-Bean. All the nitty gritty protocol serial-BLE-serial bridging is taken care of for you in the background.
1. The Serial-BLE Bridge
Start by bringing up the “SerialLoopback” example in the Arduino IDE.
Once the sketch is available, click “Upload”.
2. Program the SerialLoopback Sketch
Clicking “Upload” in the Arduino IDE, will bring up the Bean Loader App.
Select the Bean you want to upload your sketch to, double click to connect.
Right click and select Program Sketch to upload the SerialLoopback sketch to your Bean.
3. Setting Virtual Serial
Once the sketch has finished uploading, disconnect and reconnect to your Bean.
Select your connected bean, right click to choose “Use for Virtual Serial”.
This let’s you use your Bean with the /tmp/tty.LightBlue-Bean virtual serial port.
4. Select Serial Port
Navigate back over to the Arduino IDE
- Go into the Tools Menu->
- Inside the Serial Port->
- Select “/tmp/tty.LightBlue-Bean”
This is the LightBlue Serial Port that you just setup.
5. Arduino Serial Monitor
Open up the Arduino Serial Monitor by choosing:
- Tools-> Serial Monitor
Test it out by typing some stuff into the text box and press enter.
This console is where you will see the data returned from the Bean that you set up as a Virtual Serial Port.
The Arduino Bean Library
We have included an Arduino Bean Library that can be used to:
Digital I/O and I2C/SPI Buses
Here’s a diagram of the pinouts:
- To read the digital/analog pins, you use the regular Arduino digitalWrite/Read and analogWrite/Read functions you may already be familiar with.
- analogWrite is actually used on PWM pins which are digital pins
- The I2C and SPI bus libraries use the PWM pins as well.
- Wire your own battery with pins BAT and GND as V+ and V-, respectively.
- The Bean doesn’t have an on-board voltage regulator, so be sure to limit voltages between 3.0V and 3.6V.
- A0 and A1 are your typical analog input pins.
- D0-D5 offer 6 digital I/O pins.
- A0 and A1 can also be used as digital I/O, giving you 8 digital I/O total.
- Digital pins 0-3 can be used for PWM and “analog” outputs (analogWrite is really just a digital PWM output).
- SPI and I2C share these same 8 pins.
- SPI is on D2-D5, whereas I2C shares the A0 and A1 analog pins.
- Connecting both a SPI and I2C device to your bean should still leave you with 2 digital I/Os.
- The pins below the A0-1 and D0-5 pins are protoboard pins that are isolated from one another and the Arduino.
A Systems View of the Bean
To understand why the Bean library is used for certain features, we should take a look at a systems view of the Bean. This is all done behind the scenes to make the Bean easy to use.
The LBM313 is the heart of BLE communications, it communicates with the BMA250, an accelerometer and temperature sensor, as well as sets the intensities of the RGB LEDs.
The LBM313 handles all BLE traffic to and from the Arduino.
The Bean is designed this way to free up the digital and SPI/I2C bus pins on the Atmega328p, so they can be used freely in your projects.
The ATMega328P on the Bean is running at 8MHz.
This is bridged to the LBM313 using serial communication (UART at 57600bps).
We have constructed a serial protocol that allows the LBM313 and Atmega328p to communicate both messages from the client (OS X, iOS, etc.) to the Arduino. As well as send special commands to the LBM313 to do things like read the temperature sensor and set the LED.