i) Cirago Bluetooth 3.0 & Wi-Fi Combo USB Mini Adapter
This is a Wi-Fi & Bluetooth Combo. At first, I connected this directly to Raspberry Pi.
I could easily check the connection status with lsusb command. At first, it seems that bluetooth works well, but Wi-Fi doesn't. So I searched about that issue, and set some files to make WiFi work properly.
https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=44044
This is an website which includes some solutions about WiFi issue.
We can check RX/TX packets increased in wlan0 with ifconfig -a command. Also, I could remote access to Raspberry Pi using WiFi.
ii) Arduino UNO R3
I could check Arduino connection with same method I used for USB dongle.
Arduino package can be installed with sudo apt-get install arduino command. After that, we can check there's Arduino IDE.
Also, we can make serial connection with pyserial. Install with typing commands below.
wget http://sourceforge.net/projects/pyserial/files/latest/pyserial-2.7.tar.gz
tar -xzf pyserial-2.7.tar.gz
cd pyserial-2.7
sudo python setup.py install
Now, we can test a simple example.
First, upload this code with Arduino IDE.
void setup(){
serial.begin(9600);
}
void loop(){
for(int n = 0; n < 100; n++){
Serial.write(n);
delay(100);
}
}
serial.begin(9600);
}
void loop(){
for(int n = 0; n < 100; n++){
Serial.write(n);
delay(100);
}
}
Then we can compile this python code, and check the result.
import serial
potr = "/dev/ttyACM0"
serialFromArduino = serial.Serial(port, 9600)
serialFromArduino.flushInput()
while True:
if(serialFronArduino.inWaiting() > 0):
input = serialFromArduino.read(1)
print(ord(input))
import serial
potr = "/dev/ttyACM0"
serialFromArduino = serial.Serial(port, 9600)
serialFromArduino.flushInput()
while True:
if(serialFronArduino.inWaiting() > 0):
input = serialFromArduino.read(1)
print(ord(input))
Numbers are printed in the shell window. We can check Serial communication between RPi and Arduino with this simple test above.
댓글 없음:
댓글 쓰기