Photon - Serial1 vs Serial - Bluetooth Module HC-06 [SLOVED]

I’m comfortable using Serial on the Photon, just never used Serial1. Typically I use PuTTY and connect to the COM port my Photon is on and I can see any data sent from the Photon (using Serial) in PuTTY.

I’m trying to use the RX/TX pins on the Photon (which are connected to a Bluetooth receiver - HC-06). The TX of the HC-06 module is connected to the RX pin on the Photon and the RX of the HC-06 module is connected to the TX pin of the Photon. The HC-06 is powered using 3.3V and grounds are connected between the Photon and HC-06

I have C# application that connects to the Bluetooth receiver and sends it data. I can confirm the C# application works because I use it with another MCU (using the same HC-06 module).

On the Photon, I’ve got the following code in the loop method:

    while (Serial1.available() > 0) {
        Serial.write(Serial1.read());
    }

The C# App connects to the HC-06 (indicated via a steady red LED on the HC-06). The app starts to send data. What I was hoping to do/see is the data I send via the C# application appear in PuTTY. But no such luck. Did I just overlook something obvious?

As an aside…
I just connected the HC-06 via FTDI to my PC and opened PuTTY on that port and I see the data streaming in on the terminal. So the C# app and the HC-06 are doing what I expect. Now…I’d like to see the data streaming into the Photon :wink:

are you calling the begin() method to get the Serial port working at the correct baud rate, ie:

Serial1.begin(9600);  // your desired/expected baud rate

Yes, I am. I omitted the setup method from my earlier post, thinking that would be obvious :smile:

Does the device respond to AT commands?

e.g.

  Serial1.println("AT+NAME");

You might also consider powering the module off Vin as it wants 3.6~6V AFAIK

Yes, the HC-06 does support AT commands. I’ve set the name of the device and the baud rate. I just happened to set the baud rate to 9600 (it was 115200).

I now see data but it’s gibberish. So I’m guessing a mismatch somewhere. But on the Photon I’ve changed the baud rate to 9600 (which is how I’m seeing gibberish).

When sending AT commands from Photon to HC-06, is the response gibberish or only the remote data sent to your Photon via the module?

Hmmm… It works just fine with 3.3 (I’ve been using it for years on 3.3v.). Vin, won’t that be 4.8v or there about?

There are so many HC-06 boards about - so yours might be a pure 3.3V board, but mine was (:weary:) on with regulator which wouldn’t work off 3.3V.
What exact board have you got?

Oops, sorry, I should have mentioned. I configure the HC-06 via my PC (via FTDI). No gibberish there. Including when I my sends data to the HC-06 and it’s connected to my PC via FTDI, and baud rate set at 115200.

So my suggestion still stands.
Try AT commands from the Photon and see what comes back.

JY-MCU V1.06

Ok, let me try that.

Does this look like yours?

Vcc 3.6~6V, so 4.8V falls into that range (3.3V doesn’t :wink: )

The one I have matches the bottom image. Ok, I’ll try the Vin pin instead.

Gibberish, using the Vin pin as well.

Tried the AT commands from the Photon

I have

    Serial1.write("AT\r\n");

I tried without the \r\n as well. Either ways, no response from the device (at at least I don’t see anything in PuTTY.

I mistakenly use Serial1.write() instead of println to send the AT command. I changed that. I get gibberish back.

Putting a 47K resistor from 3.3V to the RX pin (of the Photon) fixed the gibberish data. I remember I did the same thing a while back when I was using a Netduino (also a 3.3v Device). So these JY-MCUs seem to have a issue with the levels or something.

Just to be clear. Even though @ScruffR is correct, in that I should be using a voltage between 3.6v and 6v, Using a 47K pull-up for the RX pin of the Photon (I’m not using TX at this time - that is the Photon is only currently receiving data from another Bluetooth device) solves the issue I’m having. Using the Vin pin or 3v3 pin to power the HC-06 Bluetooth module made no difference.

1 Like

Ok, now (with the 47k pull up on the RX pin of the Photon) the data is streaming in from my C# application as well. Set the baud rate back to 115200 and all looks good still.