Is there a way for a 9V powered Arduino access the serial monitor?

I understand that when the Arduino is connected to my PC, it is connected to COM3, and it can open the serial monitor.

However when it is powered by a 9v battery running the same program, the serial monitor wont open and says "Board at COM3 is not available". Is there a way to allow my program print to the serial monitor even while the Arduino is powered by just a 9V battery?

What type of Arduino? (It can make a difference)

Can we assume you have cables connected to both the usb and barrel socket or Vin pin at the same time?

difficult to avoid being powered by the PC is connected to it via a USB port.

but you can connect the Arduino serial interface to a PC thru an rs-232 or rs-485 usb adaptor

I made an adaptor for my Nano. It consisted of a mini usb male to mini usb female (The same usb as fitted to the Nano). The +5v line from the PC was fixed to a two way switch. Also connected to the two way switch was a terminal for an external +5 voltage.
I hope this is the bottom line: It enables me to use an external voltage and use of the terminal monitor at the same time.

What kind of Nano would that be? Is there no 5V or Vin pin your can supply power to?

It's a nano clone, basic like me!
The idea was; If I'm running the nano off an external supply, that maybe isn't as smooth as the PC's usb supply, I can monitor the output of the 'real world' as applied to the current sketch or project. Just for my own benefit.

I have an Arduino UNO.

I have an arduino uno

Is there a way to do this for UNO or does it have to be a nano? Also is there a way to extend the 5v pins on the UNO to create a strip of 5v pins? Also could you provide more info on the schematic of this adaptor and the two way switch?

So are you saying that if I buy a SparkFun USB to RS-485 Converter and connect it to my arduino instead of my pc then I can access the serial monitor?

(getting back to the real matter, rather than what is probably an equally pointless diversion....)[quote="kaiswim1, post:1, topic:922167"]
Is there a way to allow my program print to the serial monitor even while the Arduino is powered by just a 9V battery?
[/quote]
You might elaborate with some cogent reason as to why you would want to do this, particularly if, by 9v battery, you mean a 9v PP3 battery, as this is about the worst possible choice you can make for powering a Uno. The kindest that that can be said about that is, if the laptop is not up to the job, a 9v battery is not a solution. In the world that is enjoyed by everybody else, your Uno is happy about being connected to more than one source of power, and simply takes whatever is most suitable, without any need for fartarsing about by the user. Indeed, since you had the monitor working before, the latter is probably the best explanation of the message "Board at COM3 not available"

you'll need a usb to rs-485 adaptor for your PC

I guess it would work for most types of Arduino, but I have not tried it. You would need to look at the schematic of the Arduino to know for sure. If the USB-serial chip is powered only by the 5V supply from the usb cable and cannot be powered from the 5V pin or the on-board regulator, then it would not work. But I would imagine that is probably not the way the USB-serial chip is powered.

Use the bus lines on a breadboard for that while you are prototyping your circuit. For the completed version of your circuit, if you are using strip board, you can solder many wires to the same strip. If you design a PCB you can do something similar. But this raises the question of why you need a strip of 5V pins? How much current will be drawn, and are you expecting a pp3 9V battery to power many devices through the Arduino's regulator?

when using with rs-232 or rs-485 on the Arduino, they are connected to the serial pins, 1 & 2. at least the receive pin needs to be disconnected when reprogramming thru usb.

it's easier to develop on the mega which has 4 serial interfaces, or you need to use Software Serial

The Nano has a Vin-pin (regulated) to which you can supply voltages up to 12V. You can also supply regulated 5V to the 5V-pin (unregulated) and power the Nano that way. I have no problems using the serial monitor even if an external power supply is attached to either of the mentioned pins.

Feeding power to Arduino

Okay, so I have achieved wireless communication with an Arduino which works with an HC-05 Bluetooth module. It can be powered with the 9v so it can run without being plugged into my computer. The next problem I wish to solve is allowing some kind of way to keep track of the commands I send to the Arduino all while maintaining the wireless communication. When it is just powered with a 9V, it can execute the commands I send it. However it can't open the serial monitor. And I am attempting to use the serial monitor to keep track of commands. This is the code.

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(3, 4); 

int i; 
void setup()
{  
   i=0;
   Serial.begin(9600); 
   Serial.print("Hello world.");
   BTSerial.begin(9600);
   pinMode(13, OUTPUT); // put your setup code here, to run once:
}


void loop()
{
   // put your main code here, to run repeatedly:

   if (BTSerial.available() > 0)
   {
      char data = BTSerial.read(); // reading the data received from the bluetooth module
      //Serial.println(data);
      switch (data)
      {
         case 'a': digitalWrite(13, HIGH); Serial.println("a "+String(i)); break; // when a is pressed on the app on your smart phone
         case 'd': digitalWrite(13, LOW); Serial.println("d "+String(i)); break; // when d is pressed on the app on your smart phone
         default : break;
      }
      //Serial.println(data);
      //Serial.flush();
   }
   delay(1); 
   i++;
}

How does this work? Does it plug into the PC and the A and B plug into the 1 and 2? Does this have to be connected to the PC to work?

an RS-485 chip/module wired to the Arduino power and serial Tx and Rx pins is connected with a pair of wires to a USB/RS-485 adaptor on the PC.

RS-485 uses a balanced pair connection, one wire driven to +5 and the other 0V and visa versa. they are labeled A/B. it may take some trial and error to find the A connection on the USB adaptor

I´m presuming by your code that you´ve achieved BT communication between Arduino and a mobile phone. In this case, wouldn´t be better to keep track of what Arduino is doing through this same mobile instead of Serial Monitor?