1

I'm new here and also new to Arduino.

I've got a rather specific problem and I've posted to the official Forum on arduino.cc two days ago (original Post)

Sadly, I've yet to recieve any help and since it's a project for work, theres a (loose) schedule. So I've decided to post it here as well.

If you have some ideas, it'd be really great!

Also, if I've posted this question without acknowleding some forum rules please tell me so that I can write better posts in the future ;-)

Regards,

Patrick

Edit: The original Posts as Text :-)

Post # 1

Hello Guys,

this is my first time posting in the forum since I'm new to Arduino, so please be kind smiley-wink. Me and a colleague of mine have been given a Project to create with arduino hardware.

The Project is, that you should be able to read NFC tags with the arduino and send them to a server to be checked and eventually being written into a db.

The hardware: Arduino Uno R3 (funduino.de/index.php/shop/product/view/2/4) Adafruit CC3000 (www.adafruit.com/products/1469) Adafruit PN532 (www.adafruit.com/products/789) Stepper Motor (not yet included and not relevant for the problem)

Sorry about not using hyperlinks, but the forum says I'm not allowed to post more than 2 links at once...

Now on to the Problem: When we're using the shields separately (meaning connecting the arduino to either of the shields by itself), the shields work fine. The cc3000 gets a connection and the PN532 reads cards. Now we've tried to stack them together for live use. That's where the trouble starts...

If I connect the PN532 5V to the arduino 3.3V and CC3000 VIN to 5V arduino, the shields both do what they should with separate example sketches ('readMifare' and 'buildTest').

If I put my sketch in (which combines both of those sketches and some other stuff) and comment out the initialization of either the PN532 or the CC3000, the other shield works.

Now if I try to use both, the CC3000 and the PN532, the CC3000 tries to initialize, but falls into a loop of restarts. I've read that that (possibly) is because of the lack of power supply. (I've connected a 12V wall-wart by the way and it didn't work with that either)

The manual says, that the CC3000 needs 5V, but can work on 3.3V too (though I didn't find a source to explain how) and the PN532 needs 3.3V to run.

Am I doing something wrong, or is it a problem with the arduino? If I'm doing it wrong, how am I connecting these parts correctly?

I really am not that good with electronics and didn't find a sollution to my problem nearly a days worth of searching the net. For your understanding I'll post the script I'm using and some pictures of the board setup. Thanks in advance for ANY help you guys can give me (even if it's just good guide for problems like mine) ^^

Regards, Patrick

The part of the sketch that initializes the components (and also where the CC3000 gets stuck...) Code:

//WLAN-Libraries
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

//NFC-Libraries
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>

//Motor-Libraries
#include <Stepper.h>

//NFC-shield PINs
#define IRQ   (2)
#define RESET (4)  // Not connected by default on the NFC Shield

Adafruit_NFCShield_I2C nfc(IRQ, RESET);

//Motor-settings

const int stepsPerRevolution = 180;  // change this to fit the number of steps per revolution
                                     // for your motor

Stepper Motor(stepsPerRevolution, 6,7,8,9);  // initialize the stepper library on pins 8 through 11:          

//Wifi-settings

// 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

#define WLAN_SSID       "mySSID"           // changed for your convenience
#define WLAN_PASS       "myPassphrase"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

Adafruit_CC3000_Client www;  //defines how we will refer to the cc3000 connection object

// What page to grab!
#define WEBSITE      "10.2.10.170"  //NOTE: CC3000 doesn't seem to like the default localhost address of 127.0.0.1 - need to enter actual IP
#define WEBPAGE     "/index.php"


//this is the counter that will be used for uploading data
long pollCounter = 1; 

//used for storing data for upload
//set it to the data type that suits your data
int
  NFC_ID, Session_ID, UID_final;

//used for commands received from base station
int
  command_open, command_close;

  boolean pollFlag = false;         //tells the sketch whether to poll or not

//declare a variable to hold a numeric IP address
//can be overridden below if you use lookup
  uint32_t ip = (192L << 24) | (168L<<16) | (1<<8) | 13;


/**************************************************************************/
/*!
    @brief  Initialization of the modules (Motor, Wifi, NFC-Reader)
*/
/**************************************************************************/


void setup(void)
{

//Set up the Motor for the lock

  // set the Motor speed at 60 rpm:
  Motor.setSpeed(60);

//Set up the Wifi module

  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n")); 

  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);

  /* Initialize the Wifi module */
  Serial.println(F("\nInitializing..."));                 //<======== Here the CC3000 gets stuck in a loop
  if (!cc3000.begin())                                          //                          when both shields are connected
    {
      Serial.println(F("Couldn't begin()! Check your wiring?"));
      while(1);
    }

  cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);

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


  cc3000.printIPdotsRev(ip);

//Set up the NFC module if (pollFlag == true) { nfc.begin();

        uint32_t versiondata = nfc.getFirmwareVersion();
        if (! versiondata) {
          Serial.print("Didn't find PN53x board");
          while (1); // halt
        }
        // Got ok data, print it out!
        Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
        Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
        Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

        // configure board to read RFID tags
        nfc.SAMConfig();

        Serial.println("Waiting for an ISO14443A Card ...");
  }
  else {
     Serial.println("Failed to initialize NFC-Reader... Sorry..."); 
  }

  }

Hope I'm not messing up the image-uploads... (I kept the wiring-colors where I coul for you to see the connections easily)

The boards connected via cables (both separately working) www.directupload.net/file/d/3740/j3y3tx38_jpg.htm

The boards put together www.directupload.net/file/d/3740/yb9q6qla_jpg.htm

The boards connected together with the Wifi in the picture. (You can't see the LED on the CC3000 light up, but I swear it does smiley-wink) www.directupload.net/file/d/3740/uorksjrj_jpg.htm

Post # 2

Ok, I got myself a multimeter today to measure if it is really a problem with the power supply.

With the NFC-Reader running I measured 4.85V on the 5V-Pin and 3.32V on the 3.3V-Pin. This means, that the CC3000 should have enough Power to run.

So I'm now looking for a possible address collision in the libraries (specifically I2C- and SPI-collisions). As I'm still new to this, help is really appreciated.

Edit #2:

Morning everyone! What I've found out since yesterday is, that the PN532 uses I2C while the CC3000 uses SPI to communicate. When I looked through the libraries I found out that the PN532 includes Wire.h which gets its address at "nfc.begin();"

In the begin-function in Wire.cpp there is an address transmitted to the function, but I can't find it's source. Is it possible that that address collides with the one the CC3000 uses?

When I uploaded an I2C-Scanner to the UNO, it said that the only device fount is the PN532 on address '0x24'.

I don't really know what to do with that info though, since there are more libraries being included (like which in term calls others) and I cant even find these on the Mac I'm working on at the moment...

Edit #3:

The problem has been solved in the arduino.cc forum. The SRAM was overflowing, but applying the F()-macro to the strings being printed solved the issue! (Just in case someone has similar issues ^^)

0

The problem has been solved in the arduino.cc forum. The SRAM was overflowing, but applying the F()-macro to the strings being printed solved the issue! (Just in case someone has similar issues ^^)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.