I’m trying to build a configuration (see diagram) that has two Arduinos. The first Arduino (1) will control a servo and RGB LEDs. This Arduino will drive the “main logic” so to speak. The second Arduino (2) will simply drive an electronic brick to turn a light on/off. I would like to control the sequence/timing of the light on/off from Arduino 1. So Arduino 2 is in effect a slave to Arduino 1 in terms of logic. It will simply wait for a command from Arduino 1 to turn the light on/off. Due to the physical environment/proximity, I would like the connection between the two Arduinos to be Bluetooth instead of hardwired. This I can figure out how to do by just setting up a master/slave Bluetooth environment between the two Arduinos.
But, I would also like to have a Bluetooth connection between an Android device and Arduino 1. The purpose is to control the effects driven by Arduno 1 (e.g., turn on/off, timing, LED color, etc.) from the Android device. I know how to set up the HC-05 module to pair with the Android device. I’ve written a small test program and everything works ok. So, I’ve kind of got the two separate configurations worked out.
What I don’t know how to do is set up the the configuration to have two Bluetooth connections with Arduino 1. I’v done some preliminary reading on Piconet, but before I spend lots of time figuring out this won’t work I thought I’d ask the community for ideas.
Could you setup the Arduino/HC-05 so at the flick of a switch it changes between master/slave modes. In master it looks for and connects to the brick arduino and in slave mode it waits for you to connect with your android.
Nick_Pyner - thanks! I have looked at Phillipe Cantin's videos and blog. Very good stuff. I'm actually trying to figure out how to connect with him directly to see if he could offer some advice.
Riva - I need the system to be self-contained in the sense that I won't have access to it during normal operations. It will be on my roof controlling a halloween display. If I can figure out how to programmatically (through AT commands) change between master/slave mode that might work.
I think you can get him through Google+, or simply post a comment on the above site.
I imagine you could switch between master and slave modes, but it seems a rather pointless exercise and can't possibly be worth the effort when $7 will get what you want and be right first time.
Arduino #2 looks rather under-employed any. Are you sure you can't do this with one? Maybe it's some environmental problem.
Nick_Pyner - thanks! I will try contacting him through Google+ as you mentioned. I connected to him today.
I'm curious about your comment - "$7 will get what you want and be right the first time." Could you elaborate?
Yes - Arduino 2 is under-employed and I can actually hardwire the electronic block to Arduino 1 and turn it on/off by doing a digitalWrite. It will be controlling a spotlight and I want to be able to move it around as needed, and I don't won't to run wires if possible. Not a show stopper by any means, but prefer the BT route if I can get it to work.
Are you saying that I could have two HC-05's attached to Arduino #1. One to communicate to the phone and the other to communicate to Arduino #2? I've never seen that type of configuration. Or maybe I'm missing your meaning all together!
Yes, that is what I'm saying. If you have a Uno, this means that one of them will have to be on software serial. You often see bluetooth exercises using software serial and hardware serial in one configuration - hardware to the serial monitor and software to bluetooth. Serial devices all look the same to Arduino and it doesn't know or care if the hardware is just the monitor or another HC-05.
You simply send commands like
in the normal manner, and
for software serial.
If the traffic is one-way, you only need one pin. Just don't get ambitious with the speed on software serial, and stay with 9600.
By coincidence, I see that using one pin in software serial i.e. one-way traffic, is a little more complicated than I thought. I guess this is because the library routinely lays claim to two pins for two-way traffic. If this is an issue, some wise words from Nick Gammon are here
Thanks! Looks like Nick's solution is a good one for pin-constrained environments. I think I'll be able to squeak by with pins for both TX/RX, but if not, this is very good information to have at hand.