Arduino Serial Monitor Issue

I am creating a wireless relay home automation project in accordance to the tutorial at https://www.openhomeautomation.net/wireless-relay-arduino-wifi/. However, I am having an issue with the serial monitor. The code should print out a wifi port value that you use to connect to the project wirelessly, however my project does not output anything to the serial monitor. I have tested the serial monitor using other simple projects and the serial monitor has worked for those projects. This leads me to believe that there is a fault in the code that I am missing.

Here is the code:
/*

  • Simple remote relay control with Arduino & the CC3000 chip
  • Part of the code is based on the work done by Adafruit on the CC3000 chip
  • Writtent by Marco Schwartz for Open Home Automation
    */

// Include required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <Ethernet.h>
#include <aREST.h>

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10

// WiFi network (change with your settings !)
#define WLAN_SSID "NETGEAR08-5G"
#define WLAN_PASS "fluffytomato870"
#define WLAN_SECURITY WLAN_SEC_WPA2

// The port to listen for incoming TCP connections
#define LISTEN_PORT 80

// Create CC3000 instances
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2);

// Server instance
Adafruit_CC3000_Server restServer(LISTEN_PORT);

// DNS responder instance
MDNSResponder mdns;

// Create aREST instance
aREST rest = aREST();

// Relay pin
const int relay_pin = 8;

void setup() {

// Initialize Serial
Serial.begin(115200);

// Set name & ID
rest.set_name("relay_control");
rest.set_id("1");

// Define relay pin as output
pinMode(relay_pin,OUTPUT);

// Set up CC3000 and get connected to the wireless network.
if (!cc3000.begin())
{
while(1);
}

if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
while(1);
}
while (!cc3000.checkDHCP())
{
delay(10000);
}

// Print CC3000 IP address
while (! displayConnectionDetails()) {
delay(1000);
}

// Start multicast DNS responder
if (!mdns.begin("arduino", cc3000)) {
while(1);
}

// Start server
restServer.begin();
Serial.println(F("Listening for connections..."));

}

void loop() {

// Handle any multicast DNS requests
mdns.update();

// Handle REST calls
Adafruit_CC3000_ClientRef client = restServer.available();
rest.handle(client);

}

// Print connection details of the CC3000 chip
bool displayConnectionDetails(void)
{
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
{
Serial.println(F("Unable to retrieve the IP Address!\r\n"));
return false;
}
else
{
Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
Serial.println();
return true;
}
}

Thanks for your help!

Do any of the prints in the setup() function show up in Serial monitor? There are several while(1) statements in setup(). Are you sure you aren't getting stuck in one of those?

First, thanks for the quick reply! Nothing shows up at all in the serial monitor. Also, how would I check if I am getting stuck in one of the while statements?

if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) 
{

   Serial.println(" I am stuck in connectToAP, drat");  // add a variation of this where ever it can get stuck

    while(1);
  }

// Set up CC3000 and get connected to the wireless network.
if (!cc3000.begin())
{
Serial.println(" I am stuck in begin, drat"); // add a variation of this where ever it can get stuck

while(1);
}

if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY))
Serial.println(" I am stuck in connectToAP, drat"); // add a variation of this where ever it can get stuck
{
while(1);
}
Serial.println(" I am stuck in checkDHCP, drat"); // add a variation of this where ever it can get stuck

while (!cc3000.checkDHCP())
{
delay(10000);
}
Serial.println(" I am stuck in print, drat"); // add a variation of this where ever it can get stuck

// Print CC3000 IP address
while (! displayConnectionDetails()) {
delay(1000);
}

Serial.println(" I am stuck in DNS, drat"); // add a variation of this where ever it can get stuck

// Start multicast DNS responder
if (!mdns.begin("arduino", cc3000)) {
while(1);
}

I've added this and there is still no output. Did I do it right?
Also, how do you add the scroll box to make the code easier to read?

  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY))
  Serial.println(" I am stuck in connectToAP, drat");  // add a variation of this where ever it can get stuck
{
    while(1);
  }

The above is wrong. The print statements must be inside the brackets (right above the while(1)

if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY))
{

Serial.println(" I am stuck in connectToAP, drat"); // add a variation of this where ever it can get stuck
while(1);

}

Check the baud rate in serial monitor to make sure it is 115200.

And please read the "how to use the forum" sticky to see how to properly post code in code tags (the </> tags). Properly indenting code makes it easier to read. Use the IDE auto format (CTRL T) format code.

Alright, I've already checked the baud rate and done some tests with different programs and baud rates t o make sure the serial monitor was working in the first place so that is not the issue. I have implemented the changes you brought up and still nothing is outputted.

 if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) 

