Networking and Communications
This week's assignment was to design and build a wired/wireless network connecting at least two processors. I decided to continue on my work in Week 10 with collecting data via an accelerometer - this time, I wanted to stream accelerometer data wirelessly via Bluetooth. I did not get around to making a second processor, and instead streamed the data to my computer.
Using CadSoft Eagle, I modified the Fabduino to include headers for the Bluetooth module and ISP headers (Fabtoothduino?). I still have trouble programming the ATmega328p using the bootloader, so the ISP headers give me the option of programming the board using the FabISP. The name of the Bluetooth module is JBtek HC-05 Wireless RS232 for Arduino.
I used the Roland Modela MDX-20 to mill the PCB. After milling, I stuffed the board with an ATmega328p AVR chip with a 20 MHz external ceramic resonator.
I programmed the board in the Arduino IDE with the following code. Data is captured from the accelerometer into three ADC pins, and the converted values are sent over serial. I wired the three-axis accelerometer board I fabricated in week 10 to the Fabduino.
/** * Vincent Chow - 11/25/14 * Send accelerometer data over serial via Bluetooth on Fabduino * */ #define z_data A5 #define y_data A4 #define x_data A3 int xval = 0; // initialize variables int yval = 0; int zval = 0; int n = 1; // number of samples void setup() { Serial.begin(9600); pinMode(x_data, INPUT); pinMode(y_data, INPUT); pinMode(z_data, INPUT); } void loop() { xval = analogRead(x_data); yval = analogRead(y_data); zval = analogRead(z_data); Serial.print(xval); Serial.print(' '); Serial.print(yval); Serial.print(' '); Serial.println(zval); }
As you can see, the Bluetooth module was pretty straight-forward to use - no lines of code necessary to configure the settings. Once you connect the pins to the ATmega328p properly, the data is streamed from the Bluetooth module instead of by FTDI connection.
1) If your computer tells you to disconnect your USB device because of excess power draw, chances are you have a short on the board. I was lucky to immediately spot a solder bridge between a VCC and ground connection on my Fabduino, after which my computer could recognize the device without problems.