Code Monkey home page Code Monkey logo

arduinocc3000's Introduction

This project is abandoned!

I've given up on the CC3000, it's just too buggy and problematic.

TI themselves say this on the CC3000 page:

TI recommends CC3200 & CC3100 for all new and existing embedded Wi-Fi & Internet of Things applications.

And they've removed references to the CC3000 on their SimpleLink WiFi page at http://www.ti.com/ww/en/simplelink_embedded_wi-fi/home.html

I'm going to leave these pages here so people searching the web for help don't find dead links, but I recommend you abandon your quest to make this half-baked module work. Best of luck to you.




ArduinoCC3000

Arduino library for the TI CC3000 WiFi module

Edit pin definitions etc. in ArduinoCC3000Core.h.

The .ino file demonstrates basic connectivity etc. For a full API reference download the TI documentation at:

http://processors.wiki.ti.com/index.php/CC3000

http://software-dl.ti.com/ecs/simplelink/cc3000/public/doxygen_API/v1.11/html/index.html

/***************************************************************************
****************************************************************************
*
*  ArduinoCC3000.ino - Initial version of the Arduino CC3000 library.
*
*  Version 1.0.1b
* 
*  Copyright (C) 2013 Chris Magagna - [email protected]
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*  Don't sue me if my code blows up your board and burns down your house
*
****************************************************************************
****************************************************************************

Changes in 1.0.1c:

1. Changed attachInterrupt() from FALLING to LOW to fix problem
	with the 328 class (Uno, Nano, etc.) from missing the Smart Config
	HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE event.


****************************************************************************

Changes in 1.0.1b:

1.	Remapped pins on the Teensy 3.0. Since hardware SPI isn't working
	there's no reason to waste those pins - any will work. New mapping:
	
		Teensy pin | CC3000 name | Name 
		
		D25 - SPI_CS - WLAN_CS
		D26 - SPI_DOUT - WLAN_MISO
		D27 - SPI_IRQ - WLAN_IRQ
		D28 - SPI_DIN - WLAN_MOSI
		D29 - SPI_CLK - WLAN_SCK
		D30 - VBAT_SW_EN - WLAN_EN
		
2. Changed serial input in loop to ignore newlines / returns

****************************************************************************

Changes in 1.0.1a:

1. Trying to isolate why Smart Config fails on a Nano.

	The Smart Config cycle is actually working; the profile gets saved to the
	CC3000 and everything is good, but the HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE
	event never gets sent to the async event handler so we never know it's done.
	My temporary workaround is to stop waiting after 30 seconds and hope for the
	best.

	If the Smart Config cycle worked then we'll connect and get an IP address
	like normal, if not we'll get stuck waiting to connect.

	This is sub-optimal but is the best solution I have for now.

****************************************************************************

Changes in 1.0.1:

1. Fixed bug in TI's security.h where they missed a closing "}" so I had 
added it at the end of wlan.cpp (thanks to Frank Vannieuwkerke and alvarolb)

2. Fixed documentation about using INPUT_PULLUP on a 5V system (thanks to
Joseph Malkom)

3. Started going through TI's code and rewriting their use of 'longs' 
everywhere to 'bytes' or 'ints' to save RAM.

4. Added functionality to the demo program ArduinoCC3000.ino to demonstrate
Smart Config, manually connecting, scanning for APs, etc.

5. Rewrote ArduinoCC3000Core.h to recognize Teensy 3.0 software SPI 
directly.

****************************************************************************


To connect an Arduino to the CC3000 you'll need to make these 6 connections
(in addition to the WiFi antenna, power etc).

Name / pin on CC3000 module / pin on CC3000EM board / purpose

SPI_CS     / 12 / J4-8 /  SPI Chip Select
                          The Arduino will set this pin LOW when it wants to 
                          exchange data with the CC3000. By convention this is
                          Arduino pin 10, but any pin can be used. In this
                          program it will be called WLAN_CS

SPI_DOUT   / 13 / J4-9 /  Data from the module to the Arduino
                          This is Arduino's MISO pin, and is how the CC3000
                          will get bytes to the Arduino. For most Arduinos
                          MISO is pin 12

SPI_IRQ    / 14 / J4-10 / CC3000 host notify
                          The CC3000 will drive this pin LOW to let the Arduino
                          know it's ready to send data. For a regular Arduino
                          (Uno, Nano, Leonardo) this will have to be connected
                          to pin 2 or 3 so you can use attachInterrupt(). In
                          this program it will be called WLAN_IRQ

SPI_DIN    / 15 / J4-11   Data from the Arduino to the CC3000
                          This is the Arduino's MOSI pin, and is how the Arduino
                          will get bytes to the CC3000. For most Arduinos
                          MOSI is pin 11

SPI_CLK    / 17 / J4-12   SPI clock
                          This is the Arduino's SCK pin. For most Arduinos
                          SCK is pin 13

VBAT_SW_EN / 26 / J5-5    Module enable
                          The Arduino will set this pin HIGH to turn the CC3000
                          on. Any pin can be used. In this program it will be
                          called WLAN_EN
                          
                          
WARNING #1: The CC3000 runs at 3.6V maximum so you can't run it from your
regular 5V Arduino power pin. Run it from 3.3V!


WARNING #2: When transmitting the CC3000 will use up to 275mA current. Most
Arduinos' 3.3V pins can only supply up to 50mA current, so you'll need a 
separate power supply for it (or a voltage regulator like the LD1117V33
connected to your Arduino's 5V power pin).


WARNING #3: The CC3000's IO pins are not 5V tolerant. If you're using a 5V
Arduino you will need a level shifter to convert these signals to 3.3V
so you don't blow up the module. 

You'll need to shift the pins for WLAN_CS, MOSI, SCK, and WLAN_EN. MISO can be
connected directly because it's an input pin for the Arduino and the Arduino
can read 3.3V signals directly. For WLAN_IRQ use a pullup resistor of 10K to
100K Ohm -- one leg to the Arduino input pin + CC3000 SPI_IRQ pin, the other
leg to +3.3V.

You can use a level shifter chip like the 74LVC245 or TXB0104 or you can use
a pair of resistors to make a voltage divider like this:

Arduino pin -----> 560 Ohm --+--> 1K Ohm -----> GND
                             |
                             |
                             +---> CC3000 pin

****************************************************************************/

arduinocc3000's People

Contributors

cmagagna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduinocc3000's Issues

Porting the TI PatchProgrammer?

Hi Chris,

I was wondering if you've made any strides toward porting the Patch Programmer to update the CC3000 firmware yet? I gave it a shot last night and it seemed to go through all the motions, but when all was said and done I could no longer read the firmware version out of the device... I posted to the TI forums here: http://e2e.ti.com/support/low_power_rf/f/851/t/288321.aspx.

Cheers,
Vic

P. S. If you prefer a different communication mechanism than Git-Hub issues, please let me know!

Peek() Function

Hi Chris,
Awesome work!
Really appreciate what you have done!
Is there a way to add a peek() function into the client code?
This seems to be necessary to make the email code I have found work.
The email sketch is shown below if you are curious. See eRecv()
Thanks again,

BitSetter.
------------------------------------ Email Sketch -----------------------------------

/*

  • Simple remote relay control with Arduino & the CC3000 chip
  • Part of the code is based on the work done by Adafruit on the CC3000 chip
  • Writtent by Marco Schwartz for Open Home Automation
    */

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_DIV2); // you can change this clock speed but DI

define WLAN_SSID "" // cannot be longer than 32 characters!

define WLAN_PASS ""

// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2

define WLAN_SECURITY WLAN_SEC_WPA2

const unsigned long
dhcpTimeout = 60L * 1000L, // Max time to wait for address from DHCP
connectTimeout = 15L * 1000L, // Max time to wait for server connection
responseTimeout = 15L * 1000L; // Max time to wait for data from server

const int relay_pin = 8; // Relay pin

char relayBuffer[1]; // Relay buffer

Adafruit_CC3000_Client client;

uint32_t t;

void setup() {

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)) {
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);
}

}

void loop()
{
byte inChar;

inChar = Serial.read();

if(inChar == 'e')
{
if(sendEmail()) Serial.println(F("Email sent"));
else Serial.println(F("Email failed"));
}
}

byte sendEmail()
{
byte thisByte = 0;
byte respCode;
unsigned long ip, startTime, t = 0L;
// client = cc3000.connectTCP(server, 25);
// if(client.connected()) {
// Serial.println(F("connected"));
// } else {
// Serial.println(F("connection failed"));
// return 0;
// }

if(cc3000.getHostByName("smtp.frontier.net", &ip)) {

Serial.println(F("\r\nAttempting connection..."));
startTime = millis();
do {
  client = cc3000.connectTCP(ip, 123);
} while((!client.connected()) &&
        ((millis() - startTime) < connectTimeout));

}else{
return 0;
}

if(!eRcv()) return 0;
Serial.println(F("Sending helo"));

// change to your public ip
client.println(F("helo 1.2.3.4"));

if(!eRcv()) return 0;
Serial.println(F("Sending From"));

// change to your email address (sender)
client.println(F("MAIL From: [email protected]"));

if(!eRcv()) return 0;

// change to recipient address
Serial.println(F("Sending To"));
client.println(F("RCPT To: [email protected]"));

if(!eRcv()) return 0;

Serial.println(F("Sending DATA"));
client.println(F("DATA"));

if(!eRcv()) return 0;

Serial.println(F("Sending email"));

// change to recipient address
client.println(F("To: You [email protected]"));

// change to your address
client.println(F("From: Me [email protected]"));

client.println(F("Subject: Arduino email test\r\n"));

client.println(F("This is from my Arduino!"));

client.println(F("."));

if(!eRcv()) return 0;

Serial.println(F("Sending QUIT"));
client.println(F("QUIT"));

if(!eRcv()) return 0;

client.close();

Serial.println(F("disconnected"));

return 1;
}

byte eRcv()
{
byte respCode;
byte thisByte;
int loopCount = 0;

//wait until data arrives
while(!client.available()) {
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
  client.close();
  Serial.println(F("\r\nTimeout"));
  return 0;
}

}

respCode = client.peek();

//read until buffer empty:
while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

if(respCode >= '4')
{
efail();
return 0;
}

return 1;
}

void efail()
{
byte thisByte = 0;
int loopCount = 0;

client.println(F("QUIT"));

while(!client.available()) {
delay(1);
loopCount++;

// if nothing received for 10 seconds, timeout
if(loopCount > 10000) {
  client.stop();
  Serial.println(F("\r\nTimeout"));
  return;
}

}

while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}

client.stop();

Serial.println(F("disconnected"));
}

/*************************************************************************/
/
!
@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();
}

Stuck at Initialization

Chris, I seem to be stuck on the initialization of the CC3000 both using your library and the Adafruit version..

Mine is the Breakout board from Adafruit and I am using the Arduino Nano V3, the one with the Atmega 328p. Any thoughts?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.