Hi all! So I have used a 3V and 5V circuit, I also went from 8Mhz Arduino to 16Mhz Arduino all with the same result. After a few connections, the system seems to stop working for about 20-30 seconds, and then I can post data again. Maybe there is something in my code stopping the CC3000 from working properly? I upgraded the firmware as well to make sure I am up to date.
I have an XBee receiving packets, then posting the packets online to Dweet.io.
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include <XBee.h>
#include <SoftwareSerial.h>
XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS,
ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIV2);
#define WLAN_SSID "SSID"
#define WLAN_PASS ""
#define WLAN_SECURITY WLAN_SEC_WPA2
#define thing_name "SomeName"
char pay0;
char pay1;
uint32_t ip;
void setup(void)
{
Serial.begin(9600);
xbee.setSerial(Serial);
if (!cc3000.begin())
{
while(1);
}
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
while (!cc3000.checkDHCP())
{
delay(100);
}
}
void loop(void)
{
readXbee();
delay(500);
sendDweet();
}
void sendDweet(){
uint32_t ip = 0;
while (ip == 0) {
if (! cc3000.getHostByName("www.dweet.io", &ip)) {
}
delay(500);
}
cc3000.printIPdotsRev(ip);
if(!cc3000.checkConnected()){while(1){}}
Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
if (client.connected()) {
client.fastrprint(F("GET /dweet/for/"));
client.print(thing_name);
client.fastrprint(F("?LowHex="));
client.print(rx.getRemoteAddress64().getMsb(), HEX);
client.fastrprint(F("&HighHex="));
client.print(rx.getRemoteAddress64().getLsb(), HEX);
client.fastrprint(F("&Pay0="));
client.print(pay0);
client.fastrprint(F("&Pay1="));
client.print(pay1);
client.fastrprintln(F(" HTTP/1.1"));
client.fastrprintln(F("Host: dweet.io"));
client.fastrprintln(F("Connection: close"));
client.fastrprintln(F(""));
} else {
return;
}
}
void readXbee(){
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(rx);
for (int i = 0; i < rx.getDataLength(); i++) {
if (i == 0){
pay0 = rx.getData()[i];
}
if (i == 1){
pay1 = rx.getData()[i];
}
}
}
}
}