I am very interesses in your database logging code. Can you please share with us?
Hi c70070540,
the code is very simple. this is how i did it.
1. Create a table with a site id, time stamp, an inverter nummer, and all the measurement values you may have.
2. Create a stored procedure with the the values as parameters.
3. Think of some time loop to get the values from the inverter socket, connect to sql and call the stored procedure with parms filled. Quit easy and simple to me, figuring out the inverters protocol (sniffer) is a different ball game ...
This can all be done using the free express version for SQL, C#, or VB, or whatever is out there and you prefer to use.
This is all done using the full fx, as already said, no netduino or any mcu used .... except the one in a very small pc with only 6Watt of power consumption running WindowsServer
For the code after some preps in the end it is quit simple
static void StoreValues(string[] Values)
{
SqlConnection conn = new SqlConnection();
try
{
// Get DB open
conn.ConnectionString = "Server=<your-server>\\<your-instance>;Database=<your-db>;User=<your-user>;";
conn.Open();
// Fixed for now
string mClient = "AK16";
string mDate = DateTime.Now.ToString("yyyy-MM-dd");
string mTime = DateTime.Now.ToString("HH:mm:ss");
// Build command
SqlCommand cmd = new SqlCommand("spSputnikInverterValuesUpdateInsert", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
SqlParameter prmClient = cmd.Parameters.Add("@mClient", System.Data.SqlDbType.NVarChar);
prmClient.Direction = System.Data.ParameterDirection.Input;
prmClient.Value = mClient;
SqlParameter prmDate = cmd.Parameters.Add("@mDate", System.Data.SqlDbType.NVarChar);
prmDate.Direction = System.Data.ParameterDirection.Input;
prmDate.Value = mDate;
SqlParameter prmTime = cmd.Parameters.Add("@mTime", System.Data.SqlDbType.NVarChar);
prmTime.Direction = System.Data.ParameterDirection.Input;
prmTime.Value = mTime;
SqlParameter prmAdr = cmd.Parameters.Add("@ADR", System.Data.SqlDbType.NVarChar);
prmAdr.Direction = System.Data.ParameterDirection.Input;
prmAdr.Value = Values[0].Substring(Values[0].IndexOf("=") + 1);
SqlParameter prmTyp = cmd.Parameters.Add("@TYP", System.Data.SqlDbType.NVarChar);
prmTyp.Direction = System.Data.ParameterDirection.Input;
prmTyp.Value = Values[1].Substring(Values[1].IndexOf("=") + 1);
SqlParameter prmPAC = cmd.Parameters.Add("@PAC", System.Data.SqlDbType.NVarChar);
prmPAC.Direction = System.Data.ParameterDirection.Input;
prmPAC.Value = Values[2].Substring(Values[2].IndexOf("=") + 1);
SqlParameter prmTKK = cmd.Parameters.Add("@TKK", System.Data.SqlDbType.NVarChar);
prmTKK.Direction = System.Data.ParameterDirection.Input;
prmTKK.Value = Values[3].Substring(Values[3].IndexOf("=") + 1);
SqlParameter prmPRL = cmd.Parameters.Add("@PRL", System.Data.SqlDbType.NVarChar);
prmPRL.Direction = System.Data.ParameterDirection.Input;
prmPRL.Value = Values[4].Substring(Values[4].IndexOf("=") + 1);
SqlParameter prmKHR = cmd.Parameters.Add("@KHR", System.Data.SqlDbType.NVarChar);
prmKHR.Direction = System.Data.ParameterDirection.Input;
prmKHR.Value = Values[5].Substring(Values[5].IndexOf("=") + 1);
SqlParameter prmPDC = cmd.Parameters.Add("@PDC", System.Data.SqlDbType.NVarChar);
prmPDC.Direction = System.Data.ParameterDirection.Input;
prmPDC.Value = Values[6].Substring(Values[6].IndexOf("=") + 1);
SqlParameter prmUDC = cmd.Parameters.Add("@UDC", System.Data.SqlDbType.NVarChar);
prmUDC.Direction = System.Data.ParameterDirection.Input;
prmUDC.Value = Values[7].Substring(Values[7].IndexOf("=") + 1);
SqlParameter prmIDC = cmd.Parameters.Add("@IDC", System.Data.SqlDbType.NVarChar);
prmIDC.Direction = System.Data.ParameterDirection.Input;
prmIDC.Value = Values[8].Substring(Values[8].IndexOf("=") + 1);
SqlParameter prmKDY = cmd.Parameters.Add("@KDY", System.Data.SqlDbType.NVarChar);
prmKDY.Direction = System.Data.ParameterDirection.Input;
prmKDY.Value = Values[9].Substring(Values[9].IndexOf("=") + 1);
SqlParameter prmKMT = cmd.Parameters.Add("@KMT", System.Data.SqlDbType.NVarChar);
prmKMT.Direction = System.Data.ParameterDirection.Input;
prmKMT.Value = Values[10].Substring(Values[10].IndexOf("=") + 1);
SqlParameter prmKYR = cmd.Parameters.Add("@KYR", System.Data.SqlDbType.NVarChar);
prmKYR.Direction = System.Data.ParameterDirection.Input;
prmKYR.Value = Values[11].Substring(Values[11].IndexOf("=") + 1);
SqlParameter prmKTO = cmd.Parameters.Add("@KTO", System.Data.SqlDbType.NVarChar);
prmKTO.Direction = System.Data.ParameterDirection.Input;
prmKTO.Value = Values[12].Substring(Values[12].IndexOf("=") + 1);
//
cmd.ExecuteNonQuery();
}
catch (Exception)
{
;
}
finally
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
conn.Dispose();
}
}
}
And some results:
For day April 3rd, 2012
For March 2012
And some other graphs
Have fun with it ...
Groetjes,
Peter.