{  Serial.println(" I am stuck in connectToAP, drat");  // add a variation of this where ever it can get stuck
    while(1);
  }

Could it be an issue with the print function? When I tested the serial monitor I used the write function, not print.

Serial.print() & Serial.println() to see it on the serial monitor.
Serial.write sends raw binary data, good for machine to machine transfer, not so good for screen viewing.

Let me clarify, I looked up a simple serial monitor program to test the serial connection. The program took input from the serial monitor input and copied it through the serial monitor. However, it did this using the write function rather than the print. So although I did test the serial monitor, it was with the write function, not the print that is used in the the program. I just wanted to make it clear that I am not 100% sure if the print function is working on my Arduino setup in general, not just with this program.

void setup()
{
 Serial.begin(115200);
  
}

void loop()
{
  Serial.println(" serial print works ");
  delay(1000);
}

This test code works on my Uno.

Can you post links to the shields and other hardware that you have connected and how your project is wired. If the above code doesn't print, there may be a hardware conflict.

Attached is a shot of Schwartz' schematic from his website. My own hardware follows his tutorial exactly but my photos were a little too big to attach to this website as is. If you really need them I can edit the photos and attach them.

Did you run the test code that I posted? Did any thing print?

Oh my mistake, I thought that was the same code you showed earlier. Yes I tested the code and it prints both with the hardware connected and detached. So now we know for sure that there is no issue with the serial connection on my project, correct?

That would be a valid assumption, I think. Put a Serial.print right after Serial.begin(115200).

void setup() {
  Serial.begin (115200);
  Serial.println("Serial port initialized");

That is outside of any decision making code so should print. If you don't see it right after upload, push the reset on the Arduino while watching serial monitor and see if it prints.

Alright, the serial monitor initialized DOES print. However nothing happens afterwards. None of your while loop test functions print anything at all.

Post your code as it is now, please.

Here's the code.

/* 
*  Simple remote relay control with Arduino & the CC3000 chip
*  Part of the code is based on the work done by Adafruit on the CC3000 chip
*  Writtent by Marco Schwartz for Open Home Automation
*/

// Include required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <Ethernet.h>
#include <aREST.h>

// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ   3
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10

// WiFi network (change with your settings !)
#define WLAN_SSID       "NETGEAR08-5G"
#define WLAN_PASS       "fluffytomato870"
#define WLAN_SECURITY   WLAN_SEC_WPA2

// The port to listen for incoming TCP connections 
#define LISTEN_PORT           80

// Create CC3000 instances
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIV2);                                                                         

// Server instance
Adafruit_CC3000_Server restServer(LISTEN_PORT);

// DNS responder instance
MDNSResponder mdns;

// Create aREST instance
aREST rest = aREST();

// Relay pin
const int relay_pin = 8; 

void setup() {
  
  // Initialize Serial 
  Serial.begin(115200);
   Serial.println("Serial port initialized");

  // Set name & ID
  rest.set_name("relay_control");
  rest.set_id("1");

  // Define relay pin as output
  pinMode(relay_pin,OUTPUT);
  
  // Set up CC3000 and get connected to the wireless network.
  if (!cc3000.begin())
  {
    Serial.println(" I am stuck in begin, drat");  // add a variation of this where ever it can get stuck

    while(1);
  }
  
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) 

{
    while(1);
  }
  Serial.println(" I am stuck in checkDHCP, drat");  // add a variation of this where ever it can get stuck

  while (!cc3000.checkDHCP())
  {
    delay(10000);
  }
Serial.println(" I am stuck in print, drat");  // add a variation of this where ever it can get stuck

  // Print CC3000 IP address
  while (! displayConnectionDetails()) {
    delay(1000);
  }
  
  Serial.println(" I am stuck in DNS, drat");  // add a variation of this where ever it can get stuck

  
  // Start multicast DNS responder
  if (!mdns.begin("arduino", cc3000)) {
    while(1); 
  }
   
  // Start server
  restServer.begin();
  Serial.println(F("Listening for connections..."));

}

void loop() {
  
  // Handle any multicast DNS requests
  mdns.update();
  
  // Handle REST calls
  Adafruit_CC3000_ClientRef client = restServer.available();
  rest.handle(client);

}

// Print connection details of the CC3000 chip
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

Unless it is stuck in the cc3000.begin, I don't know what else to try. I know nothing of that library so can't be of more help. My only suggestion, at this point, is to put a print before and after the cc3000.begin to see if it is going into that function and returning. Use prints, liberally, to follow program flow to find where it hangs. You can always delete them later.

Okay, I put a print before the c3000 function and that prints but the one within the function doesn't. Is it safe to assume that there is an issue with the c3000 function or the c3000 board itself?