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!
