PWM Over BLE UART With Ameba

by daphwl in Circuits > Arduino

72 Views, 0 Favorites, 0 Comments

PWM Over BLE UART With Ameba

BLEPWM.png

Ameba RTL8722DM

Ameba RTL8722DM is a low-power dual-band WLAN and BLE(Bluetooth Low Energy) SoC by Realtek. The RTL8722DM also include memory for Wi-Fi protocol functions and application making it simple for anyone to develop various kind of IoT applications. At the same time it has a wide range of peripheral interfaces. With all these interfaces, it can connect to most of the electronics components like LEDs, temperature and humidity sensors, and so on.

BLE UART

With BLE, application data is sent and received using the GATT system. GATT uses services, characteristics, and attributes to organise data and control how the data can be read from and written to. The Bluetooth SIG specification for BLE includes several predefined services for common applications, but users are free to implement custom services and characteristics to best fit their data structure and application needs. In this example, the BLEService and BLECharacteristic classes are used to implement a custom service for transmitting ASCII characters similar to regular UART. This custom service is the Nordic UART Service, which is supported in several smartphone apps.

In this example, a smartphone app is used to transmit commands over BLE UART to control the PWM outputs and change the color of a RGB LED. Refer to the other example guides for detailed explanations of the BLE UART service.

Supplies

  • Ameba RTL8722DM x1
  • RGB led x1
  • Android / IOS smartphone x1

Setting Up

BLEPWM1.png
ArduinoLogo.png
Bluefruit Connect.PNG

First, connect the breadboard to Ameba.

Then connect the RGB led and resistors in as shown in the wiring diagram.

On the RGB led, there is a common pin which need to connect to either 3.3V or GND depending on the type of LED. (Common Cathode/Common Anode)

Ensure that you have already installed the required software in your smartphone. The app is available in both

Programming

BLEPWM2.png

The programming can be done using Arduino IDE which makes it very easy to write code and upload to the Ameba board.

  • To open the sample code in the Arduino IDE, Open "File" -> "Example" -> "AmebaBLE" -> "PWM_over_BLEUart"
  • Upload the code and once the upload is finish, press the reset button on the Ameba.

Setting Up the App

BLEPWM3.png
BLEPWM4.png
BLEPWM5.png

Open the app on your smartphone, scan and connect to the board that is named "AMEBA_BLE_DEV" and choose the controller, then Colour Picker function.

Final Result

BLEPWM6.png

Using the color selection wheel, saturation, and brightness sliders, choose a desired color and click select to send the RGB values to the board. You should see the RGB LED change to the matching color.

Additional Resources?

If you need additional technical documents or the source code for this project. Please visit the official websites and join the Facebook group and forum.