Hi,
I am very much new to arduino to be precise new to embedded programming itself, although got some knowledge on c++.Basically I am trying to send some data from my arduino Duemilenove to pc via RN-171 wifly module. So i started to play with various wifi sketches available with arduino , but wiflyhq and wifiserial are only working with RN-171. to test I downloaded the code from GitHub - ericbenwa/POST-Arduino-Data-Wireless: A simple way to send data from an Arduino and save it to a database (MySQL) over WiFi. here. which posts some value to php which is then saved to a mysql db, I have done almost all the same except , the code uses wifi.h and i am using wiflyhq.h as include file. But i am unable to send data to the php page in my windows 7 laptop. the php code is also taken from the same link. and when i tested the php via browser it works as expected. for the reference i am posting my arduino program here
#include <WiFlyHQ.h>
#include <SoftwareSerial.h>
SoftwareSerial wifiSerial(8,9);
//#include <AltSoftSerial.h>
//AltSoftSerial wifiSerial(8,9);
WiFly wifly;
/* Change these to match your WiFi network */
const char mySSID[] = "DLink";
const char myPassword[] = "asdfgf";
//const char site[] = "arduino.cc";
//const char site[] = "www.google.co.nz";
const char site[] = "192.168.1.100";
int yourarduinodata=999;
String yourdatacolumn= "yourdata=";
String yourdata;
void terminal();
void setup()
{
char buf[32];
Serial.begin(115200);
Serial.println("Starting");
Serial.print("Free memory: ");
Serial.println(wifly.getFreeMemory(),DEC);
wifiSerial.begin(9600);
if (!wifly.begin(&wifiSerial, &Serial)) {
Serial.println("Failed to start wifly");
terminal();
}
/* Join wifi network if not already associated */
if (!wifly.isAssociated()) {
/* Setup the WiFly to connect to a wifi network */
Serial.println("Joining network");
wifly.setSSID(mySSID);
wifly.setPassphrase(myPassword);
wifly.enableDHCP();
if (wifly.join()) {
Serial.println("Joined wifi network");
} else {
Serial.println("Failed to join wifi network");
terminal();
}
} else {
Serial.println("Already joined network");
}
//terminal();
Serial.print("MAC: ");
Serial.println(wifly.getMAC(buf, sizeof(buf)));
Serial.print("IP: ");
Serial.println(wifly.getIP(buf, sizeof(buf)));
Serial.print("Netmask: ");
Serial.println(wifly.getNetmask(buf, sizeof(buf)));
Serial.print("Gateway: ");
Serial.println(wifly.getGateway(buf, sizeof(buf)));
wifly.setDeviceID("Wifly-WebClient");
Serial.print("DeviceID: ");
Serial.println(wifly.getDeviceID(buf, sizeof(buf)));
if (wifly.isConnected()) {
Serial.println("Old connection active. Closing");
wifly.close();
}
yourdata = yourdatacolumn + yourarduinodata;
if (wifly.open(site, 80)) {
Serial.print("Connected to ");
Serial.println(site);
/* Send the request */
wifly.println("POST /phptest/insert_mysql.php HTTP/1.1");
wifly.println("Host: 192.168.1.100");
wifly.println("User-Agent: Arduino/1.0");
wifly.println("Connection: close");
wifly.println("Content-Length: ");
wifly.println(yourdata.length());
wifly.println();
wifly.println(yourdata);
Serial.println(yourdata);
} else {
Serial.println("Failed to connect");
}
}
void loop()
{
}
/* Connect the WiFly serial to the serial monitor. */
void terminal()
{
while (1) {
if (wifly.available() > 0) {
Serial.write(wifly.read());
}
if (Serial.available() > 0) {
wifly.write(Serial.read());
}
}
}
I am not sure what i am doing wrong. the serial monitor correctly displays the values in relation to wify and it also shows connected to the site and finally the serial monitor prints yourdata=999 , but when i check in mysql server in my laptop there is no new data added to it.
Any pointers.