Home Code CC3000 WiFi shield mDNS and LED example

CC3000 WiFi shield mDNS and LED example

by shedboy71

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.


Features

  1. Arduino Uno and Arduino Mega  compatible
  2. Supports SD card sizes 2GB and 4GB
  3. Wireless network processor
    • IEEE 802.11 b/g ( 2.4GHz)
    • Embedded IPv4 TCP/IP stack
  4. Best-in-class radio performance
    • TX power: +18.0 dBm at 11 Mbps, CCK
    • RX sensitivity: –88 dBm, 8% PER, 11 Mbps
  5. Operating temperature: –20°C to 70°C
  6. SmartConfig technology enables simple Wi-Fi configuration using a smartphone, tablet or PC

Parts List

CC3000 WiFi Shield 1PCS CC3000 WiFi Shield for R3 With SD Card Supports MEGA2560
Arduino Mega 1pcs MEGA 2560 R3 ATmega2560 AVR USB board +free USB cable (ATMEGA2560 /CH340 ) funduino 2560
Dupont Wire 40PIN Dupont Line 10CM 20CM 30CM Male to Male + Female to Male and Female to Female Jumper Wire Dupont Cable for arduino DIY KIT
Traffic LED 5V Traffic Light LED Display Module for Arduino Red Yellow Green 5mm LED

Schematic

We used a traffic light LED example connected to our CC3000 shield, something like this

cc3000 and MDNS led example_bb

cc3000 and MDNS led example_bb

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
Share

You may also like

Leave a Comment