HP5508A replacement v1.6 - Bluetooth link

"Everything is better with bluetooth "....

When I was testing the glass scale performance on the CNC machine a major annoyance was that I had to be very still, because the floor would flex when I leaned sideways. That made it very difficult to read the display of the computer with the data I was looking for. There has to be a better way - such as looking at the data on your cell phone.

So here we will add a bluetooth transceiver.

The transceiver I picked is a HC05.

The connection is pretty simple. Attention should be paid to use the 5V supply for Vcc:

The updated pin assignment is this:

Usage Pin (Arduino/PIC) Notes

   REF        0/RB5   
   AM2303     1/RB7              
   BMP180     2/RB8                 all I2C devices - not just BMP any more
   BMP180     3/RB9                 all I2C devices - not just BMP any more
   USB+       4/RB10
   USB-       5/RB11
   HC05/TXD  10/RA1 
   MEAS1     11/RB0                 LED4
             12/RB1                 LED3
   MEAS2     13/RB2                 LED2
   MEAS3     14/RB3                 LED1
   CLOCK     15/RA2
   HC05/EN   17/RB4
   HC05/RXD  18/RA4

And so the only code changes are a library to drive the HC05 and an occasional output of the data to the bluetooth device. The immediate goal is not to output all the data via bluetooth but only an occasional snapshot.

Since it basically shows up as a serial port on both ends we need a way to read that on the target device. Here you can see the data piping into the PC via the USB bus and at the same time into an android phone via terminal emulator.

That worked as a first test, but the format is not very human-readable. So for now I will change the format of the data coming in though bluetooth to this:

1x: 1000.00 nm 2x: 500.00 nm 4x: 250.0 nm

since the board has no way of knowing what type of interferometer is set up.

[Update: this code has now been commented out. Instead we are duplicating the data stream that goes out the USB serial connection.]

In the future, it seems possible to ditch the USB cable altogether. A PC with bluetooth will see the HC05 as a com port just like the USB right now. At least in principle the computer should be able to read the data through bluetooth just as well as through USB. That would be very nice, since power could be supplied by the 15V supply on the laser.

Initialization of the HC05 is a bit tricky. That is because in the AT command code it can be set to different baud rates, depending on how it was powered up. So if a new baud rate is programmed in and the firmware does not know about it, the device may not function.

According to (note that Pin 34 is connected to EN for this module.)


"To activate AT mode on the HC-05 zs-040 modules we can:

– 1. Hold the small button switch closed while powering on the module.

– 2. Set pin 34 HIGH (3.3v) when power on.

– 3. Close the small push button switch after the HC-05 is powered.

– 4. Pull pin 34 HIGH after powering the HC-05.

Method 1.

Enters AT mode with the built in AT mode baud rate of 38400. The baud rate cannot be changed by the user.

This method allows the module to enter AT mode on start but but does not keep pin 34 HIGH and uses the “mini” AT mode.

Method 2.

Enters AT mode with the built in AT mode baud rate of 38400. The baud rate cannot be changed by the user.

If you keep pin 34 HIGH you will enable the “full” AT mode which allows all AT commands to be used.

If you let pin 34 return LOW after power on then “mini” AT mode will be enabled.

Method 3.*

Enters “mini” AT mode using the user defined communication mode baud rate.

Method 4.*

Enters “full” AT mode using the user defined communication mode baud rate.

If pin 34 is kept HIGH then the HC-05 enters the “full” AT mode. If pin 34 is brought HIGH and returned to LOW it will put the module in to “mini” AT mode."

We cannot programmatically push the small button while powering on the module.

We cannot drive the module off of the 3.3V line and that is why it is permanently connected to 5V.

so that only leaves the method 4. So if the HC05 comes from a different project you may have to reprogram the baud rate first..



has a nice description of the available commands:

1 AT           Test UART Connection 
2 AT+RESET     Reset Device 
3 AT+VERSION   Querry firmware version 
4 AT+ORGL      Restore settings to Factory Defaults 
5 AT+ADDR      Query Device Bluetooth Address 
6 AT+NAME      Query/Set Device Name 
7 AT+RNAME     Query Remote Bluetooth Device’s Name 
8 AT+ROLE      Query/Set Device Role 
9 AT+CLASS     Query/Set Class of Device CoD
10 AT+IAC      Query/Set Inquire Access Code 
11 AT+INQM     Query/Set  Inquire Access Mode 
12 AT+PSWD     Query/Set Pairing Passkey 
13 AT+UART     Query/Set UART parameter 
14 AT+CMODE    Query/Set Connection Mode 
15 AT+BIND     Query/Set Binding Bluetooth Address 
16 AT+POLAR    Query/Set LED Output Polarity 
17 AT+PIO      Set/Reset a User I/O pin 
18 AT+MPIO     Set/Reset multiple User I/O pin
19 AT+MPIO?    Query User I/O pin 
20 AT+IPSCAN   Query/Set Scanning Parameters 
21 AT+SNIFF    Query/Set SNIFF Energy Savings Parameters 
22 AT+SENM     Query/Set Security & Encryption Modes 
23 AT+RMSAD    Delete Authenticated Device from List 
24 AT+FSAD     Find Device from Authenticated Device List 
25 AT+ADCN     Query Total Number of Device from Authenticated Device List
26 AT+MRAD     Query Most Recently Used Authenticated Device
27 AT+STATE    Query Current Status of the Device 
28 AT+INIT     Initialize SPP Profile 
29 AT+INQ      Query Nearby Discoverable Devices 
30 AT+INQC     Cancel Search for Discoverable Devices 
31 AT+PAIR     Device Pairing 
32 AT+LINK     Connect to a Remote Device 
33 AT+DISC     Disconnect from a Remote Device 
34 AT+ENSNIFF  Enter Energy Saving mode 
35 AT+EXSNIFF  Exit Energy Saving mode

More details available here:


So now the interferometer has bluetooth.