Hi,
I am working on one project. It should be some type of attendance system with arduino uno, ethernet shield, rfid rc-522 reader for nfc cards, and solenoid lock.
It should work as follows:
reading an uid of an nfc card
sending uid to verify to server
if uid is in the server the lock will open for a few seconds
if lock opens the time of open is written in database
But i have a problem connecting ethernet shield to database. Database is situated on localhost (xampp) for now. All php codes are working i have tested them.
Is there anyone who could help?
Thanks and have a great day
Have you tried some sketch that makes some simple internet connection? Is there no diagnostic or error information that you can show us or tell us about?
Tell us about all the things you have tried, and what happened.
I have tried different variations of the code with same core (connecting - verification - action). I have also tried some cutted codes only for successfull connection. None of them was working.
The ethernet shield is connected to the network and have also obtained an ip address with no problem.
I'm aware that the codes can look catastrophic and with a lot of errors, but I'm still a newbie.
For example:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 100);
EthernetClient client;
void setup() {
Ethernet.begin(mac, ip);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect("192.168.1.100", 80)) {
Serial.println("connected");
client.println("GET / HTTP/1.1");
client.println("Host: 192.168.1.100");
} else {
Serial.println("connection failed");
}
}
void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
You know, but we don't. If you don't know, better test it again on your hardware to be sure. I don't see any attempt to connect or upload to a database there, though... so that would explain why it doesn't connect. That one only connects to a host. No more.
ou you mean that, no i havent tried that because i couldnt connect to databese in the very first code. there was a serial prints and conditions similar to the second one but the result were the same. i will try to find it but not sure, if not i will try to make a new one.