In this article we look at the CC3000 WiFi shield. We will use the aRest example for CC3000, and we will then use a web address to manipulate some LED's on and off.
Lets look at the CC3000 chip
The TI CC3000 module is a self-contained wireless network processor that simplifies the implementation of Internet connectivity. TI’s SimpleLink Wi-Fi solution minimizes the software requirements of the host microcontroller (MCU) and is thus the ideal solution for embedded applications using any low-cost and low-power MCU.
The TI CC3000 module reduces development time, lowers manufacturing costs, saves board space, eases certification, and minimizes the RF expertise required. This complete platform solution includes software drivers, sample applications, API guide, user documentation, and a world-class support community.
- Arduino Uno and Arduino Mega compatible
- Supports SD card sizes 2GB and 4GB
- Wireless network processor
-
- IEEE 802.11 b/g ( 2.4GHz)
- Embedded IPv4 TCP/IP stack
-
- Best-in-class radio performance
-
- TX power: +18.0 dBm at 11 Mbps, CCK
- RX sensitivity: –88 dBm, 8% PER, 11 Mbps
-
- Operating temperature: –20°C to 70°C
- SmartConfig technology enables simple Wi-Fi configuration using a smartphone, tablet or PC
Parts List
Schematic
We used a traffic light LED example connected to our CC3000 shield, something like this
Code
This example requires several libraries to be installed
https://github.com/marcoschwartz/aREST
https://github.com/adafruit/Adafruit_CC3000_Library
https://github.com/adafruit/CC3000_MDNS
[codesyntax lang=”cpp”]
// Import required libraries #include <Adafruit_CC3000.h> #include <SPI.h> #include <CC3000_MDNS.h> #include <aREST.h> #include <aREST_UI.h> #include <avr/wdt.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); // Create aREST UI instance aREST_UI rest = aREST_UI(); // Your WiFi SSID and password #define WLAN_SSID "iainhendry" #define WLAN_PASS "iain061271" #define WLAN_SECURITY WLAN_SEC_WPA2 // The port to listen for incoming TCP connections #define LISTEN_PORT 80 // Server instance Adafruit_CC3000_Server restServer(LISTEN_PORT); // DNS responder instance MDNSResponder mdns; void setup(void) { // Start Serial Serial.begin(115200); // Give name and ID to device rest.set_id("1"); rest.set_name("cc3000"); // 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(100); } Serial.println(); // Start multicast DNS responder if (!mdns.begin("arduino", cc3000)) { while(1); } // Start server restServer.begin(); Serial.println(F("Listening for connections...")); // Enable watchdog wdt_enable(WDTO_4S); } void loop() { // Handle any multicast DNS requests mdns.update(); // Handle REST calls Adafruit_CC3000_ClientRef client = restServer.available(); rest.handle(client); wdt_reset(); // Check connection, reset if connection is lost if(!cc3000.checkConnected()){while(1){}} wdt_reset(); }
[/codesyntax]
Testing
Open your favourite web browser
http://arduino.local/digital/7/1
You should see the following displayed in your browser and the LED should switch on
{"message": "Pin D7 set to 1", "id": "1", "name": "cc3000", "hardware": "arduino", "connected": true}
Now type in the following
http://arduino.local/digital/7/0
{"message": "Pin D7 set to 0", "id": "1", "name": "cc3000", "hardware": "arduino", "connected": true} You can repeat this for the other LEDs that you have connected to your CC3000 shield