Bluetooth/Wifi controllable LEDs

Having seen that companies offer RGB Light bulbs controllable by your mobile, I thought of how to do this on my own as an improvement for the bascetta stars mentioned here: Small Device With colour circle.

How to start? Research is the clue to success.

I do my electronics as a hobby. SMD soldering is not what I want to do. Everything should be able to put on regular a PCB board.

Next question: How to remotely control the electronics? Three options came to my mind:

A 433MHz Sender Receiver. Problem here: Impossible to control with a standard smartphone.

A Bluetooth coupling. Possible

A WiFi 802.11 coupling. Possible

I decided to go for both possible variants. How to do that? After some research I found some nice small PCBs.

For Bluetooth, so called HC05/06 PCBs provide a link between bluetooth and a serial line (TXD/RXD)

For Wifi something similar exists, based on an ESP8266 Chip, providing a link between WIFI and a serial line (TXD/RXD)

In this article I will describe both solutions a little bit more in detail.

The controller

Since both remoting options include a RX/TX interface, the controller should be able to provide those. In addition to that there should be enough pins to drive a RGB LED. Since I own an ATMEL Programmer, the device should be an ATMEL. Quite fast the choice was the 2313A ( The cheaper but equal variant to the older 2313). If the programming would take more space than thought, the 2313A has a bigger brother, the 4313 which only differs in size of RAM and ROM. A big bonus of this device are the 4 hardware PWM lines, so no need to implement our own.

Bluetooth

As described above, the choice for Bluetooth implied a HC05/HC06 module. In our case a HC06 is sufficient. The HC05 has the possibility to actively connect to another device. The HC06 only works in slave mode, means another device has to initiate the connection. Perfectly fine for us. HC06 it was. It comes as a little PCB not bigger than a stamp. The pins are located around the PCB and there are lots of them. Luckily only 4 are needed: TX, RX, VCC, GND. In order to check them out, I attached on with a USB to TTL converter. Watch out! The HC06 wants 3.3Volts and not 5.

The description says that the HC06 by default “talks” 9600 8N1. I adjusted the settings, started my putty on the serial line and typed in AT. Without pressing return, the answer came: “OK”. Looks good.

In order to control the HC06, only 3 commands are necessary:

=> Control the baudrate. 115200 works perfectly for me.

=> Give the Device a Bluetoothname. Think of something usefull here.

=> Define a password for pairing if you like. default is 1234.

Since the HC06 respons to a typed AT more or less immediatly with an OK, providing more complex commands requires you to be very fast in typing. Since I am not, I used a wordpad, prepared the AT sequence and did a copy paste into my putty terminal.

Everything worked out fine. I changed the Baudrate (reconnected to the device with the new baudrate), gave my device a nice name, and decoupled it from the USB to TTL converter.

I connected it to the 2313A. TX to RX, RX to TX, GND and VCC. Since the HC06 needs 3.3V I decided to drive the 2313A also with 3.3V. No problem.

I attached 3 RGB LEDS to the PWM outputs. Since the voltage for the red part of the LED is lower than for green and blue, I chose 33 Ohm for the red and 47Ohm for the other two.

Interacting from the 2313A with the HC06 is extremely simple. Since I did the Baudrate change and the renaming of the device with an attached USB/TTL converter, there was no additional command to give from the 2313A side. As soon as a remote controller was connected to the HC06 via Bluetooth it was just sending bytes from the controller to the 2313A. Currently the 2313A only receives controldata from the controller. It does not send data back. Could be done, but what for.

I decided to implement a color circle that was circling if no controller was connected, so the device produced some nice light even in “standalone” mode.

With a controller attached, the 2313 listenes to 3 possible commands:

RRGGBB#

=> set the RGB LEDS to the given color. RR, GG, BB are in HEX.

c#

=> Continue with color circle.