PIC to iOS Serial Bridge (via Bluetooth)


There are some projects were I could use a simple serial text user interface to an embedded PIC processor.  It occurred to me that Bluetooth may provide me this link so that I could use my iOS phone or tablet to quickly access a microprocessor without looking for cables.

With some searching I identified Bluetooth Low Energy (BLE) as a good possibility.  There are some inexpensive and small modules that put a wrapper on some chipsets and allows you to talk via the ubiquitous serial asynchronous protocol built into many processors.  Among these, the industry standard appears to be the HC-10 series of interface boards.

Logic-level serial interface

I could tell that these modules all use logic level voltages for the serial interface, rather than the +/- 12V of normal RS232 communications.  I decided to modify one of my USB serial boards for this task.  For this I selected a GMUS-03 USB to serial adapter as it had a small circuit board that was accessible.  I traced the wiring on the board and bypassed the 12V voltage translator circuits so that the interface was direct logic level IO.

I bypassed the +/-12V translator circuit on this serial
interface to talk direct logic (0-5V) levels.

I kept the same 9 pin D interface for the physical connector.  Per the standard, pin 2 flows data TO the computer.  The voltage level on pin 3 was 5V (idle), and pin 2 had a threshold of 2V.  So that means that 3.3V logic is able to send data to this board.

A simple loop back connector (pin 2 tied to pin 3) showed this adapter was operational and I was up and running.


The first BLE board I tried was purchased from Banggood for $3.  This is the AT-09 and it stated HM-10 compatibility on the web page.  However, once I received the item (3 week delivery, not too bad), it was clear there were several differences with the HC-10.  One big one is that this is 5V compatible, both power and logic.  That makes it very convenient to interface to my serial adapter and a PIC.  Another difference is the pinout of the module.
I built a small circuit board to interface and power the module as shown below.  This allowed me to use a serial interface program such as Tera Term on my PC to exchange live data with the module first without using a PIC as a middle man.

AT-09 test board.  This has a Flash 16F877 PIC that is programmed via the
RJ11 connector at the top.  The AT-09 module itself is in the top left.
The three colored (red-black-white) cable on the bottom left goes
to the modified serial interface at the top of this page and
forms the link to the PC running Tera Term.

The module should flash its red LED upon power up.  You can then send it commands via 9600, 8, none, 1.  It is vital to follow every command with CR and LF or you will not get a response.

After some trial and error I finally got the desired "OK" response from the AT-09 and I could query it for information.  Some links to pages I found helpful:
When not connected on the Bluetooth side, the serial interface will respond to "AT" commands.  Be sure to terminate each with carriage return and line feed.  This is a list using the module's 'help' command:

* Command             Description                                  *
* ---------------------------------------------------------------- *
* AT                  Check if the command terminal work normally  *
* AT+RESET            Software reboot                              *
* AT+VERSION          Get firmware, bluetooth, HCI and LMP version *
* AT+HELP             List all the commands                        *
* AT+NAME             Get/Set local device name                    *
* AT+PIN              Get/Set pin code for pairing                 *
* AT+PASS             Get/Set pin code for pairing                 *
* AT+BAUD             Get/Set baud rate                            *
* AT+LADDR            Get local bluetooth address                  *
* AT+ADDR             Get local bluetooth address                  *
* AT+DEFAULT          Restore factory default                      *
* AT+RENEW            Restore factory default                      *
* AT+STATE            Get current state                            *
* AT+PWRM             Get/Set power on mode(low power)             *
* AT+POWE             Get/Set RF transmit power                    *
* AT+SLEEP            Sleep mode                                   *
* AT+ROLE             Get/Set current role.                        *
* AT+PARI             Get/Set UART parity bit.                     *
* AT+STOP             Get/Set UART stop bit.                       *
* AT+START            System start working.                        *
* AT+IMME             System wait for command when power on.       *
* AT+IBEA             Switch iBeacon mode.                         *
* AT+IBE0             Set iBeacon UUID 0.                          *
* AT+IBE1             Set iBeacon UUID 1.                          *
* AT+IBE2             Set iBeacon UUID 2.                          *
* AT+IBE3             Set iBeacon UUID 3.                          *
* AT+MARJ             Set iBeacon MARJ .                           *
* AT+MINO             Set iBeacon MINO .                           *
* AT+MEA              Set iBeacon MEA .                            *
* AT+NOTI             Notify connection event .                    *
* AT+UUID             Get/Set system SERVER_UUID .                 *
* AT+CHAR             Get/Set system CHAR_UUID .                   *
* -----------------------------------------------------------------*
* Note: (M) = The command support slave mode only.                 *

It is interesting to note that the baud rate setting persists after a power cycle.  This makes me wonder how to reset it if I forget or get out of sync.

With the setup completed, it is time to send data to and from your iOS device.  I loaded the BLE Terminal app onto my phone and when it does a scan of devices, it found "MLT-BT05", which matches the name of the device as found on the serial interface via the AT+NAME command.  Tapping on that device opens a terminal window as shown below.  Typing characters into Tera Term caused them to appear immediately on the phone and vice versa.  I was able to get this to work from my basement while the PC was on my second floor.  BLE Terminal has a handy signal strength indicator for the link margin (not shown below).

Once you are "connected" via BLE Terminal, you need to perform a Disconnect in order for the AT command set to be interpreted (instead of the characters being relayed over Bluetooth).

  Note.  Fig 6.6 on SS Page 51 7E (FMC_B_P1)

BLE Terminal app on my phone shows two-way
stream between module and phone.
Sorry for the typo.


The next one I tried out was purchased from Ebay seller 'super-genius!' and arrived quickly due to US sender's address.  Cost was slightly higher at about $4, but not surprising as it shipped from a US address.  The appearance of this board is almost the same except some resistors are different in size, and this does not have a pushbutton.  I expected it to be a drop-in replacement as the one above, but to my surprise could not get any acknowledgement to the AT command nor any other command.  Simply connecting my iPhone to it (shows up as "JDY-09-V4.3") caused the red LED to go solid.  I could then exchange data from the PC connected to the serial wires to the iPhone at 9600 baud.  At this point, I will only use this variant for slower speed projects.  I had purchased two of these units and both behaved the same way.


I will be trying this option in the future.  Looks very user friendly with iOS app support.

First use: X-10 Signal Monitor

The first project that I installed one of these modules into was the X-10 Monitor.  It is the perfect application of this bluetooth link as I wanted to keep the monitor's portability and the simple remote control was what I needed.

Bluetooth data module added to the monitor (upright on the left).

With this interface, I can connect to the monitor anywhere in the house and check the received signal strength at the main breaker panel (or where ever the monitor is located).

Back Home

(c) 2020 Edward Cheung, all rights reserved.