LESSON TEME: Networking and Communications

  In this week, I tried network programming by using a Bluetooth module. This video shows the result in which I'm setting a number for blinking count of a LED settled on an Arduino by using a Python Serial Program running on a Laptop. The number is transmitted to the Arduino via Bluetooth Serial Communication and the Arduino blinks the LED according to the number.

[1] Bluetooth Communication between Laptop PC and Arduino

PROTOTYPING: Bluetooth Communication Between Laptop and Arduino

  I used a bluetooth module of "CRIUS" which is a kind of bluetooth module used in a drone. Figure 3 shows a wiring diagram I connected an Arduino with a Bluetooth moudule. At first, I had a mistake for the wireing connection for TXD and RXD of the Bluetooth module. Be careful that TXD and RXD of a Bluetooth module has to connect to RX and TX pin on an Arduino respectively. Don't conncet TXD to TX and RXD to RX. Figure 4 shows the programming code for an Arduino to do serial communication. At the first step, I tried to use "SoftwareSerial" library for Arduino but it didn't work well. (my Arduino version is 1.6.8) The library can "write" for serial communication but can't "read". Espacially, SoftwareSerial.available() function doesn't work well. Then, I tried to use "Serial" library for Arduino. This library work well. I sometimes failed to upload my sketch to the Arduino. So I searched the solutions in the Internet and found that the wires of TXD and RXD have to be unpin from an Arduino, otherwise the sketch editor shows error messages of failed to upload. Next step is Laptop setting. For bluetooth communication, I made a pairing for bluetooth communication on Mac Settings Pannel. Figure 6 shows a code for serial communication by using Python. PySerial seems to be a good library for this work. The programm require to input a number from keyboard. The number is transmitted to the Arduino via Bluetooth serial communication. Figure 7 is an appearance to run the programm. The red LED of bluetooth module blinks when the power is supplied but not connect any bluetooth device yet. The red LED is keeping light on when it is connected anothe bluetooth device. The Arduino receives the transmitted number and blinks the LED according to the number.

web site page
[2] Bluetooth Module
web site page
[3] Wiring Diagram for Connecting Arduino and Bluetooth Module
web site page
[4] Programming Code for Bluetooth Communication
web site page
[5] Paring Setup Between Laptop PC and Bluetooth Module
web site page
[6] Python Code for Bluetooth Communication
web site page
[7] Software to Send LED Blinking Number
web site page
[8] Prototyping Complete, Go Next Stage!

Bluetooth Communication Between Laptop and ATtiny44

  I tried to make two types of bluetooth communication: one is to send data from Attiny44 to my laptop and the other is to send data from my laptop to ATtiny44. I reused the electronic board developed in week8. The first one is almost similer architecture of week 11 (input device)[9] . I used a sound sensor and send the data to my laptop PC. The result is shown in Video [10]. The second one is a newest one for my final project. This electronic board can receive a message from my laptop PC via Bluetooth Serial Communication. The electronic board move a servo motor according to the message. The laptop PC has a software to control and send a message to the board [11]. The operation of the software is that if I keep pressed "1" key, then the servo moter move. The mesage of "1" is "Go Sign Signal". So, the electronic board keep waitning the message. The a part of the program code is shown in Figure [12]. The software is implemented by using Processing. The architecture is shown in Figure [13]. The Video [14] is an appearace to control the servo motor from laptop PC.

web site page
[9] Wiring Setup Sound Input Viewer of Bluetooth version
[10] Input Sound Data Viewer from ATtiny44 via Bluetooth Serial Communication
web site page
[11] Software to Control a Servo Motor via Bluetooth Communication
web site page
[12] A Part of Programming Code for Waiting a Message
web site page
[13] Wiring Setup Servo Motor Remoto Controller
[14] Controlling Servo Motor on ATtiny44 from Laptop PC via Bluetooth Serial Communication

Data Files