Am I wasting my time with SMTP and a CC3000?

I just got a CC3000 WiFi shield and I was surprised that they did not have an example script for SMTP emails like the Ethernet shield does. I have see quite a number of examples for the WiFi shield. I have made some progress but my programing skills are impeding me at this point. I have taken the CC3000 library from Adafruit and have gotten the shield to connect to a SMTP server but the script I am trying to modify to work with this shield was from a Ethernet shield example and that library has a Flush() function for which there is no equivalent in the CC3000 library, or at least any that I can find. Am I wasting my time here? Below is the serial monitor output and a copy of the sketch. If you have any advise let’s have it. :grin: P.S. this was just over the allowed amount of text for a post so I have deleted comments. Hope I didn’t screw it up.

Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 1029

Initialising the CC3000 ...
Firmware V. : 1.24
MAC Address : 0x08 0x00 0x28 0x57 0xA4 0x72

Attempting to connect to HCPS_Guest
Started AP/SSID scan




Connecting to HCPS_Guest...Waiting to connect...Connected!
Request DHCP

IP Addr: 10.205.97.34
Netmask: 255.255.224.0
Gateway: 10.205.96.1
DHCPsrv: 10.5.96.25
DNSserv: 168.254.50.101
started
138


Connect to 168.254.26.52:25
Connected
freeram1:948
RCPT TO:
<>
DATA
freeram2:948
from:daniel.rahenkamp@xxxxx.com
to:roontoon@xxxx.com
freeram3:948
/*************************************************** 
 * This is for the Adafruit CC3000 Wifi Breakout & Shield
*/

#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

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       "HCPS_Guest"        
#define WLAN_PASS       ""

#define WLAN_SECURITY   WLAN_SEC_WPA2

//Create a new TCP/IP client
Adafruit_CC3000_Client client;

//Variables used by the leak detection logic
int status = 2; //0 = NO LEAK 1= LEAK WAS DETECTED 2= startup
int sensePin = 5;
int alarm = 1500;

/*!
 @brief  Sets up the HW and the CC3000 module (called automatically
 on startup)
 */

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

  pinMode(9,OUTPUT);          // changed to use onboard LED
  digitalWrite(9,HIGH);
  // delay(2000);
  // Serial.println("Ready. Press 'e' to send.");



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

  uint16_t firmware = checkFirmwareVersion();
  if ((firmware != 0x113) && (firmware != 0x118)) {
    Serial.println(F("Wrong firmware version!"));
    for(;;);
  }

  displayMACAddress();

  /* 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(void) 
{
  
 if (status == 0 && analogRead(sensePin) >= alarm )
  {
    Serial.println(F("water"));
    Serial.println(analogRead(sensePin));
    SendEmail(2);
    status = 1;
    delay(500);    
  }

  else if (status == 1 && analogRead(sensePin) <= alarm )
  {
    Serial.println(F("no water"));
    Serial.println(analogRead(sensePin));
    status = 0;
  }

  //Send that we have powered on succefully
  else if (status == 2)
  {
    Serial.println(F("started"));
    Serial.println(analogRead(sensePin));
    SendEmail(2);
    Serial.println(freeRam ());
    delay(5000); 
  }
}

//shows free ram
int freeRam () 
{
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

bool SendEmail(int task)
{
  bool sent = false;
  int smtpDelay = 100;

  //Set the destination for our packets
  uint32_t smtp = cc3000.IP2U32(168,254,26,52);

  //Connect to the smtp server 
  client = cc3000.connectTCP(smtp, 25);

  delay (100);

  if (client.connected())
  {
    Serial.println(F("Connected"));
    
    client.fastrprintln (F("EHLO P"));
    client.fastrprintln (F("AUTH LOGIN"));                         
    client.fastrprintln (F("*username*"));           
    client.fastrprintln (F("*pass*"));
   // client.flush();
    client.fastrprintln (F("MAIL FROM:<>"));
   
    //client.flush();
    
    Serial.print("freeram1:");
    Serial.println(freeRam ());
    
    client.print(F("RCPT TO:"));
    Serial.println(F("RCPT TO:"));
    client.println(F("<>"));
    Serial.println(F("<>"));
  //  client.flush();
    client.println("DATA");
    Serial.println(F("DATA"));
   // client.flush();
    Serial.print("freeram2:");
    Serial.println(freeRam ());

    client.println("from:daniel.rahenkamp@xxxx.com");
    Serial.println(F("from:daniel.rahenkamp@xxxx.com"));
    client.println("to:roontoon@xxxxx.com");
    Serial.println(F("to:roontoon@xxxx.com"));
    Serial.print("freeram3:");
    Serial.println(freeRam ());
    client.println("SUBJECT: Testing");
    Serial.println(F("SUBJECT: Testing"));
    Serial.print("freeram4:");
    Serial.println(freeRam ());
    client.println();
    client.println("This is the line body.");
    client.println("This is another line of the body.");
    client.println(".");
    client.println(".");
    client.println("QUIT");
    sent = true;
  }
  else
  {
    Serial.print("error");
    sent = false; 
  }

Serial.print("fredsfsdfsdf:");

  return sent;
}

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
}



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

Here is email client code I helped another user with a while ago.
http://playground.arduino.cc/Code/WiFiEmailClient
If the CC3000 library has similar functions, it should work. If it doesn't, it should let you know why. It displays the email server response so you will know what happened.

You will need to change the setup() part to initialize your CC3000 correctly, but the loop() part should remain basically the same.

Thanks!!! You Rock! I will get back if I have problems.

d

Stuck already. Not sure if I have conflicts in having both the WiFi and CC3000 libraries included.

Errors:

EmailWiFiTest6:30: error: ‘WiFiClient’ does not name a type
EmailWiFiTest6.ino: In function ‘byte sendEmail()’:
EmailWiFiTest6:115: error: ‘client’ was not declared in this scope
EmailWiFiTest6:126: error: ‘client’ was not declared in this scope
EmailWiFiTest6.ino: In function ‘byte eRcv()’:
EmailWiFiTest6:179: error: ‘client’ was not declared in this scope
EmailWiFiTest6:191: error: ‘client’ was not declared in this scope
EmailWiFiTest6.ino: In function ‘void efail()’:
EmailWiFiTest6:213: error: ‘client’ was not declared in this scope

//    Email client sketch for IDE v1.6 and CC3000
//    Posted December 2012 by SurferTim
//    Modified 17 March 2013 for WiFi Shield by 
//    MisterResistor and SurferTim

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
//#include <WiFi.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       "HCPS_Guest"        // 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

char server[] = "mail.sdhc.k12.fl.us";  // smtp mail server  (mine.com)

WiFiClient client;


/**************************************************************************/
/*!
 @brief  Sets up the HW and the CC3000 module (called automatically
 on startup)
 */
