ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
331 stars 132 forks source link

ESP32-POE-ISO #114

Closed TeKiLLa1985 closed 2 years ago

TeKiLLa1985 commented 4 years ago

Hi, is it possible to get the MySQL Connector running on a ESP32-POE-ISO, i have compile it but i can t connect to the MariaDB.

ChuckBell commented 4 years ago

The connector is not supported for use with non-Oracle distributions of MySQL. However, many have had success running on the ESP platform. Just be sure to use an Arduino Ethernet compatible network library. See the other notes on this site for hints.

On Wed, Oct 2, 2019 at 9:13 AM TeKiLLa1985 notifications@github.com wrote:

Hi, is it possible to get the MySQL Connector running on a ESP32-POE-ISO, i have compile it but i can t connect to the MariaDB.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/114?email_source=notifications&email_token=AB6SHYFIXLCB5CLIR4XNOY3QMSNARA5CNFSM4I4WFB7KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HPD7XXA, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6SHYDX2PVPLJXXG6FE6UTQMSNARANCNFSM4I4WFB7A .

TeKiLLa1985 commented 4 years ago

So, we have made it now i can write things to my Database but one problem i can't solve i have a 4 byte input from my RFID and i bring that down to a 4 byte hex string and now i wan t to send it to my database but i have no idea how

TeKiLLa1985 commented 4 years ago

`#include

include

include

include

include

include

include

const int RST_PIN = 5; // Reset pin const int SS_PIN = 13; // Slave select pin

static bool eth_connected = false;

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

IPAddress server_addr(192, 168, 251, 130); // IP of the MySQL server here char user[] = "TEST01"; // MySQL user login username char password[] = "XXX"; // MySQL user login password

char INSERT_SQL[] = "INSERT INTO test.hello_arduino (message) VALUES ()";

void setup() { Serial.begin(9600); ETH.begin(); Serial.println("Connecting..."); while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); }

void loop() // Hier beginnt der Loop-Teil { if ( ! mfrc522.PICC_IsNewCardPresent()) // Wenn keine Karte in Reichweite ist... { return; // ...springt das Programm zurück vor die if-Schleife, womit sich die Abfrage wiederholt. } if ( ! mfrc522.PICC_ReadCardSerial()) // Wenn kein RFID-Sender ausgewählt wurde { return; // ...springt das Programm zurück vor die if-Schleife, womit sich die Abfrage wiederholt. } Serial.print("Die ID des RFID-TAGS lautet:"); // "Die ID des RFID-TAGS lautet:" wird auf den Serial Monitor geschrieben. for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i], HEX); // Dann wird die UID ausgelesen, die aus vier einzelnen Blöcken besteht und der Reihe nach an den Serial Monitor gesendet. Die Endung Hex bedeutet, dass die vier Blöcke der UID als HEX-Zahl ausgegeben wird //Serial.print(" "); // Der Befehl „Serial.print(" ");“ sorgt dafür, dass zwischen den einzelnen ausgelesenen Blöcken ein Leerzeichen steht.

} Serial.println(); // Mit dieser Zeile wird auf dem Serial Monitor nur ein Zeilenumbruch gemacht. Serial.print("\nConnecting to ");

WiFiClient client; MySQL_Connection conn((Client *)&client); if (conn.connect(server_addr, 3306, user, password)) { Serial.println("Database connected."); } else Serial.println("Connection failed."); Serial.println("Recording data.");

// Initiate the query class instance MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn); // Execute the query cur_mem->execute(INSERT_SQL); // Note: since there are no results, we do not need to read any data // Deleting the cursor also frees up memory used delete cur_mem; Serial.println("closing connection\n"); //client.stop();

}`

ChuckBell commented 4 years ago

IIRC, most of those libraries return the value as a string. Is that not the case? Regardless, all you do is format the string and store that. See sprintf().

On Wed, Oct 9, 2019 at 04:59 TeKiLLa1985 notifications@github.com wrote:

`#include

include

include

include

include

include

include

const int RST_PIN = 5; // Reset pin const int SS_PIN = 13; // Slave select pin

static bool eth_connected = false;

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

IPAddress server_addr(192, 168, 251, 130); // IP of the MySQL server here char user[] = "TEST01"; // MySQL user login username char password[] = "XXX"; // MySQL user login password

char INSERT_SQL[] = "INSERT INTO test.hello_arduino (message) VALUES ()";

void setup() { Serial.begin(9600); ETH.begin(); Serial.println("Connecting..."); while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); }

void loop() // Hier beginnt der Loop-Teil { if ( ! mfrc522.PICC_IsNewCardPresent()) // Wenn keine Karte in Reichweite ist... { return; // ...springt das Programm zurück vor die if-Schleife, womit sich die Abfrage wiederholt. } if ( ! mfrc522.PICC_ReadCardSerial()) // Wenn kein RFID-Sender ausgewählt wurde { return; // ...springt das Programm zurück vor die if-Schleife, womit sich die Abfrage wiederholt. } Serial.print("Die ID des RFID-TAGS lautet:"); // "Die ID des RFID-TAGS lautet:" wird auf den Serial Monitor geschrieben. for (byte i = 0; i < mfrc522.uid.size; i++) { Serial.print(mfrc522.uid.uidByte[i], HEX); // Dann wird die UID ausgelesen, die aus vier einzelnen Blöcken besteht und der Reihe nach an den Serial Monitor gesendet. Die Endung Hex bedeutet, dass die vier Blöcke der UID als HEX-Zahl ausgegeben wird //Serial.print(" "); // Der Befehl „Serial.print(" ");“ sorgt dafür, dass zwischen den einzelnen ausgelesenen Blöcken ein Leerzeichen steht.

} Serial.println(); // Mit dieser Zeile wird auf dem Serial Monitor nur ein Zeilenumbruch gemacht. Serial.print("\nConnecting to ");

WiFiClient client; MySQL_Connection conn((Client *)&client); if (conn.connect(server_addr, 3306, user, password)) { Serial.println("Database connected."); } else Serial.println("Connection failed."); Serial.println("Recording data.");

// Initiate the query class instance MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn); // Execute the query cur_mem->execute(INSERT_SQL); // Note: since there are no results, we do not need to read any data // Deleting the cursor also frees up memory used delete cur_mem; Serial.println("closing connection\n"); //client.stop();

}`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/114?email_source=notifications&email_token=AB6SHYHCWSOMLU7ZURY4F6LQNWMQ3A5CNFSM4I4WFB7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAXFSQQ#issuecomment-539908418, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6SHYE6TYNJLWBBS5QDIH3QNWMQ3ANCNFSM4I4WFB7A .

ChuckBell commented 2 years ago

Closed due to inactivity.