This is a continuation of my original text sending problem but that thread has been 'Locked'. No problem.
Background
I have developed a Feather MO WIFI based control system that monitors water tank levels for my water association. The most important feature of this project is that texts are sent whenever water levels fall below 8 feet. I can do this 24/7 if I use an unsecure - HTTP - website, but if I use the water associations secure - HTTPS - website, the texts are never sent.
Update
I have learned that by changing a single line of code I can receive texts from the HTTPS website without fail. By changing -
Code: Select all
if (client.connect(server, 80))
Code: Select all
if (client.connectSSL(server, 443))
Here is the pertinent code from the test sketch:
Code: Select all
void loop() {
postData = postVariable + " 7.5 feet";
{
//if (client.connect(server, 80)) // use for HTTP sites only ...
if (client.connectSSL(server, 443)) // use for HTTPS site only ...
{
client.println("POST /includes/text_message_to_be_sent.php HTTP/1.1");
client.println("Host: www.secure-website.org");
//client.println("Host: www.nonsecure-website.com");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(postData.length());
client.println();
client.print(postData);
Serial.println("Message sent!");
}
if (client.connected()) {
client.stop();
}
delay(60000);
}
Serial.println(postData);
delay(3000);
}
Using the sketch that has been uploaded to the Feather MO WIFI embedded in the project enclosure, I can receive texts from an HTTP site, but never from the water associations HTTPS website. Here is the code snippet from the embedded Feather sketch:
Code: Select all
void send_text(float interval, float tank_level){
String current_tank_level = String (tank_level,2);
postData = postVariable + current_tank_level; // using a variable for tank level ...
unsigned long tank_level_currentMillis = millis();
if (tank_level_currentMillis - tank_level_previousMillis >= interval)
{
tank_level_previousMillis = tank_level_currentMillis;
if (client.connect(server, 80)) // HTTP site only ...
//if (client.connectSSL(server, 443)) // HTTP site only ...
{
client.println("POST /includes/send_this_text_message.php HTTP/1.1");
//client.println("Host: www.secure-website.org");
client.println( "Host: www.non-secure-website.com" );
client.println( "Content-Type: application/x-www-form-urlencoded" );
client.print("Content-Length: ");
client.println(postData.length());
client.println();
client.print(postData);
Serial.println("Email Sent");
Serial.println(postData);
}
if (client.connected()) {
client.stop();
}
}
}
Bottom Line
Using my test sketch I can receive texts from either HTTP or HTTPS websites.
Using the embedded Feather sketch I can receive texts from an HTTP site but never from an HTTPS website.
For the sake of clarity I will mention the following:
The PHP files used in both sketches are identical. They are copies of each other.
I do not understand what I am overlooking. If someone can shed some light on this problem I would be very grateful.
Thank you.