Inconsistent issues with Teensy 3 as Webclient Question

Status
Not open for further replies.

Ramrod13

New member
I have integrated the teensy 3 with a wiznet ethernet module and I have already established that it works by running the example Webserver sketch.

The task I am attempting to accomplish at the moment is simply communicating to a server and writing to a text file. Essentially whats going on is the teensy sends a message to a php script running on the server and then the script populates a .txt with the providing information. Simple right?

The issue I am having is that I've gotten my sketch and teensy/wiznet project to work twice already. But I can't repeat the results ever since. I am lighting a debug LED which turns on, however nothing is being written to the console. I am just confused as to what may actually be going on.... any thoughts?

I'm sure these are all beginner issues I am having so any help would be appreciated. Thanks!



myWebClient3.INO
Code:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
byte mac[] = { 0x**, 0x**, 0x**, 0x**, 0x**, 0x** };//Blue Teensy
IPAddress server(***,***,***,***);

// Initialize the Ethernet client library
// with the IP address and port of the server 
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
   //debug LED
  pinMode(23, OUTPUT);
  digitalWrite(23, HIGH);
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
  //Serial.println("Serial connection works");
   

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /sendData.php?name=cameFrom&status=theTeensy!/");
    client.println();
    client.println();
  } 
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}


void loop()
{
  //sendData();
  //delay(3000);  
}

void sendData(){
  if(client.connected()){
    // Make a HTTP request:
    client.println("GET /sendData.php?name=Client&status=ItWorkedAGAIN/");
    client.println();
    Serial.println("Looped Success cause still connected!");
  }
    else if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /sendData.php?name=Client&status=ItWorkedInAgain/");
    client.println();
    Serial.println("Looped Success and had to reconnect!");
  } 

  else {
    // kf you didn't get a connection to the server:
    Serial.println("Looped Fail and could not reconnect");
  }
}
 
Status
Not open for further replies.
Back
Top