I have no access to a compiler, so there might be errors.
#include <WiFiEsp.h>
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(2, 3); // RX, TX
#endif
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192,168,x,x);
char user[] = "francis";
char password[] = "xxxxxx";
char ssid[] = "PintoLoco";
char pass[] = "xxxxxxxx";
WiFiEspClient client;
MySQL_Connection conn( (Client *) &client );
MySQL_Cursor *cur_mem = null;
// PPK: some database systems are case sensitive
// so Peceras.Parameters is not the same as peceras.parameters
// check if the tables and fields are named correctly.
char query[] = "SELECT Value FROM Peceras.Parameters";
void setup()
{
Serial.begin( 115200 );
Serial1.begin( 115200 );
Serial.println( "Connecting to WiFi" );
WiFi.init( &Serial1 );
int status = WiFi.begin( ssid, pass );
while( status != WL_CONNECTED )
{
status = WiFi.begin(ssid, pass);
}
Serial.println( "Connected to network" );
IPAddress ip = WiFi.localIP();
Serial.print( "My IP address is: " );
Serial.println( ip );
Serial.println( "Connecting DB ..." );
if ( conn.connect( server_addr, 3306, user, password ) )
{
Serial.println( "DB connected." );
cur_mem = new MySQL_Cursor( &conn );
row_values *row = NULL;
long head_count = NULL;
column_names *cols = cur_mem->get_columns();
cur_mem->execute(query);
do
{
row = cur_mem->get_next_row();
if ( row != NULL )
{
for ( int f = 0; f < cols->num_fields; f++ )
{
head_count = atoi( row->values[f] );
Serial.print( "Ingestelde Temperatuur: ");
Serial.println( head_count );
if ( f < cols->num_fields - 1 )
{
Serial.println(',');
}
}
Serial.println();
}
} while (row != NULL);
// Deleting the cursor also frees up memory used
// PPK: I'm not sure if this is a good idea, I don't know
delete cur_mem;
}
else
{
Serial.println( "DB Connection failed." );
}
}
void loop()
{
// PPK: I would recommend to do the select in the setup section
// It looks like you want to run it just once
}