Pages: 1 2 [3] 4 5 6   Go Down
Author Topic: How to get the JY-MCU bt board to work  (Read 75599 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had the same problems where only the AT command received a response. I have the breakout version 1.03 with firmware version 1.5. Found and changed a simple Arduino sketch to allow AT commands to be sent to the Bluetooth adapter. Simply adding a delay(10) allowed the other commands such as AT+VERSION to get a correct response from the Bluetooth adapter. I used Arduino's serial Monitor to send all the commands.  This is based on the code in the link provided earlier in this thread. Hope this is useful to some!

Link to the code: http://eclipse.clinertech.com/arduino/bluetooth/blth.html

I have the same problem with AT commands, only have AT working, non other. Is the problem in the software serial sketch maby? I don't have a usb to ttl board, only a usb to rs232 so I really need make it work over the arduino, any Ideas?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Poppin, your code works with me. Something in the example code makes it unable to get a response from any other AT command. Nice job, it works here.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Links with the AT commands.
http://byron76.blogspot.ca/2011/09/one-board-several-firmwares.html
http://eclipse.clinertech.com/arduino/bluetooth/Bluetooth_AT_Commands.txt

Two key pieces of information I wish I knew when I started.

1. AT commands DO NOT work when the device is paired.
2. SoftwareSerial doesn't work past 9600 BAUD.


WARNING: Setting the BAUD Rate too high will essentially lock you out of the chip if you don't have hardware that can send/recieve at that baud rate...

This code above worked for me very well >.> until I changed the BAUD rate using AT+BAUD8
Now it's stopped responding to AT commands. ( I did recompile my sketch to use the new baud rate 115200)
There is a "STATE" Pin that I found on http://www.dankrill.com/lab/index.php?content=procedures&set=b&item=11
that says that will toggle it between AT command mode and regular work but I think maybe a 10k resistor is too much since I'm only running on 5V

I've also discovered that delay rates of tx/rx stuff changes pending on baud rate so maybe I'm failing there somehow. I was reading the SofwareSerial.cpp file and some other sources said timing is pretty important for this but unsure exactly how to calc it.

At one point I did have my snes controller -> Arduino Mega -> BlueTooth module -> custom compiled SNES9x  >.> but I wanted faster response times.

Things would lock up alot and I got a reset procedure down.
Remove the pairing (ubuntu 12.04 LTS)
Reboot box
hcitool scan
rfcomm bind 0 00:12:02:28:71:34 1
screen /dev/rfcomm0 9600 #This will prompt you for the pairing password and I also noticed the LED went solid rather than blinky.
screen /dev/rfcomm0 9600
rfcomm release 00:12:02:28:71:34






UPDATE:

Got it working again, I switched to hardware tx3/rx3 then I cycled through every baud rate until I saw the right output, aparently I set it to 57600


run the following just once after boot, and note AT commands cannot be run after this is paired
hcitool scan
rfcomm bind 0 00:12:02:28:71:34 1


#Upload this test code
void setup() {
 Serial3.begin(57600);
}

void loop() {
   Serial3.write("*test*\r\n");
   delay(1000);
}

command line test
screen /dev/rfcomm0 57600     #cycle through all baud rates until you see the plain text "*test*" string

I re uploaded the sketch every time but when I hit 57600 I just decided to re run screen without the upload and it worked >.> so maybe it doesn't matter or maybe that fixed it.

Once I saw the plain text I CTRL-A-k out of screen

rfcomm release 00:12:02:28:71:34 #If you don't release the pairing AT commands don't work!


Then upload the following code


String command = "";
void setup() {
  Serial.begin(115200);
  Serial3.begin(57600);
  Serial.println("Type AT commands!");
}

void loop(){
  if (Serial3.available()) {
    while(Serial3.available()) { command += (char)Serial3.read();delay(10); }
    Serial.println(command);
    command = ""; // No repeats
  }
  if (Serial.available()){ delay(20); Serial3.write(Serial.read()); }
}




screen /dev/ttyACM0 115200 #Begin typing AT commands.


« Last Edit: September 03, 2012, 03:53:56 pm by xpatch » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just wrote up an Arduino sketch that configures this module if that is helpful to anyone.

http://arduino.cc/forum/index.php/topic,122070.0.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got my JY-MCU, but can't get it to work.

Wired with 5V @ 8A going in to Arduino VBus, BT, and 100 pixel LEDs.  Pixel data on D4, TX/RX swapped from BT to Arduino (tried both ways).

1) When powered, red light on it blinks continuously even with TX/RD unplugged, always, never seen any change.

