This article is about Interfacing CC3000 Wifi Shield with Arduino UNO or Mega 2560.
Adafruit’s CC3000 Wifi Shield and TonyLabs CC3000 wifi shield are compatible with each other, the code used for Adafruit’s wifi shield can also work with TonyLabs CC3000 Wifi Shield. Hence we can use Adafruit’s cc3000 Wifi shield library to work with TonyLabs CC3000 Wifi shield.
Power Issue:
One issue that was being faced by me, while I was uploading any example from the library, that Arduino output stops when it is searching for available Access Points (AP). See the output below:
1 2 3 4 5 6 7 8 9 10 |
Hello, CC3000! RX Buffer : 131 bytes TX Buffer : 131 bytes Free RAM: 6836 Initialising the CC3000 ... Firmware V. : 1.24 MAC Address : 0x00 0x19 0x94 0x47 0xD6 0x85 Started AP/SSID scan |
The code stops here and does nothing.
The same problem was faced by other peoples on Adafruit’s wifi shield, when they were interfaccing CC3000 Wifi Shield with Arduino. This was all due to low power, Wifi shield needs more power when it is searching and connecting to any wifi, or any communication between AP and cc3000 shield needs more power, hence using external supply can solve this problem.
Check this connection, without any external supply, just with USB supply from Computer.
![]() |
![]() |
The output at USB Supply:
Solution:
Now connecting External Supply voltage:
![]() |
![]() |
The supply voltage from external power supply is: 5.43 volts as a random voltage more than 5 volts, to provide sufficient current to shield. The current drawn by shield is 0.12A, which increases when searching for wifi Access Points up to 0.31 Amperes and voltage drops to 5.
30v due to load, this might be not the same in your case due to different power supplies.
The supply voltage is given to Vin and GND pins of Wifi Shield (same pins as Arduino):
With External supply now the output is:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
/*************************************************** This is an example for the Adafruit CC3000 Wifi Breakout & ShieldDesigned specifically to work with the Adafruit WiFi products: ----> https://www.adafruit.com/products/1469Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Kevin Townsend & Limor Fried for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ /* This example does a full test of core connectivity: * Initialization * SSID Scan * AP connection * DHCP printout * DNS lookup * Ping * Disconnect It's a good idea to run this sketch when first setting up the module. */ #include <Adafruit_CC3000.h> #include <ccspi.h> #include <SPI.h> #include <string.h> #include "utility/debug.h" // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed but DI #define WLAN_SSID "TP-LINK_MEMON" // cannot be longer than 32 characters! #define WLAN_PASS "autoscan" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 /**************************************************************************/ /*! @brief Sets up the HW and the CC3000 module (called automatically on startup) */ /**************************************************************************/ void setup(void) { Serial.begin(115200); Serial.println(F("Hello, CC3000!\n")); displayDriverMode(); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println(F("\nInitialising the CC3000 ...")); if (!cc3000.begin()) { Serial.println(F("Unable to initialise the CC3000! Check your wiring?")); while(1); } /* Optional: Update the Mac Address to a known value */ /* uint8_t macAddress[6] = { 0x08, 0x00, 0x28, 0x01, 0x79, 0xB7 }; if (!cc3000.setMacAddress(macAddress)) { Serial.println(F("Failed trying to update the MAC address")); while(1); } */ uint16_t firmware = checkFirmwareVersion(); if ((firmware != 0x113) && (firmware != 0x118)) { Serial.println(F("Wrong firmware version!")); for(;;); } displayMACAddress(); /* Optional: Get the SSID list (not available in 'tiny' mode) */ #ifndef CC3000_TINY_DRIVER listSSIDResults(); #endif /* Delete any old connection data on the module */ Serial.println(F("\nDeleting old connection profiles")); if (!cc3000.deleteProfiles()) { Serial.println(F("Failed!")); while(1); } /* Attempt to connect to an access point */ char *ssid = WLAN_SSID; /* Max 32 chars */ Serial.print(F("\nAttempting to connect to ")); Serial.println(ssid); /* NOTE: Secure connections are not available in 'Tiny' mode! */ if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { // if (!cc3000.connectSecure(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println(F("Failed!")); while(1); } Serial.println(F("Connected!")); /* Wait for DHCP to complete */ Serial.println(F("Request DHCP")); while (!cc3000.checkDHCP()) { delay(100); // ToDo: Insert a DHCP timeout! } /* Display the IP address DNS, Gateway, etc. */ while (! displayConnectionDetails()) { delay(1000); } #ifndef CC3000_TINY_DRIVER /* Try looking up www.adafruit.com */ uint32_t ip = 0; Serial.print(F("www.adafruit.com -> ")); while (ip == 0) { if (! cc3000.getHostByName("www.adafruit.com", &ip)) { Serial.println(F("Couldn't resolve!")); } delay(500); } cc3000.printIPdotsRev(ip); /* Do a quick ping test on adafruit.com */ Serial.print(F("\n\rPinging ")); cc3000.printIPdotsRev(ip); Serial.print("..."); uint8_t replies = cc3000.ping(ip, 5); Serial.print(replies); Serial.println(F(" replies")); if (replies) Serial.println(F("Ping successful!")); #endif /* You need to make sure to clean up after yourself or the CC3000 can freak out */ /* the next time you try to connect ... */ Serial.println(F("\n\nClosing the connection")); cc3000.disconnect(); } void loop(void) { delay(1000); } /**************************************************************************/ /*! @brief Displays the driver mode (tiny of normal), and the buffer size if tiny mode is not being used @note The buffer size and driver mode are defined in cc3000_common.h */ /**************************************************************************/ void displayDriverMode(void) { #ifdef CC3000_TINY_DRIVER Serial.println(F("CC3000 is configure in 'Tiny' mode")); #else Serial.print(F("RX Buffer : ")); Serial.print(CC3000_RX_BUFFER_SIZE); Serial.println(F(" bytes")); Serial.print(F("TX Buffer : ")); Serial.print(CC3000_TX_BUFFER_SIZE); Serial.println(F(" bytes")); #endif } /**************************************************************************/ /*! @brief Tries to read the CC3000's internal firmware patch ID */ /**************************************************************************/ uint16_t checkFirmwareVersion(void) { uint8_t major, minor; uint16_t version; #ifndef CC3000_TINY_DRIVER if(!cc3000.getFirmwareVersion(&major, &minor)) { Serial.println(F("Unable to retrieve the firmware version!\r\n")); version = 0; } else { Serial.print(F("Firmware V. : ")); Serial.print(major); Serial.print(F(".")); Serial.println(minor); version = major; version <<= 8; version |= minor; } #endif return version; } /**************************************************************************/ /*! @brief Tries to read the 6-byte MAC address of the CC3000 module */ /**************************************************************************/ void displayMACAddress(void) { uint8_t macAddress[6]; if(!cc3000.getMacAddress(macAddress)) { Serial.println(F("Unable to retrieve MAC Address!\r\n")); } else { Serial.print(F("MAC Address : ")); cc3000.printHex((byte*)&macAddress, 6); } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ 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; } } /**************************************************************************/ /*! @brief Begins an SSID scan and prints out all the visible networks */ /**************************************************************************/ void listSSIDResults(void) { uint8_t valid, rssi, sec, index; char ssidname[33]; index = cc3000.startSSIDscan(); Serial.print(F("Networks found: ")); Serial.println(index); Serial.println(F("================================================")); while (index) { index--; valid = cc3000.getNextSSID(&rssi, &sec, ssidname); Serial.print(F("SSID Name : ")); Serial.print(ssidname); Serial.println(); Serial.print(F("RSSI : ")); Serial.println(rssi); Serial.print(F("Security Mode: ")); Serial.println(sec); Serial.println(); } Serial.println(F("================================================")); cc3000.stopSSIDscan(); } |
In the code above (same as Buidtest example in library), you just have to change the SSID, Password and Security type of AP (to which you want to connect to), see fig below:
Attachments:
– Download Adafruit’s CC3000 Wifi Shield Library for Arduino
Possible Errors:
When Interfacing CC3000 Wifi Shield with Arduino, users might get half the letters on Serial, not the complete message then the serial buffer is full probably, to increase buffer size, check this tutorial:
.
For years we #39;ve seen all sorts of microcontroller-friendly WiFi modules but none of them were really Adafruit-worthy.
For years we #39;ve seen all sorts of microcontroller-friendly WiFi modules but none of them were really Adafruit-worthy.