Arduino + Bluetooth LE Module. Anyone ?

Hi,

Recently I bought the Bluetooth Low Energy Module from TinySine Link to the product: http://www.tinyosshop.com/index.php?route=product/product&path=65_110&product_id=705

After 15-20 days, I got my packet today and tried to test it with arduino nano

Here is the connections I made...

BLE TX ------- RX nano

BLE RX ------- TX nano

BLE VCC ------- Nano 3v power output

BLE GRD ------- Nano power ground

I connected my nano and opened arduino ( without connecting the BLE first ) to code a test sketch for at command using the softwareserial example.

I set the baud rate: 9600.

When I test run and call "AT" from my serial monitor. I don't get any response. The BLE LED state blinks and blinks..in loop which means, it's in ready state.

I contacted the TinySine Support to provide me a sample arduino code and they didn't respond. So thought I'd ask you guys for any inputs...

Has anyone faced this problem before ? Please help me out.

The BLE obviously works, pairs with iphone, android..etc.

But I couldn't make it work with arduino + AT commands.

PS: I even tried the soft tx/rx way by using D10 and D11 pins from nano and still no luck.

Looking forward for a solution, Hope you guys can help.

Rk

You might be too close to the wind in the power department, even though it is low energy. These devices are 3.3v, and I see the ad claims it works off 3.3v, but I think it might be a mistake as the normal power supply for the device in that configuration is 3.6 - 6v. This is to allow the on-board regulator to do its job properly. Usually, it is clearly marked on the backboard, but is conspicuously absent in your case. You could test this by leaning a couple of extra volts against the VCC pin. Maybe the Nano has a 5v pin.

Thanks for your reply, Nick. Are you saying that the 3.3v is not enough to connect the module with arduino ?

But when it’s powered with 3.3v I can connect the module with iphone/android devices and it works on them.

Just when I try to connect with arduino via mac/pc it is not working. The state keeps on blinking as it’s ready.

I later re-searched and ppl posted the same problem I have now.

The nano has +5v printed on board. But when I plug it in… it never works.

By the way…this is the arduino sketch I’m using…

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(0, 1); // RX | TX

void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT command:");
  BTSerial.begin(9600); 
}

void loop()
{

  // Keep reading from BLE and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to BLE module
  if (Serial.available())
    BTSerial.write(Serial.read());
}

The default baud is 9600 for TinySine BLE.
And I believe 0, 1 is tx and rx in Arduino Nano v3

PS: Also attached a real picture of the breadboard connection. The onboard blue LED + separate green LED keeps on blinking it’s state as it’s ready.

I'm saying that everything is definitely marginal and that could be the cause of your problem.

I am suss about about the stated power requirement, which is what I assume you are working on. I believe it should be 3.6v minimum, for the stated reason, and thus you are 10% short. This can't be a good idea, under any circumstances, and it may be fatal, i.e. bluetooth has enough volts to make the connection, but not enough to keep it and do some real work. As I said, it won't be hard to test that situation. I don't know anything about Nanos. The 5v pin you allude to may be input only.

I think using software serial is a bad idea, but the code seems kosher.

You might find this useful as you can test it in the serial monitor before you use bluetooth

homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

and some background here

homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf

I will be interested to see you you go, as I believe the Tinysine BLE should be used the same way as the plain-vanilla HC-05 - including the power considerations!

Setting up software serial on the same pins as the hardware serial will probably confuse matter unless you put the Nano into a reset state.

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(0, 1); // RX | TX

Setting up software serial on the same pins as the hardware serial will probably confuse matter

Gawd... and there is me saying the code looks kosher. I reckon software serial on hardware pins is a recipe for disaster and may well be the only problem. You should look to that first, even though I am still suss about the power.

Okay, I went through the PDF document and made exactly the same as instructed in there along with the example/test .ino sketch. I didn't know.. I should press the "Reset" key on my nano, till now. Thanks!

Now, It works when I send messages from my iPhone app to Arduino. Whatever MSG I enter from my iPhone, it shows here on RealTerm application. But problem is... I want to use the AT command and also send data the same way from Arduino to iPhone via BLE. How is that possible ?

One thing, I don't understand from the PDF...

A popular mistake is to try loading and testing your programme and having the bluetooth connection with the same computer. This doesn’t work because bluetooth and serial monitor share the same port on Arduino, and the same code. Note item 2. above

and Item #2 says...

You can prove the code is kosher without the Bluetooth being connected. Remember this. It can do wonders for your confidence when the connection doesn’t work, but the really important bit you need to realise is that you can do this because there are no software requirements or special commands for running bluetooth. This means no libraries. It is vital that you understand that it is just another serial device, no difference from the serial monitor, and the serial facility you already have is all you need.

If it doesn't work.. then how do I use AT Commands ? I need to use the AT commands to get my BLE mac-address, change name..etc

Now, It works when I send messages from my iPhone app to Arduino. Whatever MSG I enter from my iPhone, it shows here on RealTerm application. But problem is… I want to use the AT command and also send data the same way from Arduino to iPhone via BLE. How is that possible ?

So you have it working… If you want to send both AT commands and data, I guess you have to wire in the key pin and include the activation of that in your programme, thereby entering AT mode on the fly. I have never needed to do this, but I believe it is routine for Arduino<>Arduino communication.

rshnk90:
One thing, I don’t understand from the PDF…

OK. Maybe I should have been a bit clearer about that. That note is only to prove the most basic two-way communication and does not really address AT commands at all. This is because I don’t really have any expertise there and have had virtually no need for it.

In order to use AT commands, you are probably going to need software serial. I believe it is possible to stay with hardware serial on single port by the simple expedient of sending a stream of commands without bothering about confirmation, but I have not proven it and don’t particularly recommend it.

