hello everyone ..
i have a problem ..
thats i trying to upload the digital output status to the sql or upload the relay status to the sql
i have read many topic talking about it ..
but i couldn't understand them ..
i mean what is the query statment in arduino programing ..
i dont wanna use php html to send data ..
ill use them to show the data ..
lets say i have something like this on my arduino software ..
int led1 = 8;
void setup()
{
pinMode(led1,OUTPUT);
}
void loop()
{
digitalWrite(led1,HIGH);
delay(1000);
digitalWrite(led1,LOW);
delay(1000);
}
how can i upload the sql table everytime the output change the status from high to low ..
like how can i write query like 'insert into tablename valuse anything'
and how can i write the connect statment like i use in php
$con = new pdo("mysql:host='localhost' dbname='databasename'",'user','pass');
or
mysql_connect(localhost,user,pass);
mysql_select_db(databasename);
what i understod that first thing i have to do is give the arduino uno ethernet shild tcp/ip data like this
#include <SPI.h>
#include <Ethernet.h>// network configuration. dns server, gateway and subnet are optional.
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };// the dns server ip
IPAddress dnServer(192, 168, 1, 1);
// the router's gateway address:
IPAddress gateway(192, 168, 1, 1);
// the subnet:
IPAddress subnet(255, 255, 255, 0);//the IP address is dependent on your network
IPAddress ip(192, 168, 1, 177);
int led = 9;
int led1 = 8;
void setup() {
pinMode(led,OUTPUT);
pinMode(led1,OUTPUT);
Serial.begin(9600);// initialize the ethernet device
Ethernet.begin(mac, ip, dnServer, gateway, subnet);
//print out the IP address
Serial.print("IP = ");
Serial.println(Ethernet.localIP());
}void loop() {
digitalWrite(led,HIGH);
delay(100);
digitalWrite(led1,HIGH);
delay(100);digitalWrite(led,LOW);
delay(100);
digitalWrite(led1,LOW);
delay(100);}
when i uploaded this code to the arduino i succeded pinging on the ip 192.168.1.177 via lan network
so anyone can help me to upload the output via sql please ..
my arduino is arduino uno ethernet shild