/**************************************************************************/
void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n")); 

  pinMode(9,OUTPUT);          // changed to use onboard LED
  digitalWrite(9,HIGH);
  // delay(2000);
  // Serial.println("Ready. Press 'e' to send.");

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

  uint16_t firmware = checkFirmwareVersion();
  if ((firmware != 0x113) && (firmware != 0x118)) {
    Serial.println(F("Wrong firmware version!"));
    for(;;);
  }

  displayMACAddress();

  /* 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("Email sent");     
       else Serial.println("Email failed");
   }       
 }

byte sendEmail()
 {
   byte thisByte = 0;
   byte respCode;

  if(client.connect(server,25)) {
     Serial.println("connected");
   } else {
     Serial.println("connection failed");
     return 0;
   }

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

// change to your public ip
   client.write("helo 1.2.3.4\r\n");

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

// change to your email address (sender)
   client.write("MAIL From: <roontoon@me.com>\r\n");

  if(!eRcv()) return 0;

// change to recipient address
   Serial.println("Sending To");
   client.write("RCPT To: <roontoon@me.com>\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending DATA");
   client.write("DATA\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending email");

// change to recipient address
   client.write("To: You <roontoon@me.com>\r\n");

// change to your address
   client.write("From: Me <roontoon@me.com>\r\n");
  client.write("Subject: Arduino email test\r\n");
  client.write("This is from my Arduino WiFi shield!\r\n");
  client.write(".\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending QUIT");
  client.write("QUIT\r\n");

  if(!eRcv()) return 0;

  client.stop();

  Serial.println("disconnected");

  return 1;
 }

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

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

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

  respCode = client.peek();

  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.write("QUIT\r\n");

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

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

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

  client.stop();

  Serial.println("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;
  }
}

You need to change this in your global variable section.I don't know how to declare that with the CC3000.

WiFiClient client;

In the first sketch I had it declared as Adafruit_CC3000_Client client; and I just changed it and I get a whole other set of errors referring to connect which I believe is not in that library. Attached is the CC3000 library

EmailWiFiTest6.ino: In function 'byte sendEmail()':
EmailWiFiTest6:116: error: 'class Adafruit_CC3000_Client' has no member named 'connect'
EmailWiFiTest6:127: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:127: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:133: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:133: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:139: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:139: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:144: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:144: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:151: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:151: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:154: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:154: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:156: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:156: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:157: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:157: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:158: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:158: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:163: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:163: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:167: error: 'class Adafruit_CC3000_Client' has no member named 'stop'
EmailWiFiTest6.ino: In function 'byte eRcv()':
EmailWiFiTest6:186: error: 'class Adafruit_CC3000_Client' has no member named 'stop'
EmailWiFiTest6:192: error: 'class Adafruit_CC3000_Client' has no member named 'peek'
EmailWiFiTest6.ino: In function 'void efail()':
EmailWiFiTest6:214: error: invalid conversion from 'const char*' to 'uint8_t'
EmailWiFiTest6:214: error: initializing argument 1 of 'virtual size_t Adafruit_CC3000_Client::write(uint8_t)'
EmailWiFiTest6:222: error: 'class Adafruit_CC3000_Client' has no member named 'stop'
EmailWiFiTest6:234: error: 'class Adafruit_CC3000_Client' has no member named 'stop'

Adafruit_CC3000.zip (176 KB)

Looked a little more that the CC3000 Library and they have this function //
/*!
@brief Quick socket test to pull contents from the web
*/
/
/
Adafruit_CC3000_Client Adafruit_CC3000::connectTCP(uint32_t destIP, uint16_t destPort)

