Posts

Showing posts with the label bluetooth

Bluetooth programmer

Image
From breadboard to perfboard I have been busy bending Bluetooth modules to my will.  The typical parameters I need to control are the module name, baud rate, and whether the module is a slave or master.  To program my quadcopter over Bluetooth, I have defined a Bluetooth module as a Master, which connects automatically to the quadcopter slave module when available.  The Master module connects to the PC via an RS232 USB converter - until now this been a mass of wires living on a breadboard, but I've now finally soldered a simple circuit together to allow me to program modules more easily.

A tale of two UART devices

Image
Resolving UART bus conflicts and voltage levels I wanted to record two potential issues I found with using my custom Atmega328p board with onboard USB FT232 when an HC-05 bluetooth module in introduced, in the hope it may well be helpful to others. Above:   A small piece of perfboard modifies the Bluetooth socket to include a 5V to 3.3V voltage divider on the Bluetooth HC-05 RX line (10 and 20kohm resistors).  The red wire provides a direct line from the Bluetooth HC-05 TX output and the Atmega328p RX input, thereby granting it preference when the HC-05 module is present.  It's not quite clear from the picture, but the RX input pin is bent up out of the socket and a 1k resistor connects the FT232 TX output (see below).

Customising Optiboot

Image
I wanted to setup programming my custom Atmega328p board over Bluetooth.  Some have used the connection pin to control the Reset pin of the AVR.  However I want to use Bluetooth constantly, and only trigger a reset upon receiving a specific string sequence.  This requires tweaking the bootloader, using Optiboot as a basis: (1) Change Baudrate to be mutually compatible with Bluebooth and AVR. (2) Set an EEPROM byte in the main application, which could be read (and written) in the Optiboot routine. Setting up Optiboot in the Atmel environment: - Setup a project as usual in Atmel Studio - Copy files over from github to the project folder: optiboot.c, pindefs.h, stk500.h and boot.h. EDIT: It seems there is an AtmelStudio folder already set up on github . Setting baud rate to be compatible with AVR and Bluetooth module: 57600 bps - Insert #define BAUD_RATE 57600 (as required) into optiboot.c . - Compile and link project with following settings: Compiler Mis...

Programming Atmega328p chip wirelessly with nRF24L01+ module - Part II

Image
Fitting nRF24L01+ code into a bootloader A brief follow up to an earlier  post .  I previously had a system working whereby I was able to program an Atmega328p chip, using a connected Arduino Nano, but crucially using an nRF24L01+ module rather than a wired UART/PC connection.  What I really wanted however was to remove the Arduino Nano, and to program the MCU chip 'directly' by use of a bootloader with nRF24L01+ code to replace with the usual UART functionality.  I thought initially that I wouldn't be able to cram the radio module code into a bootloader, but in fact it wasn't too difficult.  I used Optiboot as a starting point and implemented bi-directional radio control within the bootloader.  I think it ended up being less than 1024 words (2048 bytes). I'm not an expert here - but I had to modify the compiler and linker parameters to get things to work: Compiler flags: -g -Wall -Os -fno-split-wide-types -mrelax Linker flags: -Wl,-section-s...

HC-05 troubleshooting

Image
Some HC-05 modules are more equal than others I've been playing with some cheap HC-05 bluetooth modules I picked up off Amazon.  They are a very convenient and easy way to add remote control to a project, using two wire UART (RX/TX) in the usual way, so can replace an existing serial connection to a PC for example.  They work pretty much out the box and there are loads of guides to using them.  I thought I would share a few thoughts on using these modules though as I've come to realise that all HC-05s are not created equal... There are some visual clues.  On the back of my modules I have an "EN" pin whereas some other HC-05 modules have a "KEY" pin.  The KEY pin is used to place the module into "AT command mode", by putting it high (3.3V) before powering up the module.  I initially thought that the EN pin was analogous to the KEY pin (a different name perhaps), but the EN pin can be used to disable the bluetooth module , which I guess is...