2) When paired I get 2 serial ports: "Com11 - SSP" and "Com12 - SSP (Dev B)". Windows lets me enable or disable 12 in BT settings.  11 is always only in device manager.

3) When I try to open either port (at 9600), term program locks up for a few seconds, then says it is open but it doesn't work.

Seller said board default was 9600.  I was hoping I could just plug this in and do everything (re-program Arduino, send bytes to change LED colors) the exact same as when I connect my TTL board to the same 4-pins and use a cable.  The whole thing is installed on my roof, so I'd rather not have to send any AT commands while unpaired or any of that stuff, but I guess I could just pull the BT and connect it to my TTL if I have to.

Any suggestions?  Which of the 2 serial ports is right?  Is the red light supposed to blink no matter what?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got my JY-MCU, but can't get it to work.

Wired with 5V @ 8A going in to Arduino VBus, BT, and 100 pixel LEDs.  Pixel data on D4, TX/RX swapped from BT to Arduino (tried both ways).

1) When powered, red light on it blinks continuously even with TX/RD unplugged, always, never seen any change.

2) When paired I get 2 serial ports: "Com11 - SSP" and "Com12 - SSP (Dev B)". Windows lets me enable or disable 12 in BT settings.  11 is always only in device manager.

3) When I try to open either port (at 9600), term program locks up for a few seconds, then says it is open but it doesn't work.

Seller said board default was 9600.  I was hoping I could just plug this in and do everything (re-program Arduino, send bytes to change LED colors) the exact same as when I connect my TTL board to the same 4-pins and use a cable.  The whole thing is installed on my roof, so I'd rather not have to send any AT commands while unpaired or any of that stuff, but I guess I could just pull the BT and connect it to my TTL if I have to.

Any suggestions?  Which of the 2 serial ports is right?  Is the red light supposed to blink no matter what?

Blinking red light is what I see as well, even with nothing attached to TX and RX. I think the light may change when it goes into command mode, but I don't recall offhand.

I haven't tried to reprogram an Arduino over the bluetooth serial link, but I don't see any reason why it wouldn't work.

I think your best bet is to get the Bluetooth module working on its own before trying to incorporate it into your project. The sketch I wrote should be able to configure the module to whatever you specify, regardless of what the default configuration is. From there, you can test it out with a simple "Hello World" kind of sketch and a Bluetooth terminal on the PC. The module will keep that configuration forever, so once you set it up once and get it working, you can just drop the module into the project on the roof and it should just work.
Logged

0
Offline Offline
Full Member
***
Karma: 2
Posts: 125
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1) Try using a very simple sketch that just outputs a message every second with just the Arduino first. Program it with a USB cable, then remove it from the computer and attach the JY-MCU so that the up arrow (on either RX or TX) goes to TX (pin 1) on the Arduino. If you connected it correctly then you should be able to see your data.
2) When you pair and open the serial port (you have two-either one should work), the LED should shop blinking and be solid on. This means the serial port is open and you should be seeing data. You cannot send AT commands in this mode. If you want to send AT commands to change baud rate and name, follow steps in post #3. You cannot upload sketches in this mode unless you press the reset button at the right time. Uploading sketches requires a reset wire which the JY-MCU does not provide. I made an ATtiny circuit to watch the LED and reset the microcontroller so that sketches can be uploaded, but uploading code is five times slower and sometimes it fails. It is flawless if it actually finishes an upload though.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies, I guess I'll pull it off and get it AT-programmed (even though any baud/pin/name is totally fine with me if I could just get it to work).

The solid-light on serial data is good to know...  and you are saying both of the 2 serial ports do the same thing?  Strange.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok...

1) Connected board to TTL and AT commands were fine.
2) Proved out 2-way communication by using BT, TTL, and two terminal programs.
3) Proved 1-way communication when re-installed on Roof (Arduino code sends "RPM\n" on startup, and I see that in terminal program)
4) SENDING BYTES DOES NOT SEEM TO WORK when installed on Roof???

