Can anyone shed light on this behaviour?
Using an HC-05 Bluetooth and a Nano (non-genuine) and communicating via the h/w serial port (pins 0 & 1). HC-05 is connected to Android phone running Bluetooth serial terminal app.
To communicate b/w the HC-05 and the IDE monitor without going thru a sketch, this hookup is the one that works:
. HC-05 TX to Nano TX (pin 0) . HC-05 RX to Nano RX (pin 1) . Nano RST pin grounded, so sketch is suppressed
Text typed on the phone terminal app appears in the IDE monitor and vice versa.
But to communicate b/w the phone and a sketch, this is the hookup that works (opposite to above):
. HC-05 TX to Nano RX (pin 1) . HC-05 RX to Nano TX (pin 0) . Nano RST pin is not grounded . Sketch uses Serial.read to get char from the serial port and turns on LED (pin 13) if '1' received and turns it off if '0' received and Serial.print to echo the character received.
This works. Text entered on the phone is returned by the sketch to the phone (terminal's local echo is off). Entering '1' makes the LED come on and '0' makes it go off.
So, exact opposite connections required in each case. It's as if the sketch reverses the roles of pins 0 & 1, which you could do with software serial on other pins, but the statement used is the normal "Serial.begin(9600)".
Is this surprising or am I misunderstanding something fundamental (wouldn't be the first time)?