Adafruit Cc3000 Wifi
Adafruit Cc3000 Wifi
Adafruit Cc3000 Wifi
Guide Contents 2
Overview 4
Assembly and Wiring 6
CC3000 Breakout 7
Assembly 7
Wiring 8
CC3000 Shield 12
Assembly 12
Connections 18
Pinouts 18
Optional Antenna 18
Using the CC3000 19
Download the Library 19
Sample Sketches 19
WEP with HEX Passphrases 19
buildtest 21
buildtest 21
WebClient 23
WebClient 23
ntpTest 25
ntpTest 25
InternetTime 27
InternetTime 27
GeoLocation 29
GeoLocation 29
SmartConfig 31
SmartConfigCreate and SmartConfigReconnect 31
SmartConfigCreate 31
SmartConfigReconnect 31
Using the SmartConfigCreate Sketch 31
Step One: Install the SmartConfig App 31
Step Two: Configure the SmartConfig App on your Phone 32
Step Three: Open and Run 'SmartConfigCreate' 33
The CC3000 WiFi module from Texas Instruments is a small silver package which finally brings easy-to-use,
affordable WiFi functionality to your Arduino projects.
It uses SPI for communication (not UART!) so you can push data as fast as you want or as slow as you want.
It has a proper interrupt system with IRQ pin so you can have asynchronous connections. It supports
802.11b/g, open/WEP/WPA/WPA2 security, TKIP & AES. A built in TCP/IP stack with a "BSD socket"
interface supports TCP and UDP in both client and server mode, with up to 4 concurrent socket connections.
The CC3000 does not support "AP" mode, it can connect to an access point but it cannot be an access point.
The CC3000 is available from Adafruit As a Breakout Board, and as an Arduino Shield.
Both the shield and the breakout board have an onboard 3.3V regulator that can handle the 350mA peak
current, and a level shifter to allow 3 or 5V logic level. The antenna layout is identical to TI's suggested layout
and we're using the same components, trace arrangement, and antenna so the board maintains its FCC
emitter compliance (you'll still need to perform FCC validation for a finished product, but the WiFi part is taken
care of). Even though it's got an onboard antenna we were pretty surprised at the range, as good as a
smartphone's.
Check out the next couple of pages for detailed instructions for setting up your CC3000 shield or breakout
board!
Assembly
The CC3000 breakout board ships with a strip of header pins. Snip off a 9-pin section and solder it to the 9
holes on the side of the board.
The easiest way to do this is to first insert the header pins into a breadboard, to hold them securely while you
solder.
Wiring
Use jumper wires to attach the CC3000 breakout board to your arduino:
CLK to Digital 13
MISO to Digital 12
MOSI to Digital 11
CS to Digital 10
If you're using a Mega, you'll need to connect to the hardware SPI pins:
CLK to Digital 52
MISO to Digital 50
MOSI to Digital 51
CS to Digital 10
If you're using an Arduino Due, you'll need to connect to the hardware SPI pins. See theexcellent diagram in
this forum post (http://adafru.it/dVz) if you aren't sure where the hardware SPI pins are located on the Due.
3.3v is an output from the breakout board's voltage regulator - we won't be connecting anything to it in this
tutorial.
Break off 6, 8, or 10-pin sections and insert them into the header sockets of your Arduino
By default, SPI through the ICSP header is not connected. To enable the ICSP header connections, you'll
have to connect three solder jumpers on the bottom of the CC3000 shield.
Soldering these jumpers is required if you are using the shield with a Mega, Leonardo, or Due, but is not
required for use with an UNO!
Simply melt a blob of solder, connecting the pads, on each of the three solder jumpers (keep your solder
inside the white boxes - don't let the solder cross between boxes!)
The CC3000 is (electrically) fairly simple to use. The module requires an SPI connection, including a clock
(CLK), data in from a microcontroller (MOSI) and data out to the microcontroller (MISO). It also uses a chip-
select line (CS) for SPI to indicate when a data transfer as started
Along with the SPI interface, there is a power-enable type pin calledVBAT_EN which we use to start the
module properly and also an IRQ pin, which is the interrupt from the CC3000. The IRQ pin is required to
communicate and must be tied to an interrupt-in pin on the Arduino. On the Mega/UNO, we suggest #2 or #3
SCK - #13
MISO #12
MOSI #11
CS for CC3000 #10
VBAT_EN #5
CS for SD Card #4
IRQ #3
On the breakout, be aware that the MISO (data out from module) pin does not go 'high impedance' when CS
is driven high. Check the shield for how we use a 74AHC125 to manually tri-state this pin when it's shared
with an SD card.
Optional Antenna
If you have a shield or breakout with a uFL connector (instead of an on-board ceramic antenna) you can use a
uFL to RP-SMA (http://adafru.it/852) or uFL to SMA (http://adafru.it/851) (less common) adapter and then
connect to any 2.4 GHz antenna (http://adafru.it/945). This is handy when you want to place the module in a
box but have the antenna on the outside, or when you need a signal boost
Please note that when using an external antenna, the module is no longer FCC-compliant, so if you want to
sell the product with FCC certification, it must be retested.
You can download the latest ZIP file by clicking the button below.
Download the latest Adafruit_CC3000 library
http://adafru.it/cHe
Rename the uncompressed folder Adafruit_CC3000. Check that the Adafruit_CC3000 folder contains
Adafruit_CC3000.cpp and Adafruit_CC3000.h; also ccspi.cpp, ccspi.h, an examples folder, and a utility
folder
Place the Adafruit_CC3000 library folder your sketchbookfolder/libraries/ folder. You may need to create
the libraries subfolder if its your first library. Restart the IDE. You can figure out your sketchbookfolder by
opening up the Preferences tab in the Arduino IDE.
If you're not familiar with installing Arduino libraries, please visit our tutorial: All About Arduino
Libraries (http://adafru.it/aYM)!
Sample Sketches
The Adafruit CC3000 Library contains several example sketches, demonstrating different capabilities of the
CC3000 along with some useful programming techniques.
To run the sample sketches, you'll have to edit them to include the SSID and password of your access point.
#define WLAN_SSID "myNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "myPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
Remember to append 0x00 to the declaration, after the passphrase, as shown in the example!
Be aware the library does not currently support WEP passphrases with 0x00 null characters! See this bug for
more details: https://github.com/adafruit/Adafruit_CC3000_Library/issues/97
Initialization
SSID Scan
Access Point connection
DHCP address assignment
DNS lookup of www.adafruit.com (http://adafru.it/aK0)
Ping www.adafruit.com (http://adafru.it/aK0)
Disconnect
It's a good idea to run this sketch when first setting up the module. It will let you know that everything
is working correctly.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Here's a sample of the Serial Monitor output of buildtest. You should see something similar:
Hello, CC3000!
Networks found: 3
================================================
SSID Name : Extreme
RSSI : 58
Security Mode: 3
================================================
IP Addr: 192.168.1.23
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.1
DNSserv: 192.168.1.1
www.adafruit.com -> 207.58.139.247
Make sure you can see and recognize all of the access points around, connect to the access point, get a
good connection with DHCP, can do a DNS lookup on www.adafruit.com (http://adafru.it/aK0) and ping it
successfully. If all this works, then your hardware is known good!
Initialization
Optional SSID Scan (uncomment code section to enable)
Access Point connection
DHCP address assignment
DNS lookup of www.adafruit.com (http://adafru.it/aK0)
Optional Ping of www.adafruit.com (http://adafru.it/aK0) (uncomment code section to enable)
Connect to website and print out webpage contents
Disconnect
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of WebClient. You should see something similar:
Hello, CC3000!
Initializing...
Started AP/SSID scan
IP Addr: 192.168.1.23
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.1
DNSserv: 192.168.1.1
www.adafruit.com -> 207.58.139.247
Connect to 207.58.139.247:80
-------------------------------------
HTTP/1.1 200 OK
Disconnecting
Once you get this working, you can change the webpage you want to access to any kind of webpage on the
Internet
Initialization
SSID Scan
Access Point connection
DHCP address assignment
SNTP time synchronization
Extract and print current time and date
The sntp client performs a time synchronization with servers from us.pool.ntp.org and pool.ntp.org. You can
also optionally provide it the addresses of one or two of your own time servers. The ntpTest sketch tries
time.nist.gov first, before falling back to one of the pool servers.
The client also breaks out the synchronized network time into a structure containing current date and time
fields. The sketch formats and prints this information to the Serial Monitor.
To avoid unnecessary loading of NTP servers, please perform the time synchronization as infrequently as
possible. Once per day or longer should be plenty to maintain reasonably accurate time.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of ntpTest. You should see something similar:
Hello, CC3000!
The sketch then uses the Arduino's internal timer to keep relative time. The clock is re-synchronized roughly
once per day. This minimizes NTP server misuse/abuse.
The RTClib library (a separate download, and not used here) contains functions to convert UNIX time to other
formats if needed.
To avoid unnecessary loading of NTP servers, please perform the time synchronization as infrequently as
possible. Once per day or longer should be plenty to maintain reasonably accurate time.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of InternetTime. You should see something similar:
Hello, CC3000!
IP Addr: 192.168.1.23
Netmask: 255.255.255.0
Gateway: 192.168.1.1
DHCPsrv: 192.168.1.1
DNSserv: 192.168.1.1
Locating time server...
Combined with code in the ntpTest or InternetTime sketches, this can give absolute position and time,
extremely useful for seasonal calculations like sun position, insolation, day length, etc. One could always add
a GPS module or just plug in values from your GPS or phone, but for applications where extreme accuracy
isn't required, this has the luxury of coming 'free' with the CC3000 already in use.
Positional accuracy depends on the freegeoip.net database, in turn based on data collected by maxmind.com.
No guarantees this will work for every location. This software is provided as-is.
Position should be polled only once, at startup, or very infrequently if making a mobile network-hopping thing,
so as not to overwhelm the kindly-provided free geolocation service.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of GeoLocation. You should see something similar:
Hello, CC3000!
Free RAM: 837
Initializing...OK.
Connecting to network...Started AP/SSID scan
IP Addr: 192.168.0.4
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 192.168.0.1
Disconnecting
RESULTS:
Country: United States
SmartConfigCreate
This sketch will initialise the CC3000, erasing any previous connection details stored on the device. It will
then enter SmartConfig mode with a 60 second timeout where it waits for configuration data to arrive from the
SmartPhone.
If a connection was successfully established, the connection details will be stored in the non-volatile memory
of the CC3000, and the module will be configured to automatically reconnect to this network on startup
(meaning you don't need to run the SmartConfig app unless your AP details change or you erase the stored
connection details on the module).
There's no need to edit the sketch to add your SSID and password - the SmartConfig app does that for you!
SmartConfigReconnect
This sketch shows how to use the CC3000 in 'reconnect' mode, and avoid erasing all stored connection
profiles, which is unfortunately necessary with other sketches where manual config data is provided.
Initializates the CC3000 with a special SmartConfig flag so it doesn't erase the profile data
Access Point connection (based on saved AP details)
DHCP address assignment
Disconnect
For iOS devices simply search for the TI WiFi SmartConfig app (http://adafru.it/cQ3) from the app store.
You should see a screen similar to the following, with the AP'sSSID, Gateway IP Address and Device Name
fields already populated:
This tutorial will use an iPad to provide the SmartConfig details, but the process is basically the same on
Android.
IP Addr: 192.168.0.103
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 192.168.0.1
The first flag should always be false, and is used to indicate that we are going to perform a firmware update.
The second flag should always be true when using SmartConfig data, and puts the CC3000 in an auto-
reconnect mode and maintains existing connection details in non-volatile memory.
Requesting DHCP
IP Addr: 192.168.0.103
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 192.168.0.1
Any time you don't provide the extra flags to the .begin method, all connection details will be erased and auto-
reconnect mode will be disabled! Unfortunately, this is necessary when providing manual connection details,
so be careful using non SmartConfig* sketches if you don't want to lose your connection details.
SendTweet
This example sketch sends “tweets” (Twitter messages) from an Arduino with CC3000 WiFi. Usually this
requires extra proxy software running on another computer, but this sketch operates directly from the
Arduino.
This is a barebones example that issues a single fixed message, but it’s easily adapted to send different
information such as a periodic sensor reading.
In addition to the WiFi setup explained below, it’s necessary to set up a Twitter developer account and
complete an application form before this can be used. That procedure is explained on the Twitter Setup
page of the Internet of Things Printer tutorial (http://adafru.it/cHs).
One additional configuration step is required on the Twitter developer site:from your applications
“Settings” tab, set access to “Read and Write.” This is necessary so our sketch can send tweets; the printer
sketch only reads tweets.
Before you run the sketch, edit it to replace the dummy SSID and password with your own:
#define WLAN_SSID "yourNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "yourPassword"
Also, make sure that the right wireless security scheme is selected (unsecured, WEP, WPA, or WPA2)
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
Here's a sample of the Serial Monitor output of SendTweet. You should see something similar:
Hello! Initializing CC3000...Firmware V. : 1.19
OK
Deleting old connection profiles...OK
Connecting to network...Started AP/SSID scan
Connect to 199.59.150.9:80
OK
Issuing HTTP request...OK
Awaiting response...success!
Waiting ~1 hour...
Version 1.12 - This is a minor bug fix release withrelease notes here (http://adafru.it/dVA).
The 1.12 and earlier firmware versions are known to have problems with heavy load and certain
network conditions which can cause the CC3000 to lock up. Consider upgrading to the more
recent 1.13 release if you run into stability issues.
Version 1.13 - This is another bug fix release withrelease notes here (http://adafru.it/dVA).
The 1.13 release has a fix for internal CC3000 issues which cause lock ups under heavy usage
and certain network conditions. However note that the 1.13 release also appears to have bugs
with UDP traffic (http://adafru.it/dVB). Most internet traffic uses TCP instead of UDP so you likely
won't run into problems and should consider upgrading to the latest 1.13 firmware.
Version 1.14 - This is a bug fix release withrelease notes here (http://adafru.it/dVA).
Do not power your Arduino & CC3000 from a computer/laptop USB port during a firmware upgrade! You
MUST use an external power supply with at least 1 amp of current capacity. This is to ensure the Arduino and
CC3000 have enough power to operate during the firmware upgrade.
Make sure to run firmware updates using Arduino IDE version 1.0.6 and NOT the later beta versions 1.5.7,
1.5.8, or 1.6. The newer toolchain in the beta versions causes problems with the firmware update process.
To upgrade to a specific version first make sure you have the most recentAdafruit CC3000 Arduino
library (http://adafru.it/cFn) installed. If you installed the CC3000 library some time ago make sure to
download and install it again as fixes and new firmware versions are added periodically.
Next make sure your CC3000 is wired to your Arduino and can successfully run CC3000 sketches like
buildtest. If there's a problem communicating with the CC3000 you want to find out before your start the
firmware upgrade. Also be sure you're using a good quality 1 amp or more external power supply and
not a computer/laptop USB port to power the Arduino & CC3000!
Now in the Arduino IDE load one of thedriverpatch_X_XX CC3000 examples, where X_XX is the version
like driverpatch_1_13 for version 1.13. Adjust any of the pins to communicate with your Arduino just like you
would to run buildtest. Compile and load the sketch on your Arduino.
Open the serial monitor at 115200 baud and you should see a message such as a the following (try pressing
the Arduino's reset button if you see no message):
Note: The version number displayed during the firmware upgrade and from sketches like buildtest includes
the major, minor, and patch numbers so it doesn't exactly match the version number from TI. Here's a handy
conversion between reported version number and CC3000 firmware version:
List of wifi access points used to test the CC3000 (by TI, not verified by Adafruit)(http://adafru.it/rxe)
Using an Apple Airport? Check this thread for details on how to set it up for use with the
CC3000 (http://adafru.it/rxf)
Schematic for the CC3000 breakout board v1.0 (no buffer on the MISO pin)
Inches:
If your passphrase is a series of HEX digits, you can't simply enter it as a literal string. Instead you have to
define is as an actual binary sequence.
For example, if your passphrase is 8899aabbccdd, you would define it as follows (note the 0x00 at the end!
It's important!):
I'm using WEP and I tried that but it still doesn't work
Make sure you have WLAN_SECURITY defined as WEP:
What is the gain of the ceramic antenna? How does it compare to the external antennas?
We use the Johannson 2500AT44M0400 (http://adafru.it/cVL) which has 0.5 dBi gain. Compare this to the
external antennas with 2 dBi and 5dBi. Since antenna 'range' is not linear with the gain and antenna range
has a lot to do with what else is transmitting or receiving, physical barriers, noise, etc. We can roughly say that
the ceramic antenna has half the range of the 2dBi antenna, and the 5dBi antenna has double the range of
the 2dBi antenna (roughly!)
There is no way to know the actual range you will get unless you experiment with your setup since there is so
many variables, but the ceramic antenna gets about the same range we expect with an every day cellphone
(http://adafru.it/cVL)
How can I use the CC3000 with a static IP?
WiFi device IPs are dynamic 99% of the time, but it is possible to assign a static IP if your router permits it.
Check out this forum post for how to go about it(http://adafru.it/doW)
The CC3000 only operates on channels 1 through 11. Outside of the United States, you may be able to
configure your router to a channel number outside of that range. Make sure your router is configured for a
channel in the range 1 through 11.
A lockup during initialization is a very common issue when there isn't enough power to supply both the
Arduino and CC3000 board. Make sure you're powering the Arduino from a 1 amp or higher rated external
power supply. Don't try to power the Arduino from a computer/laptop USB port because those ports
typically can't provide enough power and will cause lockups!
Also if your Arduino supports changing the voltage of the digital I/O pins (like some 3rd party Arduino clones),
make sure the voltage is set to 5 volts and not 3.3 volts.
My CC3000 sketch locks up after running for a while or under heavy load...
Unfortunately there is a well known internal issue with the CC3000 which can cause lock ups and instability
over time or under heavy load. This thread on the Spark Core forums (http://adafru.it/dVC) dives deeply into
the issue and investigation with Texas Instruments. Ultimately the latest firmware version 1.13 was released
with a potential fix for the stability problems. If you'd like to upgrade to firmware version 1.13 see the page on
firmware upgrades in this guide (http://adafru.it/kA7).
By default the CC3000 is configured to get an IP address automatically from your router using DHCP. In
most cases this works well, however if you run into trouble getting an IP address or DNS server you should
consider setting a static IP address and DNS server.
To set a static IP address make sure you have the latest version of the CC3000 library and load the buildtest
example. Scroll down to the commented section of code in the setup function which discusses setting a static
IP address:
/*
uint32_t ipAddress = cc3000.IP2U32(192, 168, 1, 19);
uint32_t netMask = cc3000.IP2U32(255, 255, 255, 0);
uint32_t defaultGateway = cc3000.IP2U32(192, 168, 1, 1);
uint32_t dns = cc3000.IP2U32(8, 8, 4, 4);
if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
Serial.println(F("Failed to set static IP!"));
while(1);
}
*/
Remove the /* and */ comment delineators and fill in the IP address, net mask, default gateway, and DNS
server values for your network. You might need to check your router's configuration page to find these details.
Run the buildtest sketch and the CC3000 should be configured to use the static IP address and configuration
you assigned. You can actually remove or comment out the IP assignment code because the CC3000 will
remember the configuration in its internal non-volatile storage.
If you'd ever like to enable DHCP again, load buildtest and uncomment the section below the static IP
address configuration:
/*
if (!cc3000.setDHCP()) {
Serial.println(F("Failed to set DHCP!"));
while(1);
}
*/
Unfortunately these networks are difficult or sometimes impossible for the CC3000 to connect to because
they require using a web browser to authenticate with the network. However a couple options to pursue are:
Try contacting the network support team / administrator and see if they can allow the CC3000 onto the
network based on its MAC address. When you run the buildtest sketch it will print out the CC3000 MAC
address so you can copy it from there. This option is the easiest and most reliable way to get onto the
network, but might not be available depending on the network's policies.
The second option is to clone the MAC address of a laptop or device you've gotten on the network
already. For this you'll want to find the MAC address of the laptop/computer (usually in network settings,
search online to get a direct answer depending on the OS you're using). Then uncomment and
adjust the commented code in the setup function of the buildtest example which sets the MAC address
of the CC3000. Fill in your laptop/computer's MAC address and run the sketch to have the CC3000 start
using the provided MAC addres. Unfortunately at this point you have to turn off the cloned
laptop/computer or at least disconnect it from the network because two devices with the same MAC
can't be on the network at the same time (they'll get confused and start seeing each other's traffic).
I'm using the IPAddress class or an example from the Ethernet library and it doesn't work, what's wrong?
The IPAddress class is not compatible with the IP addresses the CC3000 classes expect. However you can
switch to using the CC3000.IP2U32 function to generate an IP address. See this line in the buildtest
example (http://adafru.it/flI) for how to use this function, and what type to use to store the IP address (an
unsigned 32-bit integer). Unfortunately the Arduino compiler will try to convert an IPAddress into this type so
ethernet library code might compile, but when the code actually runs it will fail because the data is not in the
right order. Stick to using the IP2U32 function!