I'm trying to use a serial Bluetooth module with my arduino and I felt I needed some more education on how serial communication works. So I read up on everything I could find and now I have a pretty basic understanding of how it all works. The only thing I don't understand is how the serial monitor fits in. Does sending something go to the Arduinos RX or TX? I heard somewhere the using the serial monitor with a serial module attached can cause a thing called bus contention. Can someone sort this out for me please?
ShaneDancy:
The only thing I don't understand is how the serial monitor fits in.
It only just fits at all. It is a debugging device more than a terminal, and you will eventually be better off with a real terminal, like Realterm. Bus contention is caused by Arduino's hardware serial port, D0,D1, being shared by the USB and bluetooth, and the only way to use the monitor is via the USB. This is usually about COM4,COM10. The bluetooth on my laptop runs on COM40, and works fine with RealTerm.
Sharing D0,D1 can be tedious but not really a problem, as it doesn't happen in proper practice. You could put Bluetooth onto software serial, but I bet you don't have a good reason to do so, and it is best avoided anyway. A Mega has four hardware serial ports and, if you really need multiple serial, it's a better proposition.
Note that you can have the serial monitor share with bluetooth when bluetooth is talking to another device, like the phone, but this just enables you to see what is going on, i.e. for debugging.
The only thing I don't understand is how the serial monitor fits in. Does sending something go to the Arduinos RX or TX?
The serial hardware that is one of the subsystems of the ATmega328 processor is connected to external devices via the pins that are labeled D0 and D1 on your Arduino.
Since the Arduino IDE uses that serial hardware subsystem to load your program code it's USB port is connected, via some interfacing components to those same two pins.
After your program is loaded into the ATmega328 you are free to use the serial hardware subsystem to display messages by invoking the 'serial monitor' or some other 'terminal' program.
If you have no need to display messages, and if you don't invoke the serial monitor or another terminal program, then you are free to use those two pins (D0 and D1) to connect to your Bluetooth module, an X-Bee, a serial LCD, or any other compatible serial device.
Nick is experienced with Bluetooth devices so if he says you can implement the serial monitor along with a Bluetooth module I guess you can. Normally it is a good idea to only deal with one device at a time on the serial port which is why you see many programs using software serial (or a second hardware serial port on a Mega) for the second device.
In most cases it is best to wait until the program code is downloaded before you connect your other device otherwise the presence of that device while downloading could affect the signal levels and cause a faulty download.
Don
floresta:
Nick is experienced with Bluetooth devices so if he says you can implement the serial monitor along with a Bluetooth module I guess you can.
Yes, but "implement" is a bit fast and loose. It is really only for looking at what is going on somewhere else - not for doing, and doesn't have great value other than as an initial check.
I suspect that sending information from the Arduino to more than one serial device isn't a big problem which is why it would work for troubleshooting as you suggest.
Receiving information from more than one serial device is a different story.
Don