Re configuring the HC 0. I picked up a cheap bluetooth serial rs. Amazon. As it didnt cost too much, I thought Id take a chance. The module arrived fine, though unsurprisingly without any documentation. Initially Id tried following the documentation for configuring a HC 0. I while I realised it was actually a HC 0. The HC 0. 6 is very similar to the HC 0. Luckily I found some good instructions for configuring the HC 0. Im going to recap what I did to get the module working with my OS X laptop and a USB serial adapter. Initially I just connected the pins from the bluetooth module to the USB serial adapter directly. Although this meant that the powerground pins lined up it also meant that the rxtx receivetransmit pins also lined up which we dont actually want. We actually want the rx pin on the serial adapter to go to the tx pin on the bluetooth adapter and vice versa. This is because its not simply passing through the signals instead were transmitting from the serial and receiving on the bluetooth adapter. This also means that we have to make sure the baud rates of both adapters match. You can see the pinouts of the bluetooth top and serial bottom adapters here I used a breadboard and some jumper wires so I could have rx and tx swapped over I also connected the 5vpower of the serial adapter to the 5vpower pin of the bluetooth adapter and did the same for ground. The other pins I left unattached labelled key and 3v on the bluetooth adapter. At this point I was then able to use the Serial Monitor from within the Arduino IDE to send AT commands to the bluetooth module. The key thing for this adapter was to ensure that the baud rate was set to 9. USB Serial Adapter Drivers Page. For windows usb serial adapter cables using prolific chip also mac and linux drivers for usb serail cables as well as x86 64bit. Just for the records, i could successfully install the driver and use the USBSerial adapter on Mac OS v10. 8. 2 Mountain Lion. The only difference from the tutorial. PCI to Serial 2port Controller Card based on NM9835CV Plug Play Automatically selects IRQ and IO address Supports PCI IRQ sharing. This particular adapter expects to receive the full commands in one go, which works well with the serial monitor in the Arduino IDE, as it lets us type text then send it when were ready. Here are some screen shots of using the serial adapter to configure the bluetooth adapter with AT commands via the Arduino IDEs serial monitor Note how the baud rate is set to 9. No line ending is selected. Firstly here I just send the command AT Then the adapter responds back with OK This command does nothing, but its handy for making sure that things are at least connected properly. Then here are some shots of changing the bluetooth adapters name to box bot by sending the command ATNAMEbot box Which yields a reply of OKsetname At this point the adapters name has been changed to box bot. So now we can attempt to communicate with it over bluetooth rather than via the serial port. So the next job is to pair the module with my OS X laptop using the Bluetooth Setup Assistant app. We start up the Bluetooth Setup Assistant and we can see the box bot module listed Select the adapter from the list and click Continue. Then we get to choose how to pair the adapter. In our case we want to enter a passcode The default passcode is normally 0. ATPIN1. 23. 4 which would set the code to 1. Hopefully you should then see the following, indicating that pairing has worked This should hopefully then mean you have a new serial port file descriptor created in dev. In my case this is named devtty. Dev. B and this is what youd use in any code to connect to the serial port. So in Python, using the pyserial module youd do something like this. Serialdevtty. Dev. B. baudrate9. Though you could use a the comports function to give you a list of all available serial ports and pick from the list yourself. I did find that to get the serial port to properly work you first had to scan for available Bluetooth devices e. Bluetooth Setup Assistant. Otherwise connecting to the devtty. Dev. B serial port would report an error. I guess its a bit like plugging in a cable. Once the connection is established though its essentially the same as a physical serial port from a code point of view, without the need for a physical wire. This makes it great for things like the Arduino, where the serial port is a pretty standard way to communicate with a main computer. The only odd thing was it seemed the connection tended to eat newline n characters. Not 1. 00 why this would be the case, but its something to watch out for when using this adapter.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |