Studio Contrechoc

design & textile & technology entries

Monthly Archives: May 2015

Teensy 3.0, BlueSMiRF and Mindwave

In the last post the Serial and SoftWareSerial of the Arduino and Coolterm and the UART of the BlueSMiRF were performing some acrobatics, but it is all possible.

bt20

After buying a Teensy LC and Teensy 3.0 this acrobatics was made much more simpler using the possibilities of combining USBSerial and Serial1. On the Teensy 3 Serial Ports are available.

With the Teensy the BlueSMiRF is connected to a Serial Port and the data can be seen in a Serial Window:

Screen Shot 2015-05-12 at 09.02.17

And because this project involves servo motors, it is nice the Teensy has so many PWM Pins and Timers!

The basic Arduino BlueSMiRF test script can be found here:

https://github.com/contrechoc/Meab_scripts/blob/master/Teensy_BlueSMiRF

You can find how to configure the BlueSMiRF for connecting to the Mindwave here:

https://learn.sparkfun.com/tutorials/using-the-bluesmirf

https://learn.sparkfun.com/tutorials/hackers-in-residence—hacking-mindwave-mobile

The Teensy page on Serial UART:

https://www.pjrc.com/teensy/td_uart.html

 

 

 

Advertisements

Bluetooth boards and the Neurosky Mindwave

For some project the Mindwave Neurosky with bluetooth was interesting. Jostie quickly made an Android App, which could connect to the Mindwave during the 2015 NASA App Challenge weekend in our neural network attempt: https://2015.spaceappschallenge.org/project/neural-network-space-fashion/.

bt8

His app can be found here:
https://github.com/Josvanegmond/Adressable

bt9 From Mindflex, with Serial to Mindwave Mobile with bluetooth

But we wanted the signals directly available for a wearable. For this a bluetooth board was needed, which could connect to the Mindwave. Several options were available.

By studying two tutorials constraints for this setup are becoming clear:

  • The board has to have the possiblity to behave as a master, connecting to the Mindwave.
  • The communication has to be Serial (that is fast) and not SoftWareSerial (two reasons for this!)

Tutorials:

