This week, we design and build a wired and/or wireless network connecting at least two processors. I am hoping to use this week for my final project board, where tiles will communicate over Bluetooth Low Energy. I'm planning to use an HM11 module, pictured first below, but also considered the ESP-32 for its many integrated functions (pictured below, underneath).
The bluetooth scenario for my tiles is as follows: Use a BLE connection to send data from the sensor to a nearby computer running a processing script for data visualization. For my final project demonstration, I plan to broadcast the accelerometer and magnetometer data from a specially outfitted tile to my laptop's Bluetooth receptor, where processing will then read in this input as if coming from a serial port. In considering the HM11 for the chip design, I am primarily interested in the ability to hook up the BLE module over the Tx and Rx lines. However, size considerations (I want the full circuit to fit on a tile just a few cm across) also led me to choose this smaller BLE module (over say, the more complicated ESP32).
My networked, final project board will include:
- 6 DOF LSM303dlhc accel + magnetometer (plus a built in temperature sensor)
- Gyro (perhaps in a later version, did not make it into this particular design)
- ATMega 328p
- Voltage regulator, 8MH resonator, 3 Leds, capacitors & resistors as required
- Programming ISP header and FTDI
To begin, I needed to mill a new sensor board, building on the design I fabricated in the Inputs & Outputs week (prior version here.) Below, you can see the redesigned primary circuit, condensed to fit within a hexagonal perimeter that fits my 3D printed tiles and a narrow, powered interface board for the HM11 module. Regarding the interface boards I'll need for this week--one bridges the chip board and the BLE breakout board providing power to both and connecting the Tx and Rx lines, and Neil's design for the HM11 "hello world" board provides a way to interact with this module.
Below, you can see the PCBs assembled on the tile, powered with a 9V battery to allow operation without requiring power over FTDI and connection to my laptop (as in my previous boards).
Below, you can see a close-up of the bluetooth module that will be connected over FTDI to my computer, to act as the "receiving" channel for the data sent over the BLE HM11 attached to my main board. After this photo, I ended up connecting the module to the computer in a different manner, as documented later.
The following photo shows the full hardware setup, with the sensor board (a modular component) attached to the headers on my main chip board (the hex tile), connected over FTDI-style vinyl cut copper hinges (to allow freedom of motion and the bonding angle of the assembly) to the HM11 bluetooth module. This first HM11 communicates the data from the chip board (sent over I2C from sensor to the chip) to the HM11 wired directly to my computer. The module wired to my computer receives the data over BLE and my computer reads it in over a COM port (as I'm using the FTDI serial connection) and can display a live rendering of the sensor data over time via a processing script.
For the code I'm using on the 328p chip and the processing script, see the prior Application Programming week. I have made minor modifications to also show magnetometer data, and to match the baud rate from Arduino defaults to the baud rate of the BLE modules (in my case, 115200). Note on the baud rates for BLE modules---if you are trying to communicate between two BLE modules that come with different default baud rates, you can set a new baudrate via "AT commands." More on this in a moment...
For more on AT commands and how to configure the HM11 module, read the datasheet here. Below, I show the result of giving AT commands over the arduino serial monitor to the BLE module currently connected to my computer. I connected both BLE modules (at different times) to program them at the same baud rate, name them and confirm they were exhibiting the expected behavior. I programmed the BLE module that was to be connected to my computer as the orchestrator/host or, due to the unfortunate standard BLE protocol naming, the "master" (while the other module is by default the peripheral or "slave").
Once my sensor+chip board is powered on and transmitting data over BLE, I need to tell the two BLE modules to connect. You can do this with the following sequence of commands, also shown in the picture below:
- AT (response should show "OK")
- AT+DISC? (for discovery of other nearby devices, should show a list with MAC addresses)
- AT+CON[MAC address from prior result, for the device you want to pair with] (should look like "AT+CON123456789101" with 12 digits that correspond to your other device)
The screenshot below shows the result of a successful pairing, where sensor data is being received by the computer's local BLE module connected over FTDI, and successfully interpreted by the arduino serial monitor (over COM port) at the 115200 baud rate.
The three following videos summarize the successful BlueTooth pairing, communication of sensor data over BLE and demonstrate the live responsiveness of the accelerometer and magnetomer to appropriate stimuli
Final Project Complete!
My final project is now complete, with a fabricated prototype that includes magnet-jointed tiles (for later self-assembly testing in zero gravity), augmented with circuitry that reads sensor inputs, communicates a visual output via LED, sends data over BLE, and visualizes the data by an application coded in Processing.
Summary of weeks represented by this project:
- Computer-Aided Design/Modeling
- Computer-Controlled Cutting (vinyl cutter could be used for the copper hinges)
- 3D Scanning & Printing
- Electronics Design
- Electronics Production
- Embedded Programming
- Interface & Application Programming
- Networking and Communications