Closed mydhitz closed 2 years ago
Hello,
It sounds like two possibilities. 1) the SD card is using the same pins as the Ethernet shield, or 2) you are running out of memory.
So, I would either move to the Mega and/or examine the pins used by the SD card module and Ethernet module to see if there is a conflict. If there is, and you cannot resolve it, you should initialize the SD card using different pins (depending on the SD Card module, this may not be so easy).
Dr. Bell
On 7/5/18 3:51 AM, dito wrote:
hi dr @ChuckBell https://github.com/ChuckBell I have a question again, i have a micro sd card, and data from micro sd i will send to database mysql, i have problem when conecting to database is not work. but if conecting to my server is working. this my code conecting to mysql and using librart sd.h
`#include
include
include
include
include
//File myFile; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress server_db(10,45,1,10); IPAddress ip(10,45,1,29);
char user[] = "root"; // MySQL user login username char password[] = "dito"; // MySQL user login password
EthernetClient client;
MySQL_Connection conn((Client *)&client); MySQL_Cursor cur = MySQL_Cursor(&conn); char query[128];
void setup() { // Open serial communications and wait for port to open: Serial.begin(115200); Serial.println("Initializing SD card..."); if (!SD.begin(4)){ Serial.println("Initializing Failed"); return; } Serial.println("Memory Ok.."); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Ethernet.begin(mac, ip); // give the Ethernet shield a second to initialize: delay(1000); Serial.println("Connecting..."); /* // re-open the file for reading: myFile = SD.open("test.txt"); if (myFile) { Serial.println("test.txt:");
|// read from the file until there's nothing else in it: while (myFile.available()) { Serial.write(myFile.read()); } // close the file: myFile.close(); |
} else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); }*/ Serial.println("\n"); }
void loop() { delay(3000); Serial.println("Conecting to db.."); if (conn.connect(server_db, 3306, user, password)){ Serial.println("Connected Server DB"); Serial.println("OK"); client.stop(); } else { // if you didn't get a connection to the server: Serial.println("Disconnected DB"); } }`
conecting to databse always failed, and i try to conecting to my server and change this code: |if (client.connect(server_db, 80))| it work...
and i try again conecting to database and not using library sd.h and i remove microsd from ethernet shield it work. how to read memory card and will send to database mysql ? i use arduino uno r3 and ethernet shield, do i need change to arduino mega ? because used memory from arduino 70%
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/48, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4N5Ed4Oswwq7AXMlyU3-LYEmwS4Tks5uDcVogaJpZM4VDZ3U.
Thank you for your answer Dr. Bell.
Closed due to inactivity. Please open a new ticket if this is still relevant.
hi dr @ChuckBell i have a question again, i have a micro sd card, and data from micro sd i will send to database mysql, i have problem when connecting to database is not work if i add microsd and library sd.h to ethershield . but if connecting to my server is working and connecting to database without micro sd and library sd.h it work and connected. this my code conecting to mysql and using library sd.h
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
//File myFile;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_db(10,45,1,10);
IPAddress ip(10,45,1,29);
char user[] = "root"; // MySQL user login username
char password[] = "dito"; // MySQL user login password
EthernetClient client;
MySQL_Connection conn((Client *)&client);
MySQL_Cursor cur = MySQL_Cursor(&conn);
char query[128];
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.println("Initializing SD card...");
if (!SD.begin(4)){
Serial.println("Initializing Failed");
return;
}
Serial.println("Memory Ok..");
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Ethernet.begin(mac, ip);
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("Connecting...");
//myFile = SD.open("test.txt");
//if (myFile) {
//Serial.println("test.txt:");
//while (myFile.available()) {
//Serial.write(myFile.read());
//}
//myFile.close();
//} else {
//if the file didn't open, print an error:
//Serial.println("error opening test.txt");
//}
Serial.println("\n");
}
void loop() {
delay(3000);
Serial.println("Conecting to db..");
if (conn.connect(server_db, 3306, user, password)){
Serial.println("Connected Server DB");
Serial.println("OK");
client.stop();
}
else {
// if you didn't get a connection to the server:
Serial.println("Disconnected DB");
}
}
conecting to databse always failed, and i try to conecting to my server and change this code:
if (client.connect(server_db, 80))
it work...and i try again conecting to database and not using library sd.h and i remove microsd from ethernet shield it work. how to read memory card and will conected to database mysql ? i use arduino uno r3 and ethernet shield, do i need change to arduino mega ? because used memory from arduino 70%