We tried different boards (although we could have guessed that only the boards mentioned in the tutorials would function 🙂 —stubborn!—


bt3  older BT board, old – hard – school – command coding RX-TX connection

Easy Bluetooth (http://www.parallax.com/ not for sale anymore?)
This is an “older” board, from a few years ago. No problem connecting and using as a slave. There is more: https://www.jameco.com/Jameco/Products/ProdDS/2109261.pdf. In this pdf of 100 pages you can see that you can enter the command mode, and make this board a master. But … this is the real stuff in command BT-coding, will cost some time to study.


bt5 see the wires: SPI connection: 6 besides the V and GND

Bluefruit LE – Bluetooth Low Energy (BLE 4.0) – nRF8001 Breakout (http://www.adafruit.com/)

A recent board. Communicating easily with an app, sending to a wearable. This board is easy to connect to, but functions as a slave. So for our purpose this board cannot be used. Besides, compared to the other boards, the SPI connection has a lot of wires…

The documentation from Nordic is also extensive: https://www.nordicsemi.com/eng/content/…/2981/…/nRF8001_PS_v1.3.pdf .


bt4 very nice, “designed” connection at the FTDI of this RF12 board

Bluefruit EZ-Link – Bluetooth Serial Link & Arduino Programmer – v1.3 (http://www.adafruit.com/)

This is a board with some nice possibilities as can be discovered here:https://learn.adafruit.com/introducing-bluefruit-ez-link/tour.

It can be connected to the FTDI header of a Jeenode, making the Jeenode having both the RF12 and bluetooth wirless.

The board has an optional JST connection. So you can make a standalone module witha lipo attached. Only problem: the lipo in the JST connector is always on: no on-off switch. So in practice this connector requires soldering a switch in the wiring to the lipo, which is not fun.

But as can be read in the FAQ of Adafruit:
Can EZ-Link act as a BT ‘master’?
No, it is a client-mode only device.

End of story for our purposes.


bt1 without the BEE carrier, programming with the AVR SPI mkII

Bluetooth Bee – Standalone ( http://www.seeedstudio.com )

This board has a bluetooth part combined with a ATmega168P (Not an ATmega168 as told in the wiki).

The wiki can be found here:http://www.seeedstudio.com/wiki/Bluetooth_Bee-Standalone.

Getting this board working did cost more time. Using an AVR ISP mkII programmer (not the X Bee carrier) was the first hurdle. After a while the J1 connector functioned – or the configuration was understood.. Uploading code was possible after adding the ATmega168P code to the Arduino boards.txt file, using the shift-U command in the Arduino environment.

Screen Shot 2015-05-07 at 09.54.15 Screen Shot 2015-05-07 at 09.55.27

(Our AVR ISP mkII is hacked so that it provides either 5V or 3.3V directly to the board – this one needs 3.3V.)

The LED’s (red-blue) on the BT board code as follows (no the description in the wiki): Master mode: double fast blue: not connected, single blue: connected. Waiting to pair: red, blue alternating.

If paired right from the laptop you get a BT – Serial link in the Arduino environment. Opening this as a serial monitor initiates the pairing, the key “0000” is given automatically. The board is in slave mode. The example code worked, the led could be lit and “shut”.

Screen Shot 2015-05-07 at 09.55.02

But the master mode is needed.

At this page about the Bluetooth Bee you can find the commands :http://www.seeedstudio.com/wiki/Bluetooth_Bee

The code used to get the master mode using the commands can be in the scripts at github:

 https://github.com/contrechoc/Meab_scripts/blob/master/bluetooth_bee_standalone_master

The communication is done using SoftwareSerial. On this board communication is hard wired using pin’s 2 and 3. See the schematics at: http://garden.seeedstudio.com/images/f/f6/Bluetooth_Bee_Schematic_Board.zip.

This hard wired connection is the problem for our project. For the Mindwave to give signales regularly a faster connection is needed than the SoftWareSerial can provide—the “normal” Serial connection on pin 0,1 is much faster—, as will be seen in the last bluetooth board which is tried out. The signales are coming through with SoftWareSerial, but apparently there are so many bits falling out that sometimes you have to wait seconds or even 10’s of seconds for new values of the Mindwave.

The script using this Bee Standalone board can be found here: (mind the baudrate which is set at 57600, default 38400 – start using this value to set the baudrate at 57600). It functions, the LED signals received values from the Mindwave, but not too often and at irregular intervals.

The second problem for our project is also related to using SoftwareSerial. We want to transfer the values from the Mindwave to servomotors. But the Servo lib and the SoftWareSerial lib are incompatible (probably they use the same timer).

So also this board is not what we needed.

Nice post in Japanese: http://leibun-tech.blogspot.nl/2012/12/bluetooth-bee-standalone-android.html,


bt2 nice and clean, connected to an ATmega328 board with RF12

 BlueSMiRF Silver (https://www.sparkfun.com)

This board was mentioned in both the relevant tutorials. So no wonder that this board functions. Using the command mode it can be programmed in Master mode and the MAC address of the Mindwave can be entered. Connection and reconnection is done automatically.

In our project we spent time using the SoftWareSerial instead of the Serial port, with the intention of debugging. The speed difference resulted in dataloss (apparently) and only some packages of the Mindwave were received in minutes. With the Serial, pin 0,1, Mindwave values enter once or even twice a second.

SoftWareSerial was used to communicate with Coolterm (or other Serial monitor) to see what was happening and debugging. This interfered with the servo motor lib.

The ATmega328 board (Jeenode) with the RF12 provided a solution: bluetooth signals from the Mindwave are received using the UART of the Smirf, then the signals can be transmitted using the RF12 transceiver. These signals can be received in a similar board.

Scripts using the Mindwave and this board can be found at:

https://github.com/contrechoc/Meab_scripts/tree/master


The projects with these boards and scripts will be presentated later…

bt7