I just picked up a Arduino 2560 wired to a breadboard with a hc 05 Bluetooth module. I copied and pasted the code from this YouTube video I have been following instructions on: LIDA Speed: MicroSquirt Bluetooth Upgrade - YouTube
For some reason when I type AT on the serial monitor it doesn’t do anything, it just stays blank. It is currently set at 115200 baud and NL and CL. I change the baud rates and it would give me back random question marks. Hc05 is already on AT mode (slow blinks). I have RXD to 11, TXD to 10, GRND to GRND, VCC to 3.3v, and KEY to 9.
Thanks for stopping by and looking any help is truly appreciated!
Please post your code here between
** **[code]** **
and
** **[/code]** **
. If it exceeds close to 9000 characters, you can attach instead
Your topic was Moved to it's current location / section as it is more suitable.
Could you take a few moments to Learn and Use The Forum
It will help you get the best out of the forum in the future.
-
Your OS and version can be valuable information, please include it along with extra security you are using.
-
Always list the version of the IDE you are using and the board version if applicable.
-
Use quote or add error messages as an attachment NOT a picture.
-
How to insert an image into your post. ( Thanks @sterretje )
-
Add your sketch where applicable but please use CODE TAGS ( </> )
-
Add a SCHEMATIC were needed even if it is hand drawn
-
Add working links to any specific hardware as needed (NOT links to similar items)
-
Remember that the people trying to help cannot see your problem so give as much information as you can
COMMON ISSUES
-
Ensure you have FULLY inserted the USB cables.
-
Check you have a COMMON GROUND where required. ( Thanks @Perry)
-
Where possible use USB 2.0 ports or a USB 2.0 POWERED HUB to rule out USB 3.0 issues.
-
Try other computers where possible.
-
Try other USB leads where possible.
-
You may not have the correct driver installed. CH340/341 or CP2102 or FT232 VCP Drivers - FTDI
-
There may be a problem with the board check or remove your wiring first.
-
Remove any items connected to pins 0 and 1.
COMPUTER RELATED
-
Close any other serial programs before opening the IDE.
-
Ensure you turn off any additional security / antivirus just to test.
-
There may be a problem with the PC try RESTARTING it.
-
You may be selecting the wrong COM port.
-
Avoid cloud/network based installations where possible OR ensure your Network/Cloud software is RUNNING.
-
Clear your browsers CACHE.
-
Close the IDE before using any other serial programs.
-
Preferably install IDE’s as ADMINISTRATOR or your OS equivalent
ARDUINO SPECIFIC BOARDS
-
CH340/341 based clones do not report useful information to the “get board info” button.
-
NANO (Old Types) some require you to use the OLD BOOTLOADER option.
-
NANO (ALL Types) See the specific sections lower in the forum.
-
NANO (NEW Types) Install your board CORE’s.
-
Unless using EXTERNAL PROGRAMMERS please leave the IDE selection at default “AVRISP mkII”.
-
Boards using a MICRO usb connector need a cable that is both DATA and CHARGE. Many are CHARGE ONLY.
CREATE editor install locations.
-
On macOs ~/Applications/ArduinoCreateAgent-1.1/ArduinoCreateAgent.app/Contents/MacOS/config.ini
-
On Linux ~/ArduinoCreateAgent-1.1/config.ini
-
On Windows C:\Users[your user]\AppData\Roaming\ArduinoCreateAgent-1.1
Performing the above actions may help resolve your problem without further help.
Language problem ?
Try a language closer to your native language:
Thanks to all those who helped and added to this list.
pan_jaycee:
VCC to 3.3v
Check the back of the Bluetooth board. It probably says 3.6-6v, so you then might question why you are feeding it 3.3v. If it indeed does say 3.3v, you still have a problem, as I don't there is enough current on Mega's 3.3v pin anyway.
You serial monitor will work at 115200 provided Arduino is set accordingly, even though it s utterly pointless for this exercise, but there is only one baud rate for configuring Bluetooth - 38400.
You might find the following background notes useful.
I first removed everything in the little green box and copied and pasted this code:
/*
AUTHOR: Hazim Bitar (techbitar)
DATE: Aug 29, 2013
LICENSE: Public domain (use at your own risk)
CONTACT: techbitar at gmail dot com (techbitar.com)
*/
#include < SoftwareSerial.h >
SoftwareSerial BTSerial(10, 11); // RX | TX
void setup()
{
pinMode(9, OUTPUT); // this pin will pull the HC-05 pin 34 (key pin) HIGH to switch module to AT mode
digitalWrite(9, HIGH);
Serial.begin(9600);
Serial.println("Enter AT commands:");
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
void loop()
{
// Keep reading from HC-05 and send to Arduino Serial Monitor
if (BTSerial.available())
Serial.write(BTSerial.read());
// Keep reading from Arduino Serial Monitor and send to HC-05
if (Serial.available())
BTSerial.write(Serial.read());
}
Been looking through the forums and looks like no one is having the problem I’m having. I made a quick video to show what is going on and settings:
Been looking through the forums and looks like no one is having the problem I'm having. I made a quick video to show what is going on and settings:
https://youtu.be/H0NQQe9jglo
The code in that video show software serial on pins 2 and 3. Those are not valid for a Mega.
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
Why would you use software serial on a Mega which has 3 additional hardware serial ports?
pan_jaycee:
looks like no one is having the problem I’m having.
Probably not true. Hazim's stuff is dated but his code should be OK. HC-05s these days have a button for starting AT mode, as mentioned in appendix 7 of my notes, some of which are Mega-specific. Note though, that you may need to use KEY for some of the advanced AT commands, but I don't know what they are. The video shows that you are fartarsing about with the monitor baud rate. There is only one baud rate to use - 9600 - as clearly and correctly shown in your code. I believe the video shows that you are in AT mode, but this is not very clear.
edit chk reply #6. Hazim is a Uno man!
Please read reply #1 which describes how you should post code. The result will look like
your code here.
// Basic Bluetooth test sketch 5a for the Arduino Mega.
// AT mode using button switch
// HC-05 with EN pin and button switch
//
// Uses serial with the host computer and serial1 for communication with the Bluetooth module
//
// Pins
// BT VCC to Arduino 5V out. Disconnect before running the sketch
// BT GND to Arduino GND
// BT RX (through a voltage divider) to Arduino TX1 (pin 18)
// BT TX to Arduino RX1 (no need voltage divider) (pin 19)
//
// When a command is entered in to the serial monitor on the computer
// the Arduino will relay it to the Bluetooth module and display the result.
//
char serialByte = '0';
const byte LEDPIN = 13;
void setup()
{
pinMode(LEDPIN, OUTPUT);
// communication with the host computer
Serial.begin(9600);
Serial.println("Do not power the BT module");
Serial.println(" ");
Serial.println("On the BT module, press the button switch (keep pressed, and at the same time power the BT module");
Serial.println("The LED on the BT module should now flash on/off every 2 seconds");
Serial.println("Can now release the button switch on the BT module");
Serial.println(" ");
Serial.println("After entering AT mode, type 1 and hit send");
Serial.println(" ");
// wait for the user to type "1" in the serial monitor
while (serialByte !='1')
{
if ( Serial1.available() ) { serialByte = Serial1.read(); }
}
// communication with the BT module on serial1
Serial1.begin(38400);
// LED to show we have started the serial channels
digitalWrite(LEDPIN, HIGH);
Serial.println(" ");
Serial.println("AT mode.");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("The HC-05 accepts commands in both upper case and lower case");
Serial.println(" ");
}
void loop()
{
// listen for communication from the BT module and then write it to the serial monitor
if ( Serial1.available() ) { Serial.write( Serial1.read() ); }
// listen for user input and send it to the HC-05
if ( Serial.available() ) { Serial1.write( Serial.read() ); }
}
I tried the code, got it uploaded and the serial monitor even popped up with words, unfortunately nothing happened when typed 1. Checked wiring and it mirrored what was on the write up. Here is a link to the write-up: Using an Arduino Mega with a HC-05 zs-040 AT Mode | Martyn Currey
Maybe it won’t connect because it is not the button version hc-05 (box says it’s an hc05). I’m pretty stumped and not sure where to go from here.
unfortunately nothing happened when typed 1.
Did you type the '1' in the Serial monitor?
Did the led not come on?
digitalWrite(LEDPIN, HIGH);
Did you see this print out?
Serial.println(" ");
Serial.println("AT mode.");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("The HC-05 accepts commands in both upper case and lower case");
Serial.println(" ");
pan_jaycee:
I tried the code, got it uploaded and the serial monitor even popped up with words,
God only knows what that means but the only words that count on the serial monitor are the "OK"s from Bluetooth. The rest is meaningless.
Using an Arduino Mega with a HC-05 zs-040 AT Mode – Martyn Currey
Maybe it won’t connect because it is not the button version hc-05 (box says it’s an hc05). I’m pretty stumped and not sure where to go from here.
Since you are using Martyn's stuff, you might as well stick with it, as I'm sure he also covers non-button HC-05s, even if it is not specific to Mega. I believe this is specifically those on the JY-MCU breakout board, plus those on Uno shields.
I did indeed press 1, nothing. I typed OK as well and still nothing. Looked at the comments for guidance and one of them talked about not having the button to which Martyn replied that he does not have any thing on them. I kept looking at his other write ups and there wasn’t anything on the “buttonless” hc05s.
I did indeed press 1, nothing.
Did you enter '1' in the serial monitor or on the phone?
If you did not see this screen which is the Serial communication between the monitor and the mega something is very wrong. You need to figure out why you can not read an entry from the Serial monitor on the mega.
Yup I entered the screen. Did everything as per the instructions. I’m thinking it needs to be a button version of the hc05, they’re mostly the same but I just have to jump the 34 pin with 5.5v
pan_jaycee:
Martyn replied that he does not have any thing on them.
I don't think that is true. Martyn specifically refers to advanced level configuration. The more obscure commands cannot be send with just using the button, you have to use the EN pin. Also while it pains me to say it, there is surely some stuff on Instructables. I think we are going round in circles here. Hazim's notes are surely "pre-button" and he should have something. My notes probably don't, and I usually just refer people to Martyn.
Anything that mentions JY-MCU will be "no-button".
I rather feel your code is suss - probably ancient, certainly verbose, and misleading. You typing OK is futile. The only OK you want is that sent by HC-05. Typing "1" is equally futile. It is not an AT command. Any code to do with LEDs is the same. The only LED you need to see is the one on the HC-05 - flashing slowly.
I suspect that, if you had stuck with Hazim's stuff - wiring included - you would be off to the races by now....
Ok, I’ll look more into the JY-MCU deal over at Martyns site tonight. Tomorrow I’ll head over to the store and pick up an UNO to try out Hazim’s sketch again with his wiring setup.
I finally fixed it!!!
Someone on Reddit told me to run no sketch and to move the hc05 rx to rx0, tx to tx0, and give power to EN. It automatically went to AT mode. I then typed in AT and got back OK. It now works and shows up on Bluetooth, I even got my phone connected to it ![]()
Thanks everyone! I appreciate your time and patience. And sorry for the spoon feeding, I’m still learning ![]()
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.