Which “appears” to me will allow me to connect using a TCP/IP connection and port number. Donno if I could use that in place of the connect that is giving me issues.

d

Then I suspect the correct replacement is this:

Adafruit_CC3000_Client client;

edit: Then use this:

  uint32_t smtp = cc3000.IP2U32(168,254,26,52);

  //Connect to the smtp server 
  client = cc3000.connectTCP(smtp, 25);

That is what I have. Sorry forgot to put that in my last post.

Complete script.

//    Email client sketch for IDE v1.6 and CC3000
//    Posted December 2012 by SurferTim
//    Modified 17 March 2013 for WiFi Shield by 
//    MisterResistor and SurferTim

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
//#include <WiFi.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       "HCPS_Guest"        // 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

char server[] = "mail.sdhc.k12.fl.us";  // smtp mail server  (mine.com)

//WiFiClient client;
Adafruit_CC3000_Client client;


/**************************************************************************/
/*!
 @brief  Sets up the HW and the CC3000 module (called automatically
 on startup)
 */
/**************************************************************************/
void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n")); 

  pinMode(9,OUTPUT);          // changed to use onboard LED
  digitalWrite(9,HIGH);
  // delay(2000);
  // Serial.println("Ready. Press 'e' to send.");



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

  uint16_t firmware = checkFirmwareVersion();
  if ((firmware != 0x113) && (firmware != 0x118)) {
    Serial.println(F("Wrong firmware version!"));
    for(;;);
  }

  displayMACAddress();

  /* 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("Email sent");     
       else Serial.println("Email failed");
   }       
 }

byte sendEmail()
 {
   byte thisByte = 0;
   byte respCode;

  if(client.connect(server,25)) {
     Serial.println("connected");
   } else {
     Serial.println("connection failed");
     return 0;
   }

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

// change to your public ip
   client.write("helo 1.2.3.4\r\n");

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

// change to your email address (sender)
   client.write("MAIL From: <roontoon@me.com>\r\n");

  if(!eRcv()) return 0;

// change to recipient address
   Serial.println("Sending To");
   client.write("RCPT To: <roontoon@me.com>\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending DATA");
   client.write("DATA\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending email");

// change to recipient address
   client.write("To: You <roontoon@me.com>\r\n");

// change to your address
   client.write("From: Me <roontoon@me.com>\r\n");

  client.write("Subject: Arduino email test\r\n");
  client.write("This is from my Arduino WiFi shield!\r\n");
  client.write(".\r\n");

  if(!eRcv()) return 0;

  Serial.println("Sending QUIT");
  client.write("QUIT\r\n");

  if(!eRcv()) return 0;

  client.stop();

  Serial.println("disconnected");

  return 1;
 }

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

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

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

  respCode = client.peek();

  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.write("QUIT\r\n");

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

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

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

  client.stop();

  Serial.println("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;
  }
}

Try client.print() instead of client.write().

Sorry just saw the second part of your post. Still no go…

Tried

uint32_t smtp = cc3000.IP2U32(168,254,26,52);

  //Connect to the smtp server 
  client = cc3000.connectTCP(smtp, 25);

here

//    Email client sketch for IDE v1.6 and CC3000
//    Posted December 2012 by SurferTim
//    Modified 17 March 2013 for WiFi Shield by 
//    MisterResistor and SurferTim

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
//#include <WiFi.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       "HCPS_Guest"        // 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

char server[] = "mail.sdhc.k12.fl.us";  // smtp mail server  (mine.com)

//WiFiClient client;
//Adafruit_CC3000_Client client;

uint32_t smtp = cc3000.IP2U32(168,254,26,52);

//Connect to the smtp server 
client = cc3000.connectTCP(smtp, 25);

/**************************************************************************/
/*!
 @brief  Sets up the HW and the CC3000 module (called automatically
 on startup)
 */
/**************************************************************************/
void setup(void)
{
  Serial.begin(115200);

And got the following.

EmailWiFiTest6:36: error: expected constructor, destructor, or type conversion before '=' token
EmailWiFiTest6.ino: In function 'byte sendEmail()':
EmailWiFiTest6:121: error: 'client' was not declared in this scope
EmailWiFiTest6:132: error: 'client' was not declared in this scope
EmailWiFiTest6.ino: In function 'byte eRcv()':
EmailWiFiTest6:185: error: 'client' was not declared in this scope
EmailWiFiTest6:197: error: 'client' was not declared in this scope
EmailWiFiTest6.ino: In function 'void efail()':
EmailWiFiTest6:219: error: 'client' was not declared in this scope

SurferTim:
Try client.print() instead of client.write().

I was just posting my last post when you did this… Were exactly?

Unfortunately I do not have a CC3000 to test this with. :frowning:

Maybe someone else will be able to help you.

Thanks for your help.

roontoon:
Thanks for your help.

Hi Roontoon. Did you manage to figure it out?

It should be possible. The transport should be transparent. The protocol is the important part.