-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble with Adafruit Bluefruit LE UART Friend #6
Comments
@monteslu @soundanalogous Any thoughts on this? It seems like an issue with Maybe a timing issue over the BLE connection since I see writing/reading of the data, but
See full log output in issue description above. |
Try setting skipCapabilities to true like this: var board = new firmata.Board(serialPort, {skipCapabilities: true}, function (err, ok) {
console.log('board created'); // <-- Never get here
if (err){ throw err; }
console.log('writing high...');
board.digitalWrite(13, 1);
console.log('done');
}); |
@soundanalogous same result (no ready emitted)
|
I'm currently using:
Not sure if this will help, but here's a picture of it wired up and connected (blue led). Here is also the serial debug output from the Nano: I've also chatted via an issue with Adafruit as I initially thought this was an issue with the board/custom firmata version, but I am able to use their Android app to control the onboard LED on the Nano. Btw, you have an issue open about them using an old version of firmata. Not sure if this has any relevancy to the issue. |
Try this: var BLESerialPort = require('ble-serial').SerialPort;
var firmata = require('firmata');
// seeing if swapping RX and TX makes any difference:
var serialPort = new BLESerialPort({
receiveCharacteristic: '6e400002b5a3f393e0a9e50e24dcca9e',
transmitCharacteristic: '6e400003b5a3f393e0a9e50e24dcca9e'
});
console.log('creating board...');
// because the payload of the capability reply is huge and will crash if the
// packets are not buffered properly from the firmware
var opts = {skipCapabilities: true};
var board = new firmata.Board(serialPort, opts, function (err, ok) {
console.log('board created'); // <-- Never get here
if (err){ throw err; }
console.log('writing high...');
board.digitalWrite(13, 1);
console.log('done');
}); |
Using the above, I now only get the
Swapping TX/RX errors in the Arduino serial console that it can't find the communicate with the Bluefruit:
I need to step away for a few hours but would love to troubleshoot later tonight (or when you have something else to try). Thanks again for you help. I've been trying to get this to work for the last week off and on with only frustration to show for it. |
That's about all as I can do on the javascript since I don't maintain ble-serial. You'll have to wait for @monteslu to help. I maintain Firmata, but since you're using a modified version from Adafruit that I'm not even sure is compatible with firmata.js, that makes things much more complicated. I do know that an Arduino 101 will work with StandardFirmataBLE and ble-serial out of the box. The Red Bear Labs BLE Nano is also compatible, but requires some modification to the RBL firmware. |
Thanks for the help. Hopefully @monteslu has some ideas I can try. It would be nice if I could use StandardFirmataBLE, but I guess that will have to wait for this issue if it does come. Adafruit's Bluefruit LE UART Friend is based on the same nRF51822 chip as Red Bear Labs' so it seems like it wouldn't be too far off to get supported (says the guy not doing the work though :) ). I currently have an existing project using a Nano with a large number of its pins being utilized (it has 3 stepper motors drivers, 2 large CIM motors with an external motor driver using PWM, and a couple potentiometers (not wired in the picture)). This is actually for the same project I still need to test some issues with ConfigurableFirmata for you (I haven't had the motors in my possession since the report and have been on vacation this week, but plan to test things out once I do). Currently this project utilizes a Raspberry PI which which acts as a wireless AP and hosts a mobile webapp, and powers/interfaces the nano over USB. I was looking to simplify this (and speed up power to connect time) by writing a React Native app that drives the Nano remotely. I initially started with bluetooth classic using a JY-MCU, but I was having trouble figuring out how to do this via react-native (as on my Mac it just creates a virtual This then lead me down the path of using ble-serial (and react-native-ble, which ultimately can polyfill Btw, I just tried to connect over to the Nano over USB (flashed with Adafruit's firmata sketch) and it doesn't connect either, but this could be due to not supporting this type of communication. Sorry for the long, and mostly off topic, comment on this issue. I appreciate your help and hopefully @monteslu has some ideas (although it could stem from a firmata compatibility issue which I'm not sure how/when that might get fixed if so). If their was another BLE hardware module that could work with my existing Arduino and worked with ble-serial better, I would purchase it in a heartbeat. |
Wait... the Bluefruit LE UART is just a UART to BLE converter. That should just work with StandardFirmata, you don't need any BLE libraries on the board. Looks like the only thing you'd need to change is the baud rate (from 57600 to 9600). |
@soundanalogous I flashed the Nano with StandardFirmata, and moved the TX/RX pins from 9/10 (was setup for software serial under Adafruit's firmata) to pins 0/1 on the Nano. I then tried running the following, setting the baud rate to var BLESerialPort = require('ble-serial').SerialPort;
var Board = require('firmata').Board;
var serialPort = new BLESerialPort();
var opts = {
serialport: {
baudrate: 9600,
buffersize: 1
}
};
console.log('creating board...');
var board = new Board(serialPort, opts, function (err, ok) {
console.log('board created');
if (err){ throw err; }
console.log('writing high...');
board.digitalWrite(13, 1);
console.log('done');
}) I now only see the writing (no reading) in the logs:
I tried swapping RX/TX pins with the same result. Tomorrow I'll pull out my JY-MCU Bluetooth Classic module and make sure it still works in a similar setup with my Nano running StandardFirmata. It eliminates the |
I forgot I would need to set the baud rate within StandardFirmata as well. Changing I did come across something interesting though. While making sure I had the baud rate setup, I decided to test it over USB using the following: var Board = require('firmata').Board;
var opts = {
serialport: {
baudrate: 9600,
buffersize: 1
}
};
console.log('creating board...');
var board = new Board('/dev/tty.wchusbserialfd130', opts, function (err, ok) {
console.log('board created');
if (err){ throw err; }
console.log('writing high...');
board.digitalWrite(13, 1);
console.log('done');
}); This works successfully as long as the RX/TX pins are also not plugged into the Bluefruit UART module, but hangs when they are. I had oddities when trying to use pins 0/1 when I first started with the Bluefruit UART and is one reason I was using software serial on pins 9/10. Also, leaving these connected causes errors when attempting to upload sketches from the Arduino IDE:
|
@soundanalogous I decided to try to get my Bluetooth Classic JY-MCU working at 9600 baud rate and in hopes to reveal an issue with my BLE setup but I'm having difficulty. I'm using the same Arduino Nano, and all works fine with the default StandardFirmata (running at I'm changing this line from var five = require("johnny-five");
var SerialPort = require("serialport").SerialPort;
var board = new five.Board({
port: new SerialPort('/dev/tty.LynchBot-DevB', {
baudrate: 9600,
buffersize: 1
})
});
board.on('ready', function() {
this.pinMode(13, this.MODES.OUTPUT);
this.loop(500, () => {
this.digitalWrite(13, this.pins[13].value ? 0 : 1);
});
}); This is the error:
If I switch back to Thoughts? Btw, here's a picture of the setup (probably not useful). This also has the issue if I leave TX/RX hooked up I receive the |
Btw, I also just tried an uppercase R for ...
var board = new five.Board({
port: new SerialPort('/dev/tty.LynchBot-DevB', {
baudRate: 9600
})
});
... ...after seeing it defined this way in the docs, but it had no improvement. |
thanks for all the details. I'll have a BLEFriend device with me tomorrow to try and replicate. In the meantime, it does look like there's an AT command for setting the baud rate on the BLEFriend itself if you want to try that. |
@monteslu You are awesome 😄 I didn't realize you could change the baud rate based on this: I found the docs and changed it to 57600 using Just a heads up if/when you test it yourself, don't forget to also set CTS to ground if using hardware UART. Here's a picture of my successful setup: Now I can move on to getting this to work on a phone using React Native and react-native-ble (hopefully...) Thanks @monteslu and @soundanalogous for all your help. |
@techniq did you end up using StandardFirmata or Adafruit's modified version? |
StandardFirmata |
I recently purchased Adafruit's Bluefruit LE UART Friend and have been struggling to get it working with
ble-serial
. I've followed Adafruit's instructions outlined here and here to wire up and flash their special version of firmata to work with the module. I am able to connect to the device successfully using their Android mobile app and control the onboard LED (pin 13) of my Arduino Nano using their app.When using
ble-serial
andfirmata.js
, I succesfully connect (blue connection light on the module turns on), but it just hangs (I never see the 'board created' log message).I ran the script with
DEBUG=ble-serial
set.Click here for the logging output
Any thoughts on how I can troubleshoot further?
The text was updated successfully, but these errors were encountered: