loading
1 Comments

Tell us about yourself!

Complete Your Profile
  • PART 1 - Send Arduino data to the Web ( PHP/ MySQL/ D3.js )

    Hello sir, thank you for your tutorial that really help me very much. I succeed on localhost but i have some problem when try this code on my server. Now I can connect to my server but server doesn't receive any data from arduino. Here is my complete code and location of my add.php file on server. The url of add.php file is right?#include <Ethernet.h>#include <BH1750FVI.h>#include <SPI.h>#include <DHT.h>const int DHTPIN = 2;const int DHTTYPE = DHT11;DHT dht(DHTPIN,DHTTYPE);BH1750FVI LightSensor;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // RESERVED MAC ADDRESSbyte arduinoip[] = {172,30,115,177};byte dnServer[] = {8,8,8,8};byte gateway[] = {172,30,0,1};byte subnet[] = {255,255,255,0};byte server[] = {10,80,11,239};EthernetClient client;float t = 0;float ...see more »Hello sir, thank you for your tutorial that really help me very much. I succeed on localhost but i have some problem when try this code on my server. Now I can connect to my server but server doesn't receive any data from arduino. Here is my complete code and location of my add.php file on server. The url of add.php file is right?#include <Ethernet.h>#include <BH1750FVI.h>#include <SPI.h>#include <DHT.h>const int DHTPIN = 2;const int DHTTYPE = DHT11;DHT dht(DHTPIN,DHTTYPE);BH1750FVI LightSensor;byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // RESERVED MAC ADDRESSbyte arduinoip[] = {172,30,115,177};byte dnServer[] = {8,8,8,8};byte gateway[] = {172,30,0,1};byte subnet[] = {255,255,255,0};byte server[] = {10,80,11,239};EthernetClient client;float t = 0;float h = 0;float lux = 0;float node = 1;String data;void setup() {// put your setup code here, to run once:Serial.begin(115200);LightSensor.begin();LightSensor.SetAddress(Device_Address_H);LightSensor.SetMode(Continuous_H_resolution_Mode);dht.begin();Ethernet.begin(mac, arduinoip, dnServer, gateway, subnet);Serial.print("IP = ");Serial.println(Ethernet.localIP());Serial.print("DNS = ");Serial.println(Ethernet.dnsServerIP());Serial.print("gatewayIP = ");Serial.println(Ethernet.gatewayIP());Serial.print("subnetMask = ");Serial.println(Ethernet.subnetMask());delay(10000);}void loop() {h = (float) dht.readHumidity();t = (float) dht.readTemperature();lux = (float) LightSensor.GetLightIntensity();float node = 1;data = "temp1";data.concat(t);data.concat("hum1");data.concat(h);data.concat("light1");data.concat(lux);data.concat("node1");data.concat(node);Serial.print("Data: ");Serial.println(data);// put your main code here, to run repeatedly:if (client.connect(server,80)) {Serial.println("Client connection successfull.");client.println("POST /add.php HTTP/1.1");client.println("Host: 10.80.11.239");client.println("Content-Type: application/x-www-form-urlencoded");client.print("Content-Length: ");client.println(data.length());client.println();client.print(data);}else{Serial.println("Client connection failed.");}if (client.connected()) {client.stop(); // DISCONNECT FROM THE SERVER}delay(30000);}

    View Instructable »