I’ve been scratching my head over this one for over a week now, would really appreciate your help.
I have an HM-11 bluetooth module that I want to connect via Serial to the Photon. I also want to be able to issue serial commands to the HM-11 through the Photon, and be able to read the results back.
I understand that there's two serials (actually 3) on the Photon:
- Serial --> Photon - to - USB
- Serial1 --> Photon TX - Device TX / Photon RX - Device RX
- Serial2 --> ... (not sure I understand this one)
I'm very confused cause I'm getting nothing back, and after reading the docs I've found this:
> To use the TX/RX (Serial1) or RGB Green (TX)/Blue (RX) LED (Serial2) pins to communicate with your personal computer, you will need an additional USB-to-serial adapter. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Photon/Electron to your device's ground.
So does that mean that in order to send/receive info through the Serial1, I need to switch my TX/RX wiring?
Also, I've looked everywhere and I couldn't find what the pins are for RGB Green and RGB Blue.
Could you guys point me in the right direction?
On the Photon, there is the “Serial” object that’s the USB serial. There’s also Serial1, that connects to the TX and RX pins.
On the Spark Core, there was also a Serial2. For all practical purposes this doesn’t exist on the Photon. You could theoretically enable it again on the Photon by disconnecting the RGB status LED and soldering in some wires.
In any case, all of the Serial pins are 0 to 3.3V. The RX pins are 5V tolerant, so they may work with devices that use 0-5V TTL style serial.
Under no circumstances can they be directly connected to a real RS-232C serial interface (such as on an old computer) because those signals are -12V to +12V. You need a level converter for that.
So you can think of them as an outbox and an inbox. Reading vs Writing.
So the Photon sends its signals out of the TX to transmit. Those are received on the Bluetooth through the RX. Etc Etc.
Disconnect both the RX and TX to the HM-11 and connect a wire between RX and TX. That should echo anything back across the USB serial to make sure your code is right, though it looks fine to me.
Have you reset the baud rate on the HM-11? I’m really not sure what the default is because the seeedstudio main page says 115200 but the manual Wiki says 9600. Maybe try 115200. Other than that, nothing really comes to mind.
Guys I figured it out!! It was the Atom serial monitor. I think it may be adding a new line or carriage return on my sent messages and the HM-11 wasn’t recognizing them!
From the documentation I got the part where it says "If the user enables Serial2, they should also consider using RGB.onChange() to move the RGB functionality to an external RGB LED on some PWM pins."
Is that all I need to do? use the onChange() function for activating the Serial2 purpose?
What does “The Blue and Green current limiting resistors should be removed.” mean?
The problem is that even if you disable driving the pins as the status LED in software, the common anode RGB LED allows some current to flow between the RX and TX pins causing corrupted serial data sometimes. The easiest way to remove this connection is to unsolder the current limiting resistors, leaving the LED disconnected from the pins.
All that means you need to desolder (or otherwise remove) several components from the Photon board. Personally, I advice against it unless you really know what all that means. There might be another way to achieve what you want, and people here are really helpful.
This portion should just give you a way to still see the RGB LED color code feedback after you deactivated the on-board RGB LED.
You can add an external RGB LED which can be attached to a set of PWM pins and should be software controled via the RGB.onChange() callback.
@rickkas7 & @BDub: If there'd ever be a v2 of the Photon, adding cut/solder jumpers to the board for de-/reattaching the resistors might be a good idea.