Hi guys..
So I have a project that's kicking me a bit...
I've been slowly getting past the hurdles but this one I have right now is not getting anywhere..
Using the ethernet shield, I am trying to access/execute a php file on a web server.
Now I have read and tried so many thread posts and tactics but not getting anywhere..
I want to write data from arduino to mysql.. (end goal)
Now, the PHP side of things is working.
For some reason, the arduino is not executing the php file.
First thing, port is not 80 ... it's 3306
at this point I have not tried sending data through yet.
the php file writes it's own data for now..
Here is the code for arduino:
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
EthernetClient client;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte myIP[] = { 10, 0, 0, 6 };
byte myGate[] = { 10, 0, 0, 2 };
byte myServer[] = { 197, 242, 144, 236 }; //Web Server IP Address
//char myServer[] = "automatemybusiness.co.za";
IPAddress ip(10, 0, 0, 6); // My Arduino IP Address Setup
IPAddress gateway(10, 0, 0, 2);
IPAddress subnet(255, 255, 255, 0);
char Data1[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
char Data2[6] = {'T', 'h', 'e', 'r', 'e', '\0'};
void setup(){
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Setting up "); // print message
Ethernet.begin(mac, myIP, myIP, myGate);
delay (5000);
lcd.setCursor(0,0);
lcd.print("Done "); // print message
delay(1000);
}
void loop(){
lcd.setCursor(0,1);
lcd.print("start loop ");
delay(2000);
int Iloopcount=0;
if (Iloopcount <= 10 ){
Iloopcount++;
lcd.setCursor(0,1);
lcd.print("Loop : ");
lcd.print(Iloopcount);
lcd.print(" ");
delay(1000);
UploadData(Data1, Data2);
}
delay(5000);
}
//Writing the data to the web portal
void UploadData(String Col1, String Col2){
String data;
lcd.setCursor(0,1);
lcd.print("trying to connect ");
delay (1000);
client.connect(myServer , 3306);
lcd.setCursor(0,1);
lcd.print("connect done ");
delay (1000);
if (client.connected()) {
client.println("GET /add.php?celsius=18 HTTP/1.0");
client.println();
delay(1000);
if (client.available()) {
delay(4000);
char c = client.read();
lcd.setCursor(0,0);
lcd.print("Feedback : ");
lcd.print(c);
delay(1000);
}
lcd.setCursor(0,1);
lcd.print("data sent...");
delay (1000);
}
else{
lcd.setCursor(0,1);
lcd.print("didnt connect");
delay (1000);
}
client.stop();
// client.flush();
}
I'm stuck ...