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
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).
There are so many HC-06 boards about - so yours might be a pure 3.3V board, but mine was () 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.
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.
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.