It should not be my Arduino code, but I thought I would try to reprogram it anyway.
I changed the boards.txt file to 9600 baud (didn't want to risk upping it, AT verified 9600)
When I try to program my Arduino Mini Pro, it just says "uploading..." and locks up the port until I reboot.  When using the TTL, it never does this; it times out after 5-seconds if you don't press reset in time.  I had my friend on the roof pressing reset, but even if our timing was off, it should time-out, not lockup.  What is going on?
Logged

0
Offline Offline
Full Member
***
Karma: 2
Posts: 125
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have already verified two-way communication without a USB cable while not on the roof, then it should work on the roof unless a wire comes loose or the asymmetry between Bluetooth transmit power causes one of the two signals to degrade.

I do not know why your computer is locking up while trying to program over bluetooth. If I had to guess, it is getting stuck at the connection establishment, something a USB cable does not have to worry about. I would just end the Arduino process or disable the bluetooth adapter in device manager instead of rebooting. Again, I do not recommend programming over bluetooth. The JY-MCU already provides an easy to use serial connection but was not meant to program.

Also when I said "up arrow (on either RX or TX)", I said "either" because I could not remember which one it was. The pins don't do the same thing.

You seem to know what you are doing so I trust you can troubleshoot.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it working...  just used a USB extension cable to get my BT dongle a little closer to the roof.  smiley-razz


I still want to know how to program though as I do want to update code and I do not want to disassemble the roof project.  Did I do it correct by changing the BAUD in boards.txt to 9600?  Would I be better to leave that alone and instead change the BT baud to 57600?  If I did that would 57600 mean less distance than 9600 (ie: would I need a longer USB extension cable to get it to work)?  How come the Arduino IDE only sees the second (dev b) serial port and not the main one (which is the only one that seems to work when trying to send serial to my code)?
Logged

0
Offline Offline
Full Member
***
Karma: 2
Posts: 125
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would recommend changing the baud rate on the bluetooth device, otherwise other boards of whatever entry you changed will not work without more modification to boards.txt. I am not sure about less distance at 57600--you have to determine this empirically.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not got it to connect again since that once.  RealTerm gives "apro exception." on one of the ports, and the other port just lags and doesn't work in either direction.  Now I removed the device and re-added it, and I have no serial ports.  I hate BT!  Have you others really got this to work reliably?  Maybe I need a different BT dongle?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have not got it to connect again since that once.  RealTerm gives "apro exception." on one of the ports, and the other port just lags and doesn't work in either direction.  Now I removed the device and re-added it, and I have no serial ports.  I hate BT!  Have you others really got this to work reliably?  Maybe I need a different BT dongle?

I've never had much luck with Windows and Bluetooth in general. I've had zero issues at all with using this module with Android devices, though. I've been doing a burn-in test for the last 2 days with one, actually. I've just left it running and connected to it from my tablet and phone sporadically to see that it will still accept a new connection. So far so good, it's been quite reliable. I've also just left it connected for a few hours at a time and it seems to keep the connection without any problems.

I think the module is best left as a serial communication terminal, though, rather than as the primary connection to the arduino for programming. For that reason, I attached mine to a SoftwareSerial port (or on the Mega, I just used one of the non-primary serial ports).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using a Pro Mini.  Right now all I'm doing is changing the color of xmas LEDs.  I would love to figure out how to make an Android app for that, and there are open-source BT-terms for Android, but I just don't have the time right now.  Eventually I want to allow "file-playback" to make the LEDs do all source of color movement, lightning effects, etc...and while I could do that from my phone as well, I'd rather have my house server doing it even when I am not at home.

I got it to work (once) again, but every time I need to connect to it to change the color it's like pulling teeth.  Once connected it works great until you exit my color-change app, unplug the BT dongle, reboot the PC, or reset the Pro-Mini.  After that I have to use RealTerm, plugging/unplugging the BT dongle, unpairing/repairing, etc...until it finally starts working again.  Sometimes I only see one serial port, other times I see 2 or none.  The Arduino IDE never sees the port that works, only the one that doesn't, but I have not got it to program over that.  How does it even decide just not to show a COMPort that is free and working?

I have not been able to test with Android term past receipt because both of those I tried only send ASCII, but I need to send 0xFE 0x00 0x00 in HEX as my key byte for the next "frame" of RGB values.
Logged

Pages: 1 2 [3] 4 5 6   Go Up
Jump to: