lakindu93 wrote:?? PC ???? ????? host ???? ????? mysql database server (local database ????), EFcom GPRS/GSM shield ?? ???????? ???? access ????? ??????? ?? ??????? ??? ?????? ?????? ???? idea ???? ????????...
Directly.
First you need to shift your database server into your DMZ zone and then enable it for the world.
Then you need to forward the mysql port in your router. Probably your router would support this option with a nice web based router GUI.
Then your ardino directly connect to that server using that connection.
Code: Select all
/**
* Example: Hello, MySQL!
*
* This code module demonstrates how to create a simple
* database-enabled sketch.
*/
#include "SPI.h"
#include "Ethernet.h"
#include "sha1.h"
#include "mysql.h"
/* Setup for Ethernet Library */
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(10, 0, 1, 23);
/* Setup for the Connector/Arduino */
Connector my_conn; // The Connector/Arduino reference
char user[] = "root";
char password[] = "secret";
char INSERT_SQL[] =
"INSERT INTO test_arduino.hello VALUES ('Hello, MySQL!', NULL)";
void setup() {
Ethernet.begin(mac_addr);
Serial.begin(115200);
delay(1000);
Serial.println("Connecting...");
if (my_conn.mysql_connect(server_addr, 3306, user, password))
{
delay(500);
/* Write Hello, World to MySQL table test_arduino.hello */
my_conn.cmd_query(INSERT_SQL);
Serial.println("Query Success!");
}
else
Serial.println("Connection failed.");
}
void loop() {
}
There is another way to do this using a web service or HTTP front end. In that way they
are using "onewire" library.In that way you don't need to do port forwarding or risk your database zone in
a DMZ zone.
src:
http://drcharlesbell.blogspot.com/2013/ ... ino_6.html
If this is a short range application like solar plant monitoring , then why didn't you use ethernet or wifi
instead.Wi fi is long term beneficial. And remind you something, sometimes you may need to save your readings
in a SD card like thing in a case where connection is loss or server down. My friend who implemented a solar based
monitoring client have done that, don't know how. But don't assume you have fancy things like sqlite things in
ardino because even sqlite is very large to be implemented on AVR microcontroller. If android or RPI then you could
definitely use MYSQLite.