Help with using Bluetooth module (AT-09) with Nano

Hi everyone,

I'd appreciate some help with Bluetooth comms. I have a Nano connected to an AT-09 Bluetooth module (BLE), as shown in the picture below.
unique boy names that start with r

The Nano is running code that allows the Arduino IDE Serial Monitor to send AT commands to the AT-09 and display its responses. This setup works perfectly well and I can successfully use AT commands to change and read the status of various parameters in the Bluetooth module. AT+HELP returns the following:

Ultimately I'd like to get two Arduinos (each with an AT-09) to communicate over Bluetooth - but for now, I'd just like to establish comms between the Nano and AT-09 and my phone (Sony XZ2 Compact) or some other Bluetooth master device - and this is where I need help. I have a few apps on the phone for connecting to Bluetooth devices, but connecting to the AT-09 isn't going too well...

The AT-09 is set to be a slave (AT+ROLE0). My phone can find the AT-09 when I scan for Bluetooth devices, but struggles to connect to it - the phone asks for a PIN but seems to do nothing when I enter the PIN. The PIN is correct, I have set different PINs using AT commands but still get the same response after entering the PIN on the phone. I have used the AT+TYPE command to enable/disable the use of a PIN in the AT-09 but still the phone just doesn't connect.

Bluetooth apps on the phone:
Serial Bluetooth Terminal - doesn't find the AT-09 when checking for Bluetooth devices
HMBLE Terminal - doesn't find the AT-09 (and often crashes)
B-BLE - does find the AT-09, connects and shows the following info that has been read from the AT-09:
free images hosting
(the screenshot doesn't show all of the parameters sent from the AT-09)

At this stage, I'd like help with simply transferring some data between serial terminals - i.e. between the Arduino IDE and the phone. I'm not that familiar with Bluetooth, so I'm not sure if I'm going about this in the wrong way. Perhaps there is a parameter in the AT-09 that I'm not aware of and haven't set correctly, or perhaps there's a more suitable Android Bluetooth serial terminal?

I'd appreciate hearing your thoughts, many thanks!

Even if the picture is not a pro Mini, I think you have said enough to suggest your wiring and code are kosher, and therefore your problem may be at the other end. First, you must ensure that your phone app is compatible with BLE. Not all are. I use the Kai Morich terminal, which is selectable between BLE and plain vanilla Bluetooth. I don't know of any others, but there must be several.

I believe the AT-09 is the same as the HM-10, so you don't use the phone settings and no password. You just connect direct from the app instead.

Nick_Pyner:
Even if the picture is not a pro Mini, I think you have said enough to suggest your wiring and code are kosher, and therefore your problem may be at the other end. First, you must ensure that your phone app is compatible with BLE. Not all are. I use the Kai Morich terminal, which is selectable between BLE and plain vanilla Bluetooth. I don't know of any others, but there must be several.

I believe the AT-09 is the same as the HM-10, so you don't use the phone settings and no password. You just connect direct from the app instead.

Thanks Nick,
Yes, I've just realised that I've been mistakenly saying Pro Mini for my Nano! (original post is corrected now).

I have the Kai Morich app (Serial Bluetooth Terminal), but when it scans for BLE devices, the AT-09 isn't found. Any thoughts on this? (The B-BLE app does find the AT-09, so the module is working, to some degree).
Edit: Serial Bluetooth Terminal is now finding the AT-09, it seems that the app needs Location Services to be enabled on the phone.

Incidentally, the factory name of AT-09 (AT+NAME) is BT05... do you know if that makes it different from an AT-09 or HM-10?

Andy_C_:
it seems that the app needs Location Services to be enabled on the phone.

Ah, now THAT'S interesting. I will add that to my notes. Thanks.

Incidentally, the factory name of AT-09 (AT+NAME) is BT05... do you know if that makes it different from an AT-09 or HM-10?

I think my HM-10 came up as BT-05, but I can't remember, and I've changed the name anyway. I have very little experience with HM-10, and have never actually used it for anything.

1 Like

So I got the Nano+AT-09 sending data to the phone app, and vice versa - success!

However, now I have a new issue. I set up two AT-09 modules, each connected to its own Arduino. I set one AT-09 to be a master (AT+ROLE1), and told it to bind (AT+BANDxxxx...) to the other AT-09 which is set as a slave. The two devices appear to connect - both modules' LEDs stay on continuously, and the Arduino IDE Serial Monitor displays "Connected" (master module).
The problem is this: when I power-off the slave AT-09, the master AT-09 gets stuck in a scanning mode, continuously trying to find the slave module - and it doesn't respond to AT commands from the Arduino IDE Serial Monitor (it did respond to AT commands from the Serial Monitor before I set it to bind with the slave. Now it just says "Scanning..." over and over again).
Any thoughts on how I can get it out of this continuously scanning mode, and respond to AT commands again?
Thanks!

Andy_C_:
Any thoughts on how I can get it out of this continuously scanning mode, and respond to AT commands again?
Thanks!

Hummmm. I'm not at all sure of the point to this. I think master is only doing what you have configured it to do - scan for the predetermined slave and auto-connect when it finds it. Having said that, Bluetooth is in AT mode by default, and stays that way until a connection is made. I therefore hope you can simply send an AT command, now there is no connection, even though Arduino is saying "Scanning". If the above is incorrect, I guess Bluetooth's status is one-way, i.e. it goes

power-on
AT mode
comms mode

but requires power-off to get back to power-on. This means you need Bluetooth's power under hardware or software control, rather than simply being connected to the 5v pin in the normal manner.

Note that, while I wax lyrical about Bluetooth auto-connect, there are other means of connection which you may actually find more suitable. I assume they are interactive, and therefore probably more suited to BLE than HC-05. Check the Martyn Currey website, this is definitely outside my bailiwick!!

Another source is Philippe Cantin, who was a bit of a pioneer in this arena.

Nick_Pyner:
Hummmm. I'm not at all sure of the point to this. I think master is only doing what you have configured it to do - scan for the predetermined slave and auto-connect when it finds it.

Yes, you are correct... the master is connecting to the slave as I configured it to do. However, further to this, the slave is set up to send some test data every 5 seconds, and the master should receive this and send it to the Arduino IDE Serial Monitor, but the master does not. So, I'm trying to examine the master side of the setup to see if it is running as expected. (The slave appears to be working fine because I can use BT Serial Terminal on the phone to receive the test data sent by the slave every 5 seconds). However, I can't do anything with the master while it's in this continuous scanning mode. It just sits there scanning. It won't accept any AT commands. This seems strange though, because, as you said, when the master is not connected to a slave, it's not in comms mode, and so therefore should be in AT mode. Perhaps scanning for a slave is part of comms mode?
I've been looking through Martyn Currey's website, it's very comprehensive, but nothing of note on my issue so far unfortunately.
I'll have a look at Phillipe Cantin's work...

Andy_C_:
the master should receive this and send it to the Arduino IDE Serial Monitor, but the master does not. So, I'm trying to examine the master side of the setup to see if it is running as expected. (The slave appears to be working fine because I can use BT Serial Terminal on the phone to receive the test data sent by the slave every 5 seconds).

This is sounding rather like it is time to post your code, but first check here, as this may be no more than slack-arsed interrogation of the data stream. But, as I said, there could be a problem where AT mode can only be obtained by breaking the power supply. There is clearly nothing wrong with the slave. I'm still not sure what the problem is, and I am altogether suss about this "scanning" stuff. I think this is just a meaningless word sent by Arduino, and I imagine that, by the time Arduino got round to doing that, the scanning exercise would be well and truly over.

If the master will not accept AT commands, it is because it is not in AT mode.

The scanning is done while in AT mode because that is the default, and the comms connection is yet to be made. I don't think this is relevant.

I've had a look through the Serial Input Basics as you suggested, and it all makes good sense. However, my code is not at that level of sophistication just yet. Right now, I just need the Serial Monitor to display whatever data is received by the Bluetooth master module - the data doesn't have to make sense, I just want to make sure that data is flowing. Once the data is reliably flowing between the Bluetooth modules, then I'll improve the code to interpret the data appropriately. I'm doing things one step at a time, as I'm learning as I go.

Below is the code that's running on the Arduino+masterBT module. The code simply passes anything that is typed into the Serial Monitor (hardware serial port) and passes it to the Bluetooth module via a software serial port, and vice versa. All ports are set to 9,600 baud (software serial port between Arduino and AT-09; hardware serial port between Arduino and Serial Monitor), Serial Monitor is set to both NL and CR. I realise that the code is a relatively blunt tool - it just passes data back and forth between the hardware and serial ports, but it works perfectly well for sending AT commands and receiving responses to those commands - so it should work the same for data?
Is there anything you can see in the code that would prevent the data from the slave from being passed to the Serial Monitor?
Many thanks!

// This code simply passes anything that is typed into the Serial Monitor (hardware serial port) and passes it to a Bluetooth module via a software serial port, and vice versa

#include <SoftwareSerial.h> // Library for the software serial port

SoftwareSerial mySerial(2, 3); // RX, TX Set up and assign hardware pins for software serial port

void setup()
{
Serial.begin(9600); // Start the hardware serial port with a baud rate of 9,600

Serial.println("Enter AT commands:"); // Prompt the the user to enter AT commands in the Serial Monitor

mySerial.begin(9600); // Start the software serial port with a baud rate of 9,600
}

void loop()
{
if (mySerial.available()) // Check that the software serial port is ready
Serial.write(mySerial.read()); // Take what's received by the software serial port and send it to the hardware serial port

if (Serial.available()) // Check that the hardware serial port is ready
mySerial.write(Serial.read()); // Take what's received by the hardware serial port and send it to the software serial port
}

Andy_C_:
However, my code is not at that level of sophistication just yet.

Probably not true. One step beyond the crudest code takes you into Robin's realm...

Having said that, it seems that you simply want to prove two way traffic. This is about as basic a proof as you will ever get. It is for SLAVE Bluetooth and PHONE.
I published it in conjunction with
Dropbox - GUIDE_2BT.pdf - Simplify your life , which you probably don't need to read!

Probably not want you want to hear but BLE is messy and it is much easier to use Classic Bluetooth e.g. HC-05
That said, this project uses BLE HC-10 to connect to my (paid) pfodApp.
and the free pfodDesigner app will generate all the Arduino code for you.

Nick_Pyner:
Probably not true. One step beyond the crudest code takes you into Robin's realm...

Having said that, it seems that you simply want to prove two way traffic. This is about as basic a proof as you will ever get. It is for SLAVE Bluetooth and PHONE.
I published it in conjunction with
Dropbox - GUIDE_2BT.pdf - Simplify your life , which you probably don't need to read!

Your article is very comprehensive, lots of good info there! I've been able to achieve two-way traffic between the slave module and my phone, so I'm currently trying to achieve traffic (initially one-way, from slave to master) between two Arduinos and their Bluetooth modules. But, as already discussed, something is going wrong because data is not flowing between the two.
I'm not sure where to go from here... the slave will transmit data successfully when the master is the phone, but not when the master is another Arduino+BT module. The modules appear to connect to each other, but I can't tell if it's something going wrong in the master, or the slave, or both. I'm ready to give up at this stage :frowning:

drmpf:
Probably not want you want to hear but BLE is messy and it is much easier to use Classic Bluetooth e.g. HC-05
That said, this project uses BLE HC-10 to connect to my (paid) pfodApp.
and the free pfodDesigner app will generate all the Arduino code for you.

Hi drmpf,
When you say that BLE is messy, can you give some examples of what you mean by that?
Many thanks!

This is my write up on that Bluetooth Low Energy BLE Problems
Then you have all the services and characteristics thing. A real overkill if you just want to send/receive a data stream and don't need the low energy features of BLE.
Getting low energy BLE takes some work. See my Easy Very Low Power BLE in Arduino projects

drmpf:
This is my write up on that Bluetooth Low Energy BLE Problems
Then you have all the services and characteristics thing. A real overkill if you just want to send/receive a data stream and don't need the low energy features of BLE.
Getting low energy BLE takes some work. See my Easy Very Low Power BLE in Arduino projects

Thanks drmpf,
I've read though your articles, and I see what you mean about BLE being tricky to use. I've ordered some HC-05s so hopefully they will be easier to work with. I got them on Aliexpress so it'll be a few weeks before they get to me.
In the meantime though, I'm still curious about my BLE modules. I'm new to BT, but I haven't been able to see which of the issues in your BLE Problems write-up could be affecting my setup. Perhaps you could shed some light on this for me...
Just to recap:
I have an AT-09 module set as a slave and connected to an Arduino. The Arduino code simply sends a char array to the BT module every 5 seconds. I can successfully receive these transmissions on my phone with Kai Morich's Bluetooth Serial Terminal app.
I have a second AT-09 module set as a master and connected to a second Arduino. The Arduino code simply performs a bidirectional pass-though function. Anything that is received by the BT module is passed to the Arduino IDE Serial Monitor, and correspondingly anything that is typed into the Serial Monitor is passed to the BT module. This code works perfectly well when the BT module is in AT mode. I can successfully use the Serial Monitor to send AT commands to the module and receive the command responses from the BT module. The code also works perfectly well if I set the BT module to slave, and send data back and forth to/from the app on my phone.
I have set the BT master module to bind with the slave, they appear to connect successfully (LEDs on both modules stop flashing and are continuously on; master stops accepting AT commmands, indicating that it's in comms mode). However, the char array sent from the slave does not appear to be received by the master - no data appears at the Serial Monitor.
Any thoughts on this? Many thanks!

Sorry not much help with that.
Sounds like a setup issue with the AT-09 modules (which I don't have available to test)
However you could try turning off the slave and using nRF Connect app to look at what the other side is doing. You can configure nRF Connect to look like the server you are trying to connect to, but I have not actually ever used that functionality
I did see this note, if you are using a pin

authorized central will need to enter a PIN code for every connection

Finally you can use an Adafruit Bluefruit LE sniffer to see what is going on between your two AT-09s

OK. As I understand it, HM-10 is going just fine, except for the linking as a master. So, have you checked the Martyn Currey website lately? He may well have something in this arena. Initially, I believe he was as dismissive about the HM-10 as I was, but I think things have changed.

I'm still somewhat dismissive, but you have some considerations

  1. You have them in your hand.

2 There are a lot of fake HC-05s about.

  1. I have never heard of a fake HM-10.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.