![]() ![]() Now we have 2 devices that can communicate with each other via Bluetooth protocol. By default, the pin for this module is 1234, and this password could be modified in AT mode. After a few seconds, the program should ask you for the pin code of the Bluetooth module. The # is the number of your device (probably be 0 if you have only one bluetooth dongle connected) and xx:xx:xx:xx:xx:xx is the address of the serial Bluetooth module. The pairing can be done by running the following command: sudo bluez-simple-agent hci# xx:xx:xx:xx:xx:xx The Bluetooth module that connects with Arduino and the Bluetooth dongle connects with Raspberry Pi need to be paired before making actual communication. The address and name of your Bluetooth module should be listed: It could take a few seconds to discover all Bluetooth devices nearby. Now you can search the serial bluetooth module by following command hcitool scan The Bluetooth dongle device name looks like “ hci0” or “ hci1“, in the example below, it is “hci0”: Then you can get the device name of your Bluetooth USB dongle by running the “hciconfig” command. ![]() Sudo apt-get install bluetooth bluez-utils blueman Run the following commands on your Pi: sudo apt-get update Plug the Bluetooth dongle into Raspberry Pi’s USB port. } Pair the Bluetooth USB Dongle with Bluetooth Serial Module Serial.begin( 9600 ) // 9600 is the default baud rate for the serial Bluetooth module Before you upload the sketch, make sure to temporarily break the TX/RX wiring between the Bluetooth module and Arduino, or they will affect each other and the uploading will fail. You can use the source code below for testing the Bluetooth module. If you use a Bluetooth module that only accept 3.3V, you will need to use voltage divider or level-translator between Arduino and the Bluetooth module. Remarks: the SPP-CA Bluetooth serial module we use is 3~6V tolerated. The USB plug in the figure below is just for power supply (DC 5V), and it has nothing to do with the communication. The Bluetooth serial module has 4 pins on board so it could be plugged into a breadboard. You can wire your Bluetooth serial module and your Arduino like this (we use Arduino Nano as example). Wiring Bluetooth Serial Module and Arduino Arduino Nano (or any other Arduino that has USB port on board).You will need the following components to implement such a wireless solution: But if your Arduino is more than 2M further from your Pi, you should consider a wireless solution, such as using Bluetooth as a serial bridge. However, what if the Arduino needs to be placed far from the Raspberry Pi?įor example, if you want to put Arduino out of my window and you still want to control it with your Pi on desktop, what to do? A long USB cable may do the trick, if the distance is not that long. USB cable is neat enough if the major of cases. This is very interesting and you can imagine many ways to use them. We have a open-source project for developing the APIs for controlling Arduino in Raspberry Pi. Connecting Raspberry Pi and Arduino with USB cable can do a lot of interesting things. Since Raspberry Pi is a full-featured mini computer, it can talk to Arduino as well, just like those big computers do. The USB connection can be used on not only uploading the sketch to Arduino board, but also exchanging data between Arduino and computer in real time. Some Arduino boards have chip on board to support serial communication over USB, and will appear as a serial device when you connect them with your computer via USB cable. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |