Go Down

Topic: CC3000 was not declared in this scope (Read 633 times) previous topic - next topic


Jun 06, 2015, 11:50 pm Last Edit: Jun 06, 2015, 11:56 pm by gkraniske
Hello all:

First off, I don't know if I'm posting in the correct section, I looked at the descriptions and this one seemed to fit the best.  If I am wrong please accept my apology and maybe point me to the area I should be in.  If I am in the correct area then I have a problem.  I'm trying to build a home automation sketch using an Arduino Mega 2560, a CC3000 WIFI (stackable), and an eight channel relay board I got off of eBay.

I found some code on the Internet (https://www.openhomeautomation.net/wireless-relay-arduino-wifi) so I copied and modified it to suit my needs since I am brand new to coding and very poor to boot.  The problem is that I can't seem to get past this declaration problem to go away.  When I try to compile the sketch I get an error that says "CC3000 was not declared in this scope."  I Googled this and the results I found didn't help so I tried adding brackets where I thought they should go and when that didn't work, I tried adding a line before (and after) the void setup() statement that said "int CC3000" but all that did was break it worse.

Any help would be greatly appreciated.  If you are able to give me a solution please tell me where in the sketch it would go as well as the actual syntax (yes, I'm that bad, Lol).  Once again thank you for your help and I hope you have a great day!

Here's my code:

Code: [Select]

#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <CC3000_MDNS.h>
#include <Ethernet.h>
#include <aREST.h>
#include "DHT.h"
#define WLAN_SSID       "MySSID"       // cannot be longer than 32 characters!
#define WLAN_PASS       "MyPassWord!"
#define LISTEN_PORT 8092
//Adafruit_CC3000_Server restServer(LISTEN_PORT);
//MDNSResponder mdns;
//aREST rest = aREST();

void setup() {
  if (!mdns.begin("arduino", cc3000)) {



void loop() {
  // put your main code here, to run repeatedly:



Jun 07, 2015, 03:14 am Last Edit: Jun 07, 2015, 03:24 am by tammytam
I'd guess that you need this line above your setup():

Code: [Select]

Adafruit_CC3000 cc3000;

Ignore this, it is incorrect. See post below


Don't guess, look in the library - the constructor takes several pin numbers.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Indeed you are right, the constructor takes several pin numbers:

Adafruit_CC3000(uint8_t csPin, uint8_t irqPin, uint8_t vbatPin, uint8_t spispeed = SPI_CLOCK_DIVIDER, Print* cc3kPrinter = CC3K_DEFAULT_PRINTER);



Now I'm really confused.
  • 1. Being unable to think with clarity or act with understanding and intelligence.
  • 2. Lacking logical order or sense. a confused set of rules.
  • 3. Chaotic; jumbled.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!


So I've been at this for almost a week before I decided to post for help.  Does anyone have anything better to offer than what I see so far?  My first post didn't do so well either, most people were not interested in helping but rather telling me just how misguided I am.  Is there a better forum to post to that maybe someone can point me to?  Thanks.


The help is up there.  Reply #1 indicates that you need to create an instance of the Adafruit_CC3000 class.  If you want to use cc3000 as the name then that's the name you should give it. 

Reply #3 points you to the constructor you need to use. 

At this point you've got help with the particular error you pointed to.  It isn't very clear what sort of help you need.  Do you know how to create a class instance?   Do you know how to use the library you've got? 

Is there something else about the examples for that library that you don't understand?
If at first you don't succeed, up - home - sudo - enter.


Hi Delta, and thanks for the pointers.  To answer your question, no I don't know how to use the libraries or how to create instances.  I lack the necessary education to build code from scratch.  Rather I find a completed project on the Internet and then modify it to suit my needs.  I do lots of research before I start posting questions, that's how I built my first home automation system which uses an Ethernet shield.  So now I'm looking to take it to the next level by using the CC3000 wireless shield but I have to get it working first before taking the next steps.  Thanks again and I look forward to any assistance you can offer.  Have a great day.


I lack the necessary education to build code from scratch.  Rather I find a completed project on the Internet and then modify it to suit my needs. 
And there's your problem.  Don't be afraid to learn a little C++.  It will be invaluable if you want to do bigger projects like this.  The hack and paste method works fine for a little while, but eventually you need to know what you are doing.  Short of just writing your code for you, or rewriting here the countless tutorials on the subject, there's not a lot I can do to help you. 
If at first you don't succeed, up - home - sudo - enter.


To answer your question, no I don't know how to use the libraries or how to create instances.
This might be pointless explaining without knowing the basics with C++, but you generally have classes in c++. A class would contain all the relevant information for what it is trying to describe, for example, the class "Car" might include variables such as "numberOfDoors", "EngineCapacity", "Model" etc.

So then to use this class, we would create an instance, for a Ford Focus for example, and we would fill in all the variables specified above. We then want another car, a Fiat Punto, so we then create another instance, and fill in all those variables for the Fiat Punto.

So back to your issue. The library contains the class, the class is called "Adafruit_CC3000". The constructor in the header file also shows that you need to specify some information, specifically pins, regarding where you wired the shield into your arduino. So you need something like this above your setup():

Code: [Select]

Adafruit_CC3000 cc3000( 8, 9, 10 );

You'll need to change 8, 9, 10 to whatever pins you used when wiring it to your arduino.


Thank you very much everyone, I will definitely try the code you suggest, as well as learning some c++.  I've never done any coding before so it will be a challenge.  But thanks again for your help and I'll keep you posted as to my progress.  Take care, until later...


Go Up