I believe your BLE is essentially equivalent to the HC-05. I have only programmed one of those once, and used this:

http://www.martyncurrey.com/tag/bluetooth/

Thanks Nick, I will try that instructions now and post back

Nick, unfortunately I don't have a 2k ohm... what can I use instead of that ?

I do have 1k ohm though and 2k2 .

I assume you are referring to a divider on Arduino Tx. I'm sure a 1k + 2K2 will be fine. While I wouldn't recommend it, you can get away with no divider at all. My main data-logger has been running for years with no divider. This is because I didn't know you should use one.

ok. just making sure. I will try without now...

Nope. doesn’t work. tried both 1 and 2 methods ( except the hot wire and ohms resistor )

Still no luck.

The state outputs blank… STATE = blank

I’m really tired of this. Almost everyone has this problem and instead of loosing hope I tried all day and now… nope. Not working.

I assume there is no other way to get mac addr and change name ?

I have three of those TinySine BLE 4.0 modules. Just connected one up to a USB to Serial converter, ran 5V from the converter to the BLE module, used CoolTerm on my Mac to talk to it. According to Tinysine the module is 3.3Vdc and it is, but the baseboard accepts 5Vdc just fine. Since the baseboard specifies 3.6 to 6V, I doubt it would work at 3.3 any way.

Thus, four wires, Vcc, GND, RX, TX. That's all it took to talk to it.

With Coolterm I didn't need to send the usual /r/n for the "string" dialog send. If you've paired with the module, you can't use any AT commands, it must be in an unlinked state to use AT commands.

For whatever reason, the HMSoft (BT module name) doesn't show up in my Bluetooth menu in spite of the fact I have BT 4.0 on the laptop. Haven't bothered with trying to pair it with an iPad or iPhone.

I normally use the HC-05 series for Bluetooth since I don't use BT with mobile devices. I try to get connected to the Arduino later on, think I got a Nano kicking around here someplace.

I have three of those TinySine BLE 4.0 modules. Just connected one up to a USB to Serial converter

Do you mean a serial converter something like this ? http://i.ebayimg.com/00/s/MjY5WDgyNA==/z/AzwAAOSwYGFUzHtw/$_12.JPG

rshnk90: Do you mean a serial converter something like this ? http://i.ebayimg.com/00/s/MjY5WDgyNA==/z/AzwAAOSwYGFUzHtw/$_12.JPG

Yep, that's it exactly. I used the 5V, not the 3.3V. It works fine and I could type in the AT command via CoolTerm and the module responded just fine. 9600, 8, N, 1.

I also tried the sketch you originally posted on the Nano and an UNO, it doesn't work for me either. There was some limits for Software Serial but I don't remember what they were now. I'm going to try it later on with a MEGA since it has four hardware serial ports.

Hi, I am using similar module, known as HC-06 using firmware linvorV1.8.

I'd like to tweak the firmware so that at the touch of a button would switch baud rates, for a stand alone BT to UART, manual BAUD setting.

Does anybody know where to get the source code?

Thanks for confirming, I'm going to purchase that module and see if it works for me.

By the way, I found a way to get the mac address without using the AT command.

I used the easiest method to create an simple app at MIT App Inventor 2 ( Android ) and use the app to get the mac address.

Problem now is... when I try to connect the BLE with my android the app simply freezes. No idea why is that. I tried 3rd party BLE tool, BLE term..etc some of them doesn't connect with this module and some freezes.

19657: Hi, I am using similar module, known as HC-06 using firmware linvorV1.8.

I'd like to tweak the firmware so that at the touch of a button would switch baud rates, for a stand alone BT to UART, manual BAUD setting.

Does anybody know where to get the source code?

The HC-06 is not that similar and is in AT mode only when it is not connected and, while it may be possible since you are pressing manual buttons, it's probably not worth the effort. If you do need to do it, you could press a button to momentarily break the power connection, and feed the button-selectable AT command before comms are restored. The HC-0x family usually only have two speeds - the default speed, and the fastest you can use, and, once you've got the latter, there is normally no need to change.

Sometimes it just takes me a while to figure things out. Sigh. Sure sign of age… :smiley:

So here’s how I wired it up on the NANO…

I set the IDE serial monitor to send out NEWLINE only…apparently if you send a CR or LF to the BT module it will ignore you. Like forever. So you have to send the text command only.

The sketch I threw together that worked is this one the one below. It watches the serial input from the IDE monitor for a NEWLINE character as it adds to an in memory buffer. When it finds the newline, it replaces it with a zero, then sends that to the BT module. It also converts any input from the IDE to upper case. I did find that I had to type AT in the serial monitor a few times to get the module to respond with OK. Once it does, you can use all the rest of the AT commands.

// set your Serial Monitor to send "NEWLINE" only
#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2, 3); // RX | TX
char myBuffer[30];
int buffPtr = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT command:");
  BTSerial.begin(9600); 
}

void loop() {
  handleMonitorIn();
  handleBTInput();
}
//
void handleMonitorIn() {
  if (Serial.available() > 0) {
    char theData = Serial.read();
    if (theData == '\n') {
      Serial.println("");// no cr/lf from BT, this separates it
      myBuffer[buffPtr] = 0;
      strupr (myBuffer);// convert to upper case
      BTSerial.print(myBuffer);
      buffPtr = 0;// reset the buffer pointer
    }
    else
    {
      myBuffer[buffPtr] = theData;
      buffPtr++;
      if (buffPtr > 29) buffPtr=29;// limit of input
    }
  }
}
//
void handleBTInput() {
  // Keep reading from BLE and send to Arduino Serial Monitor
  if (BTSerial.available() > 0) {
    Serial.write(BTSerial.read());
  }
}