Hi, I'm new to this forum. I'm currently involved in a project that's going to use JY-MCU bluetooth to communicate between three arduino units and I could use some help with this because I really don't how to program bluetooth to do that.
three arduino units
You might be better off with an NRF24 network. The first step in establishing bluetooth comms is called pairing, which implies two, and I don't think that is very easy either.
I should probably be more clear. Two of the arduinos are only going to be in communication with a sort of central arduino. Basically, how it's supposed to work is someone pushes some buttons connected to arduino number one (the one that's active for the moment). That sends a message via bluetooth to the central arduino and the first arduino unit goes into standby while the central arduino makes a register of some data and then sends a message to the second arduino activating it. Buttons are pushed on the second, data sent to central while the second goes into standby, central makes a register, etc, etc. Probably not the most practical method of communication for what we're making but it's what the group decided.
Extinct_turtle:
Probably not the most practical method of communication for what we're making but it's what the group decided.
Probably true and, if it took a group to make a decision like that, it might be time to look for another group.
You might find some help here but Cantin is using Bluesmirf, not HC-0x, I understand they are significantly different and he is only talking about two anyway.
Phillipe Cantin: Arduino Bluetooth Link.
More typical links are here
and here
http://forum.arduino.cc/index.php?topic=144400.0
I believe its possible to have a base station with multiple bluetooth modules, or perhaps a single that can poll between slaves, but it appears that I'm the only person who does, and I'm not that confident. I only raise this because I believe the bluetooth in my car can poll between phones. Meanwhile, Maniacbug and his mates are happily networking NRF24s while you are left hitting your heads against a brick wall.
I hope you are not working to a deadline.
What you could do is configure one JY-MCU (HC-05) to work in master mode. in this mode you have access to certain commands to connect and disconnect with devices aswell as a pair command. I have not working worked with this mode on these modules. but it should be possible to create a sketch that will periodically connect to the other two devices and pass along data in a round-robin fashion.
You first need to use the command AT+ROLE=1 to put the device into master mode.
Then you need to know the bluetooth addresses of your two slave devices. on those modules issue the command AT+ADDR? to retrieve the address.
Then on the master device, pair with both slave modules using the addresses you just retrieved:
AT+PAIR=,. Param1 is the bluetooth address of a remote device. and Param2 is a timeout value (max value 20)
Once both devices are paired you can connect using the command: AT+LINK=<BT_Address> (only one active connection supported on the JY-MCU)
and disconnect using: AT+DISC
google for "HC-03/05 Bluetooth serial command set", you find documents with the full command set for further information.
Thank you for your help, but we've decided to cut out the bluetooth and use XBee for communication.
I also like to connect Arduinos with eachother (with the help of the HC-05/JY-MCU).
I already managed to connect the UNO (Slave; with HC-05) to the YUN (Master; also HC-05)...
But I don't know how to send data (for example a FLOAT or a txt-file) from one to another (preferably UNO to YUN)... Can anyone help me with that?!
I know the Yun-sketch will likely be a little different than the UNO-sketch... BUT I didn't even find a UNO-sketch yet, that does transfer a FLOAT/integer/... to another arduino....
Very frustrating.....!
Here is the current sketch of my UNO and the YUN.
(with these I managed to program the HC-05 over the Serial with AT-Commands from the HC-05-datasheet; used the latest Arduino IDE 1.5.6_r2):
UNO:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
// while (!Serial) {
// ; // wait for serial port to connect. Needed for Leonardo only
// }
Serial.println("Ready!");
// set the data rate for the SoftwareSerial port
// for HC-05 use 38400 when poerwing with KEY/STATE set to HIGH on power on
mySerial.begin(38400); // 38400 necessary for programming mode
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
YUN:
void setup() {
// put your setup code here, to run once:
Serial1.begin(38400);
Serial.begin(38400);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial1.available())
{
byte a=Serial1.read();
Serial.write(a);
}
if(Serial.available())
{
byte a = Serial.read();
// if(a=='1'){
// digitalWrite(13,1);
// }
// if(a=='0'){
// digitalWrite(13,0);
// }
// else {
Serial1.write(a);
// }
}
}