Go Down

Topic: Filling the database on remote server from different places (Read 200 times) previous topic - next topic

tuadru

Hi everyone,

Ive made a few small modules to track the outdoor quality of the air and now Im trying to collect the data from 4-5 different places and send it to the database Ive made using xampp on remote server. Ive managed to fill the database table with the data from the module connected on the same network as the database, but am having trouble with filling the database from modules connected on different networks.
I imagined it so that every module would have its own table in the database on the remote server and fill the data from the sensors into that table.
I would appreciate all of the suggestion on how to do this.

samerou

Hello ,

could you provide the code for sending values connecting and sending values to XAMPP server ?

tuadru

Code: [Select]

#include <ESP8266WiFi.h>
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT11   // DHT 11


double hum,tem;

char ssid[] = "xxxxx";           // SSID of your home WiFi
char pass[] = "xxxxx";            // password of your home WiFi



IPAddress server(192,168,1,10);       // the fix IP address of the server
WiFiClient client;
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(115200);               // only for debug
  WiFi.begin(ssid, pass);             // connects to the WiFi router
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  dht.begin();
 
}

void loop () {
  client.connect(server, 80);   // Connection to the server
 
  hum = dht.readHumidity();
  tem = dht.readTemperature();
  float fah = dht.readTemperature(true); //reading the temperature in Fahrenheit
  float heat_index = dht.computeHeatIndex(fah, hum); //Reading the heat index in Fahrenheit
  float heat_indexC = dht.convertFtoC(heat_index); //Converting the heat index in Celsius

if(!isnan(hum)){
Serial.println("connected");
client.print("GET /ethernet/data.php?"); //Connecting and Sending values to database
client.print("temperature=");
client.print(tem);
client.print("&humidity=");
client.print(hum);
client.print("&heat_index=");
client.println(heat_indexC);

//Printing the values on the serial monitor
Serial.print("Temperature= ");
Serial.println(tem);
Serial.print("Humidity= ");
Serial.println(hum);
Serial.print("Heat Index= ");
Serial.println(heat_indexC);
client.stop(); //Closing the connection

delay(10000);}
}


This is the code from the Arduino side of things

PaulS

The IP address of the server (IPAddress server(192,168,1,10); ) is that of a machine in a local area network.

That machine needs a public facing IP address, and that is the IP address (and port, if not 80) that you use on the Arduinos. Then, you can connect to it from any machine on any local area network.
The art of getting good answers lies in asking good questions.

tuadru

Yeah its of a machine in local area network. Ok will try and do that.

PaulS

Yeah its of a machine in local area network. Ok will try and do that.
Your Internet Service Provider may, or may not, like you running a server on their network.

Most ISPs dynamically assign your router an IP address that changes frequently. That has almost no impact on your outgoing packets, and they contain the necessary routing information so that a server can reply to you when you make a GET request. But, it means that your server has a new address every few days (or hours). Having your ISP assign you a fixed address generally means that you pay more. Sometimes a LOT more.
The art of getting good answers lies in asking good questions.

Go Up