I solved this in the code where I had "Serial.println(" HTTPS/1.0");" should have been "Serial.println(" HTTP/1.0");" once the s was dropped all went through with no problem. This is a pretty slick way to send an email I like it better then using choreos through Temboo as I think it is less code.
I am having extreme difficulty sending an SMS message from Arduino,a text needs to go out when the water gets too high or low in a tank. I have the ENC28J60 module working fine and connecting to the net. I am using Tropo.com as the gateway to send the text messages out and I know the messages go out properly because I have gotten them out using the browser by inputting the following into the browser:
https://api.tropo.com/1.0/sessions?action=create&token=XXXXXXXXXXXXXXXXXXXXXXXXXXX&numberToDial=17634983685¶meter=Water&highlow=high&location=medical&roomnumber=328
When the above is entered as the URL out pops the correct text message using the script I wrote and store on Tropo.com to parse the arguments above.
Here is the code that I have tried and when I print out the statements that are going into the GET statement with Serial.print that mimic the client.print statements to make sure the above request is what gets sent out. The request does not get far enough into Tropo to get a log file response in my account with them.
Here is the response I get from the serial monitor when I run the sketch, does anyone know what is wrong with my request?
DHCP:OK
connected
GET /1.0/sessions?action=create&token=XXXXXXXXXXXXXXXXXXXXXXXXXX&numberToDial=17634983685¶meter=water&highlow=high&location=medical&roomnumber=238 HTTPS/1.0
Host: api.tropo.com
HTTP/1.0 400 Bad request
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>
disconnecting.
This is the first time I have tried to send text messages with Arduino and hopefully there is wisdom out there that can tell me what I have done wrong. I get the message that it is connected before
The Arduino code is at the end of the message, I have blanked out any sensitive info with XXXXX's.
Thanks
wade
/*
Etherent Code Source: http://arduino.cc/en/Tutorial/WebClient
*/
#include <UIPEthernet.h> // http://arduino.cc/en/Reference/Ethernet
#include <SPI.h> // Allows you to communicate with SPI devices. See: http://arduino.cc/en/Reference/SPI
#define TROPO_SMS_TOKEN "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // Enter correst token
byte mac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };
//byte ip[] = { 192, 168, 1, 124 }; // home LAN
char server[] = "api.tropo.com";
char sensorOutOfNorm[] = "water";
char highOrLow[] = "high";
char building[] = "medical";
char roomNumber[] = "238";
IPAddress ip(192,168,1, 124);
IPAddress gateway(192,168,10, 1);
IPAddress subnet(255, 255, 255, 0);
// Initialize the Ethernet client library
EthernetClient client;
void setup()
{
Serial.begin(9600);
Serial.println("Welcome to Tropo SMS");
// while (!Serial && millis() < 500) {} // Wait 8 seconds for serial port to be established (for Leonardo)
Ethernet.begin(mac, ip, gateway, subnet); // start the Ethernet connection
Serial.println(Ethernet.localIP());
delay(1000); // give the Ethernet shield a second to initialize
sendSMS();
}
void loop()
{
}
void sendSMS() //client function to send/receive GET request data.
{
//starts client connection, checks for connection
if (client.connect(server, 80))
{
Serial.println(F("connected"));
Serial.println("connected");
client.print("GET /1.0/sessions?action=create&token=");
client.print(TROPO_SMS_TOKEN);
client.print("&numberToDial=17634983685"); // phone number
client.print("¶meter=");
client.print(sensorOutOfNorm);
client.print("&highlow=");
client.print(highOrLow);
client.print("&location=");
client.print(building);
client.print("&roomnumber=");
client.print(roomNumber);
client.println(" HTTPS/1.0");
client.println("Host: api.tropo.com");
client.println(); //end of get request
}
else
{
Serial.println("Connection failed"); //error message if no client connect
}
// These next Serial.print statements are to make sure that the structure of the GET has the correct content and format+
Serial.print("GET /1.0/sessions?action=create&token=");
Serial.print(TROPO_SMS_TOKEN);
Serial.print("&numberToDial=17634983685"); // phone number
Serial.print("¶meter=");
Serial.print(sensorOutOfNorm);
Serial.print("&highlow=");
Serial.print(highOrLow);
Serial.print("&location=");
Serial.print(building);
Serial.print("&roomnumber=");
Serial.print(roomNumber);
Serial.println(" HTTPS/1.0");
Serial.println("Host: api.tropo.com");
Serial.println(); //end of get request
while (client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available())
{ //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println(F("\n\ndisconnecting.\n"));
client.stop(); //stop client
}