I have a tough issue in my project with CC3000 wifi chip and arduino uno R3 and a relay.
My project is called "Wireless Relay Control with Arduino & the CC3000 WiFi chip" which can be found on this website. https://openhomeautomation.net/wireless-relay-arduino-wifi/
I copy the CC3000_REST code and it compiles well. After clicking"Done uploading", I can see "Listening for connections..." in the serial monitor. However, I always get "{"variables": {}, "id": "", "name": "", "hardware": "arduino", "connected": true}" when typing 192.168.1.167/mode/6/o into my browser. From the book, I know that I supposed to get "Setting pin D6 to output".
Now I have no idea how to solve this problem. Please help me!
/*
This a simple sketch that uses the aREST library to implement
a REST API for Arduino (Uno/Mega/Due/Teensy) and the CC3000
WiFi chip. See the README file for more details.
Written in 2014 by Marco Schwartz under a GPL license.
*/
// Import required libraries
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <aREST.h>
// These are the pins for the CC3000 chip if you are using a breakout board
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
// Create CC3000 instance
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2);
// Your WiFi SSID and password
#define WLAN_SSID "UESTC-EDU"
#define WLAN_PASS "u1stc2015V2"
#define WLAN_SECURITY WLAN_SEC_WPA2
// The port to listen for incoming TCP connections
#define LISTEN_PORT 80
// Create aREST instance
aREST rest = aREST();
// Server instance
Adafruit_CC3000_Server restServer(LISTEN_PORT);
// DNS responder instance
MDNSResponder mdns;
void setup(void)
{
Serial.begin(115200);
// Set up CC3000 and get connected to the wireless network.
Serial.println(F("\nInitializing..."));
if (!cc3000.begin())
{
Serial.println(F("Couldn't begin()! Check your wiring?"));
while(1);
}
if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
Serial.println(F("Failed!"));
while(1);
}
while (!cc3000.checkDHCP())
{
delay(100);
}
Serial.println();
// 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;
}
}