I'm new to Arduino, and I'm starting my first project. I want to send data from a WiiMote over bluetooth to my Arduino. I'm struggling on a problem: when I connect the bluetooth modem to my Arduino UNO, it isn't reacting on my commands.
This is the code I wrote:
The BC417 works with AT commands on this datasheet (go to to page 9).
If Arduino sends 'AT'; it should be receiving 'OK' from the bluetooth modem. The light on pin 13 should light up.
If Arduino doesn't receive 'OK', the light will start blinking.
I used my Arduino UNO as passthrough device so I can see what the problem is. Instead of receiving 'OK', it receives '-1'.
The BC417 is working correctly, I can pair it up with my cellphone.
My question is: how can I send commands from Arduino UNO to the bluetooth modem (BC417)?
Thank you for your reply. This is another link to the datasheet.
The datasheet says that the baud rate is 9600, and I tried every baud rate above that, with no success.
You are reading one character from the serial port. It is unlikely that the one character will be 'OK'. Have you seen the OK key on your keyboard? Maybe right next to the Any key.
How have you connected the modem to the Arduino? The datasheet in the second link says that the modem is a 3.3V device. The UNO is a 5V device.
It is important to note that EGBT-046S does not
wait for any termination character for each AT command
entry. Instead, it acts to whatever character
you entered after one second.
Any data entered is checked against a list of valid commands. AT is a valid command. AT is not. So, why are you using println() to send the commands?
For what? If you are referring to sending the AT command, Serial.print() is right. But, only if the bluetooth modem is wired correctly. If it isn't, NOTHING is going to communicate with it.
Do I need to use the Arduino Pro for 3.3v input?
That's one way. Another would be to get a V5 bluetooth modem. A third would be to wire the bluetooth modem correctly. The 5V Arduinos have a 3.3V power source.
In any case, the bluetooth modem is not going to respond with the single character 'OK'. Count them 'OK' is not one character.
I suggest, then, that you use NewSoftSerial (0023 or earlier) or SoftwareSerial (1.0 or later) to create a software serial port to talk to the modem, so that you can use the hardware serial port to talk to the Serial Monitor. We need to know what the response from the modem is, if anything, when you send it the AT command.
#include <NewSoftSerial.h>
NewSoftSerial modem(2,3); // 2 is the RX pin, 3 is the TX pin
void setup()
{
modem.start(9600);
Serial.start(115200);
modem.print("AT");
while(millis() < 30000) // wait for a reply for up to 30 seconds
{
while(modem.available() > 0)
{
char aChar = modem.read();
Serial.print(aChar);
}
}
}
void loop()
{
}
Hi
I am also a beginner with arduino and electronic. I ordered a HC-06 Wireless Bluetooth Transceiver.
I can command it with some basic AT command, I can rename, set the PIN, I can connect with my Android phone, so it is working 80%. But I want 100%
My first problem, I am not sure this is a HC-05 or HC-06. I found some information on back that means this is HC-05 (zs-040). I try to use some HC-05 AT command without answer. The chip on the board is a BC417.
The AT+VERSION said: linvorV1.8
Why this is important? This is my second problem.
All tutorial on net said I must use on serial monitor with CR+LF set if I have HC-05. But it is not working, only if I set No line ending that means this is HC-06. But in this setting if I got any answer from BT that is coming every char in separate socket.
For example the AT answer:
O
K
I am using this code, that means the arduino can read only ONE char from message then got no more.
void loop()
{
if (Serial2.available()) {
while (Serial2.available()) {
command += (char)Serial2.read();
}
Serial.println(command);
command = "";
}
if (Serial.available()) {
delay(10);
Serial2.write(Serial.read());
}
}
of course I can use " Serial.print(command); ", but because there is no any separate char, all message after each other like this(AT , AT+VERSION): OKOKlinvorV1.8
So I am really do not understand what the hell happening. If I send CRLF it is not working, if not it is working but I cannot read the whole answer in one turn. What I doing wrong?