I'm starting to play with Arduino(Uno). As the first project I came up with a simple display of data received by OBD2 adapter. The connection is via bluetooth and a problem occurs here.
I'm using hc-05 bt module set as master, baud rate is set to standard 9600. Ofc i'm using voltage divider on rx pin. Pins are connected rx--rx/tx--tx but i've tried to mix it.
I've used three different slave devices - i could send and receive data on both sites on serial monitor, so everything works fine... on blank sketch.
If i add Serial.begin(9600) on setup, data sent from slave is not showing on Arduino's serial monitor(but still works in opposite direction). It looks like tx connection is disabled.
So you're saying that the code you posted with the Serial.begin() taken out and loaded to the Arduino displays information from Bluetooth on the the serial monitor. That's not possible.
It may be that you originally had some other code that did that and then you loaded that do-nothing code over it.
Perhaps your mistake is in thinking that loading new code to the Arduino ADDS to any existing code. It doesn't. It wipes out any existing code replacing it with the new code. If the new code says "do nothing" that's what happens.
I explained it too weakly. By communication i mean manual text sending from serial monitor and seeing it on the second serial terminal. I think only modules are used for this.
master ---> slave //works always
slave ---> master //works only on blank sketch
Thats why i'm wondering why 2) stops working after applying code above
How do you have this wired up? A diagram would help.
It sounds as though you have wired serial ports on the two modules together so that whatever goes out on serial from the terminal is seen by both of them. What do you intend the Arduino to do?
You may find it easier to use SoftwareSerial to talk to the slave so that you can debug using hardware serial. Also, it the master and slave are to talk to each other you'll need TX->RX and vice versa.
wildbill:
You may find it easier to use SoftwareSerial to talk to the slave so that you can debug using hardware serial. Also, it the master and slave are to talk to each other you'll need TX->RX and vice versa.
Holy moly SoftwareSerial worked perfectly. Thank you all for help!