From dfcbbb5a99dd6caeb4480b88ceea83414a5ff6e9 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:17:36 +0200 Subject: [PATCH 1/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93adffe..f71f710 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Code info -SD card can be removed to load data to PC at anytime. However, if the hour value changes, a log will be missed. So it's best to remove the SD card a few minutes into an hour and return within the hour. --The data log text layout is (Hour:Minute, Day/Month, Volts, Watts, TotalWattHours). +-The data log text layout is (Hour:Minute; Day/Month/Year; Volts, Watts, totalWattHours). Calibrate Voltage Sensor - Read the raw volt value with no current draw, this is the offset value. From 7c485d9b0c0405a8ff2a210dcae4ee995a7793c9 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:18:31 +0200 Subject: [PATCH 2/9] Delete Solar Logger Code --- Solar Logger Code | 278 ---------------------------------------------- 1 file changed, 278 deletions(-) delete mode 100644 Solar Logger Code diff --git a/Solar Logger Code b/Solar Logger Code deleted file mode 100644 index 3ded62a..0000000 --- a/Solar Logger Code +++ /dev/null @@ -1,278 +0,0 @@ -#include -#include - -////////// Inputs ////////// -int VoltPin = 15; -int AmpPin = 14; -int ResetPin = 1; //Digital -int Reset; - - -////////// Variables ////////// -double Volts; -double Amps; -double Watts = 0; -double WattsAvg = 0; -double WattsSum = 0; -double WattHours = 0; -double TotalWattHours = 0; -double PrevWattHours = 0; -double TotalKiloWattHours = 0; - -int Currentsecond; -int Currentminute; -int Currenthour; -int Currentday; -int Currentmonth; -int Currentyear; -int Previoussecond; -int Previousminute; -int Prevhour; -unsigned long CurrentTime; -unsigned long PrevTime; - -//Library for the Display -#include -#include - -LiquidCrystal_I2C lcd(0x27,20, 4); - -#include -const int chipSelect = BUILTIN_SDCARD; - - - - -void setup() { - - Serial.begin(115200); - - //Wire.begin(); - Wire.setSDA(18); - Wire.setSCL(19); - - pinMode(1, INPUT_PULLUP); - - -////////// Initialize the lcd ////////// - lcd.init(); - lcd.backlight(); - - lcd.setCursor(4,1); - lcd.print("SOLAR LOGGER"); - - delay(2000); - lcd.clear(); - -////////// Time & Date Set ////////// - setTime(15, 00, 0, 26, 7, 2019); // Hour Minute Second Day Month Year - - -} - - - - -void loop() { -////////// Time & Date ////////// - Currentsecond = second(); - Currentminute = minute(); - Currenthour = hour(); - Currentday = day(); - Currentmonth = month(); - Currentyear = year(); - - CurrentTime = millis(); - -////////// Measurements ////////// - Volts = (analogRead(VoltPin)-2)*0.0161; // (Raw volt value - Offset)*multiplier - //Volts = analogRead(A0); // Read raw volt value - Amps = (analogRead(A0)-761)*0.082; // (Raw amp value - Offset)*multiplier - //Amps = analogRead(A0); // Read raw amp value - - Watts = Volts * Amps; - - if(Amps < 0){ - Watts = 0; - } - - - if((CurrentTime-PrevTime) < 0){ - Watts = 0; - } - - WattHours = WattHours + Watts * ((CurrentTime - PrevTime) * 0.000000277); - TotalWattHours = (TotalWattHours + Watts * ((CurrentTime - PrevTime) * 0.000000277)); - TotalKiloWattHours = TotalWattHours * 0.001; - - PrevTime = CurrentTime; - - if(millis() > 4294967000){ - PrevTime = 0; - - } - Reset = digitalRead(1); - if(Reset == LOW){ - WattHours = 0; - } - -////////// LCD ////////// -if(Currentsecond != Previoussecond){ -// First line - lcd.setCursor(1, 0); // (column, line) - lcd.print(Volts, 2); - lcd.setCursor(5, 0); - lcd.print("V"); - lcd.setCursor(8, 0); - lcd.print(Amps, 2); - lcd.setCursor(12, 0); - lcd.print("A "); - - if(Watts > 100){ - lcd.setCursor(15, 0); - lcd.print(Watts, 0); - } - if(Watts > 10 && Watts < 100){ - lcd.setCursor(15, 0); - lcd.print(" "); - lcd.print(Watts, 0); - } - if(Watts < 10){ - lcd.setCursor(15, 0); - lcd.print(" "); - lcd.print(Watts, 0); - } - - - - lcd.setCursor(18, 0); - lcd.print("W "); - -// Second line - lcd.setCursor(3, 1); - lcd.print("Energy"); - lcd.setCursor(11, 1); - lcd.print(WattHours); - lcd.setCursor(14, 1); - lcd.print("Wh"); - - -// Third line - lcd.setCursor(3, 2); - lcd.print("Total"); - lcd.setCursor(10, 2); - lcd.print(TotalKiloWattHours, 2); - lcd.setCursor(13, 2); - lcd.print("kWh"); - - -// Fourth line - if(Currenthour < 10){ - lcd.setCursor(1, 3); - lcd.print("0"); - lcd.print(Currenthour); - } - else{ - lcd.setCursor(1, 3); - lcd.print(Currenthour); - } - lcd.setCursor(3, 3); - lcd.print(":"); - if(Currentminute < 10){ - lcd.setCursor(4, 3); - lcd.print("0"); - lcd.print(Currentminute); - } - else{ - lcd.setCursor(4, 3); - lcd.print(Currentminute); - } - if(Currentday < 10){ - lcd.setCursor(9, 3); - lcd.print("0"); - lcd.print(Currentday); - } - else{ - lcd.setCursor(9, 3); - lcd.print(Currentday); - } - lcd.setCursor(11, 3); - lcd.print("/"); - if(Currentmonth < 10){ - lcd.setCursor(12, 3); - lcd.print("0"); - lcd.print(Currentmonth); - } - else{ - lcd.setCursor(12, 3); - lcd.print(Currentmonth); - } - lcd.setCursor(14, 3); - lcd.print("/"); - lcd.setCursor(15, 3); - lcd.print(Currentyear); - - Previoussecond = Currentsecond; -} -////////// SD Card ////////// - if(Currenthour != Prevhour){ - - WattsAvg = TotalWattHours - PrevWattHours; - PrevWattHours = TotalWattHours; - - SD.begin(chipSelect); - - String dataString = ""; - dataString += String(Currenthour); - dataString += ":"; - dataString += String(Currentminute); - dataString += ","; - dataString += String(Currentday); - dataString += "/"; - dataString += String(Currentmonth); - dataString += ","; - dataString += String(Volts); - dataString += ","; - dataString += String(WattsAvg); - dataString += ","; - dataString += String(TotalWattHours); - dataString += ","; - - File dataFile = SD.open("SOLARLOG.txt", FILE_WRITE); - - if (dataFile) { - dataFile.println(dataString); - dataFile.close(); - Serial.println(dataString); - } - else { - Serial.println("error opening datalog.txt"); - } - - Previousminute = Currentminute; - Prevhour = Currenthour; - } - -////////// Serial ////////// -/* -Serial.print("Time: "); -Serial.print(CurrentHour); -Serial.print(":"); -Serial.print(Currentminute); -Serial.print(" Date: "); -Serial.print(Currentday); -Serial.print("/"); -Serial.print(Currentmonth); -Serial.print("/"); -Serial.print(Currentyear); -Serial.print(" Volts: "); -Serial.print(Volts); -Serial.print(" Amps: "); -Serial.print(Amps); -Serial.print(" Watts: "); -Serial.print(Watts); -Serial.println(); -*/ - -delay(20); -} From ca182b02f5fba0aaac801721f7c108c5de95f2cf Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:20:12 +0200 Subject: [PATCH 3/9] Add files via upload --- firmware/Solar_Logger/Solar_Logger.ino | 205 +++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 firmware/Solar_Logger/Solar_Logger.ino diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino new file mode 100644 index 0000000..bff4a38 --- /dev/null +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -0,0 +1,205 @@ +/*=============LIBRARIES=============*/ +#include +#include //parses PCs time + +#include +#include +LiquidCrystal_I2C lcd(0x27, 20, 4); + +#include +const int chipSelect = BUILTIN_SDCARD; + +/*======PINS======*/ +#define VOLT_PIN 15 +#define AMP_PIN 14 +#define RST_PIN 1 +#define SDA_PIN 18 +#define SCL_PIN 19 + +/*======VARIABLES======*/ +float volts; +float amps; +float watts; +float wattsAvg; +float wattsSum; +float wattHours; +float totalWattHours; +float prevWattHours; +float totalKWhHours; + +byte currentSecond, prevSecond; +unsigned long currentTime, prevTime; +byte prevMinute, prevHour; + +void setup() { + /*===========RESET===========*/ + pinMode(RST_PIN, INPUT_PULLUP); + + /*===========LCD===========*/ + //Wire.begin(); + Wire.setSDA(SDA_PIN); + Wire.setSCL(SCL_PIN); + + lcd.init(); + lcd.backlight(); + + lcd.setCursor(4, 1); + lcd.print(F("SOLAR LOGGER")); + + delay(2000); + lcd.clear(); + + /*=============================TIME & DATE SET=============================*/ + setTime(BUILD_HOUR, BUILD_MIN, BUILD_SEC, BUILD_DAY, BUILD_MONTH, BUILD_YEAR); +} + +void loop() { + + /*=====TIME & DATE=====*/ + currentSecond = second(); + currentTime = millis(); + + /*==================MEASUREMENTS=================*/ + volts = (float)(analogRead(VOLT_PIN) - 2) * 0.0161; // (Raw volt value - offset) * multiplier + //volts = (float)analogRead(VOLT_PIN); // Read raw volt value + amps = (float)(analogRead(AMP_PIN) - 761) * 0.082; // (Raw amp value - offset) * multiplier + //amps = (float)analogRead(VOLT_PIN); // Read raw amp value + watts = (float)volts * amps; + + if (amps < 0) { + watts = 0.0; + } + + if ((currentTime - prevTime) < 0) { + watts = 0.0; + } + + /*======================================CALCULATIONS======================================*/ + wattHours = (float)wattHours + watts * ((currentTime - prevTime) * 0.000000277); + totalWattHours = (float)(totalWattHours + watts * ((currentTime - prevTime) * 0.000000277)); + totalKWhHours = (float)totalWattHours * 0.001; + + prevTime = currentTime; + + if (currentTime > 4294967000) { + prevTime = 0; + } + + /*=============RESET=============*/ + if (digitalRead(RST_PIN) == LOW) { + wattHours = 0.0; + } + + /*==============LCD==============*/ + if (currentSecond != prevSecond) { + + // First line + lcd.setCursor(1, 0); // (column, line) + lcd.print(volts, 2); + lcd.setCursor(5, 0); + lcd.print(F("V ")); + lcd.setCursor(8, 0); + lcd.print(amps, 2); + lcd.setCursor(12, 0); + lcd.print(F("A ")); + + lcd.setCursor(15, 0); + if (watts > 10 && watts < 100) { + lcd.print(F(" ")); + } + else if (watts < 10) { + lcd.print(F(" ")); + } + lcd.print(watts, 0); + lcd.setCursor(18, 0); + lcd.print(F("W ")); + + // Second line + lcd.setCursor(3, 1); + lcd.print(F("Energy")); + lcd.setCursor(11, 1); + lcd.print(wattHours); + lcd.setCursor(14, 1); + lcd.print(F("Wh")); + + // Third line + lcd.setCursor(3, 2); + lcd.print(F("Total")); + lcd.setCursor(10, 2); + lcd.print(totalKWhHours, 2); + lcd.setCursor(13, 2); + lcd.print(F("kWh")); + + // Fourth line + lcd.setCursor(1, 3); + if (hour() < 10) { + lcd.print(F("0")); + } + lcd.print(hour()); + + lcd.print(F(":")); + + lcd.setCursor(4, 3); + if (minute() < 10) { + lcd.print(F("0")); + } + lcd.print(minute()); + + lcd.setCursor(9, 3); + if (day() < 10) { + lcd.print(F("0")); + } + lcd.print(day()); + + lcd.setCursor(11, 3); + lcd.print(F("/")); + + lcd.setCursor(12, 3); + if (month() < 10) { + lcd.print(F("0")); + } + lcd.print(month()); + + lcd.setCursor(14, 3); + lcd.print(F("/")); + lcd.setCursor(15, 3); + lcd.print(year()); + + prevSecond = currentSecond; + } + + /*==============SD==============*/ + if (hour() != prevHour) { + + wattsAvg = totalWattHours - prevWattHours; + prevWattHours = totalWattHours; + + SD.begin(chipSelect); + + String dataString = ""; + dataString += String(hour()); + dataString += F(":"); + dataString += String(minute()); + dataString += F("; "); + + dataString += String(day()); + dataString += F("/"); + dataString += String(month()); + dataString += F("/"); + dataString += String(year()); + dataString += F("; "); + + dataString += String(volts); + dataString += F(", "); + dataString += String(wattsAvg); + dataString += F(", "); + dataString += String(totalWattHours); + + File dataFile = SD.open("SOLARLOG.txt", FILE_WRITE); + + prevMinute = minute(); + prevHour = hour(); + } + + delay(20); +} From 256ccd8b289a872264278e957610aac3be828792 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:23:00 +0200 Subject: [PATCH 4/9] Add files via upload --- lib/buildTime/buildTime.h | 66 ++++++++++++++++++++ lib/buildTime/examples/timeTest/timeTest.ino | 25 ++++++++ lib/buildTime/keywords.txt | 23 +++++++ lib/buildTime/library.properties | 9 +++ 4 files changed, 123 insertions(+) create mode 100644 lib/buildTime/buildTime.h create mode 100644 lib/buildTime/examples/timeTest/timeTest.ino create mode 100644 lib/buildTime/keywords.txt create mode 100644 lib/buildTime/library.properties diff --git a/lib/buildTime/buildTime.h b/lib/buildTime/buildTime.h new file mode 100644 index 0000000..dc1f381 --- /dev/null +++ b/lib/buildTime/buildTime.h @@ -0,0 +1,66 @@ +// Парсинг и получение даты и времени компиляции из __DATE__ и __TIME__ +// Исходник http://qaru.site/questions/186859/how-to-use-date-and-time-predefined-macros-in-as-two-integers-then-stringify +// Допилено by AlexGyver +// Версия 1.0 + +#ifndef BUILD_DEFS_H +#define BUILD_DEFS_H +// Example of __DATE__ string: "Jul 27 2012" +// 01234567890 + +#define BUILD_YEAR_CH0 (__DATE__[7]-'0') +#define BUILD_YEAR_CH1 (__DATE__[8]-'0') +#define BUILD_YEAR_CH2 (__DATE__[9]-'0') +#define BUILD_YEAR_CH3 (__DATE__[10]-'0') +#define BUILD_YEAR (BUILD_YEAR_CH0*1000+BUILD_YEAR_CH1*100 + BUILD_YEAR_CH2*10+BUILD_YEAR_CH3) + +#define BUILD_MONTH_IS_JAN (__DATE__[0] == 'J' && __DATE__[1] == 'a' && __DATE__[2] == 'n') +#define BUILD_MONTH_IS_FEB (__DATE__[0] == 'F') +#define BUILD_MONTH_IS_MAR (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'r') +#define BUILD_MONTH_IS_APR (__DATE__[0] == 'A' && __DATE__[1] == 'p') +#define BUILD_MONTH_IS_MAY (__DATE__[0] == 'M' && __DATE__[1] == 'a' && __DATE__[2] == 'y') +#define BUILD_MONTH_IS_JUN (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'n') +#define BUILD_MONTH_IS_JUL (__DATE__[0] == 'J' && __DATE__[1] == 'u' && __DATE__[2] == 'l') +#define BUILD_MONTH_IS_AUG (__DATE__[0] == 'A' && __DATE__[1] == 'u') +#define BUILD_MONTH_IS_SEP (__DATE__[0] == 'S') +#define BUILD_MONTH_IS_OCT (__DATE__[0] == 'O') +#define BUILD_MONTH_IS_NOV (__DATE__[0] == 'N') +#define BUILD_MONTH_IS_DEC (__DATE__[0] == 'D') + +#define BUILD_MONTH \ + ( \ + (BUILD_MONTH_IS_JAN) ? 1 : \ + (BUILD_MONTH_IS_FEB) ? 2 : \ + (BUILD_MONTH_IS_MAR) ? 3 : \ + (BUILD_MONTH_IS_APR) ? 4 : \ + (BUILD_MONTH_IS_MAY) ? 5 : \ + (BUILD_MONTH_IS_JUN) ? 6 : \ + (BUILD_MONTH_IS_JUL) ? 7 : \ + (BUILD_MONTH_IS_AUG) ? 8 : \ + (BUILD_MONTH_IS_SEP) ? 9 : \ + (BUILD_MONTH_IS_OCT) ? 10 : \ + (BUILD_MONTH_IS_NOV) ? 11 : \ + (BUILD_MONTH_IS_DEC) ? 12 : \ + /* error default */ '?' \ + ) + +#define BUILD_DAY_CH0 (((__DATE__[4] >= '0') ? (__DATE__[4]) : '0')-'0') +#define BUILD_DAY_CH1 (__DATE__[5]-'0') +#define BUILD_DAY (BUILD_DAY_CH0*10+BUILD_DAY_CH1) + +// Example of __TIME__ string: "21:06:19" +// 01234567 + +#define BUILD_HOUR_CH0 (__TIME__[0]-'0') +#define BUILD_HOUR_CH1 (__TIME__[1]-'0') +#define BUILD_HOUR (BUILD_HOUR_CH0*10+BUILD_HOUR_CH1) + +#define BUILD_MIN_CH0 (__TIME__[3]-'0') +#define BUILD_MIN_CH1 (__TIME__[4]-'0') +#define BUILD_MIN (BUILD_MIN_CH0*10+BUILD_MIN_CH1) + +#define BUILD_SEC_CH0 (__TIME__[6]-'0') +#define BUILD_SEC_CH1 (__TIME__[7]-'0') +#define BUILD_SEC (BUILD_SEC_CH0*10+BUILD_SEC_CH1) + +#endif // BUILD_DEFS_H \ No newline at end of file diff --git a/lib/buildTime/examples/timeTest/timeTest.ino b/lib/buildTime/examples/timeTest/timeTest.ino new file mode 100644 index 0000000..559a97f --- /dev/null +++ b/lib/buildTime/examples/timeTest/timeTest.ino @@ -0,0 +1,25 @@ +// тест получения времени и даты компиляции + +#include "buildTime.h" +void setup() { + Serial.begin(9600); + Serial.println(__DATE__); + Serial.println(__TIME__); + Serial.println(); + + Serial.print(BUILD_YEAR); + Serial.print(" "); + Serial.print(BUILD_MONTH); + Serial.print(" "); + Serial.println(BUILD_DAY); + + Serial.print(BUILD_HOUR); + Serial.print(":"); + Serial.print(BUILD_MIN); + Serial.print(":"); + Serial.println(BUILD_SEC); +} + +void loop() { + +} diff --git a/lib/buildTime/keywords.txt b/lib/buildTime/keywords.txt new file mode 100644 index 0000000..a034297 --- /dev/null +++ b/lib/buildTime/keywords.txt @@ -0,0 +1,23 @@ +####################################### +# Syntax Coloring Map For buildTime +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### +buildTime KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + + +####################################### +# Constants (LITERAL1) +####################################### +BUILD_YEAR LITERAL1 +BUILD_MONTH LITERAL1 +BUILD_DAY LITERAL1 +BUILD_HOUR LITERAL1 +BUILD_MIN LITERAL1 +BUILD_SEC LITERAL1 \ No newline at end of file diff --git a/lib/buildTime/library.properties b/lib/buildTime/library.properties new file mode 100644 index 0000000..2e9e65e --- /dev/null +++ b/lib/buildTime/library.properties @@ -0,0 +1,9 @@ +name=buildTime +version=1.0 +author=AlexGyver +maintainer=AlexGyver +sentence=Library will help you get compile time. +paragraph=Very light and easy to use. +category=Timing +url=https://github.com/AlexGyver/GyverLibs +architectures=* \ No newline at end of file From 7da62a4907848abcab1b4e30dc870521eb1cd871 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:23:26 +0200 Subject: [PATCH 5/9] Update Solar_Logger.ino --- firmware/Solar_Logger/Solar_Logger.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino index bff4a38..f2a6272 100644 --- a/firmware/Solar_Logger/Solar_Logger.ino +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -1,6 +1,6 @@ /*=============LIBRARIES=============*/ #include -#include //parses PCs time +#include "buildTime.h"//parses PCs time #include #include From 263b06a09ff97e08e831c7e42d60634b45a7b214 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:32:57 +0200 Subject: [PATCH 6/9] Update Solar_Logger.ino --- firmware/Solar_Logger/Solar_Logger.ino | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino index f2a6272..01ef350 100644 --- a/firmware/Solar_Logger/Solar_Logger.ino +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -1,3 +1,9 @@ +/*==========SETTINGS==========*/ +#define VOLT_OFFSET 2 +#define VOLT_MULTIPLIER 0.0161 +#define AMP_OFFSET 761 +#define AMP_MULTIPLIER 0.001 + /*=============LIBRARIES=============*/ #include #include "buildTime.h"//parses PCs time @@ -59,11 +65,11 @@ void loop() { currentSecond = second(); currentTime = millis(); - /*==================MEASUREMENTS=================*/ - volts = (float)(analogRead(VOLT_PIN) - 2) * 0.0161; // (Raw volt value - offset) * multiplier - //volts = (float)analogRead(VOLT_PIN); // Read raw volt value - amps = (float)(analogRead(AMP_PIN) - 761) * 0.082; // (Raw amp value - offset) * multiplier - //amps = (float)analogRead(VOLT_PIN); // Read raw amp value + /*============================MEASUREMENTS===========================*/ + volts = (float)(analogRead(VOLT_PIN) - VOLT_OFFSET) * VOLT_MULTIPLIER; // (Raw volt value - offset) * multiplier + //volts = (float)analogRead(VOLT_PIN); // Read raw volt value + amps = (float)(analogRead(AMP_PIN) - AMP_OFFSET) * AMP_MULTIPLIER; // (Raw amp value - offset) * multiplier + //amps = (float)analogRead(VOLT_PIN); // Read raw amp value watts = (float)volts * amps; if (amps < 0) { From 0e7bef4fa881098c7bc4e4f848864a05e03996fd Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Fri, 25 Dec 2020 14:38:08 +0200 Subject: [PATCH 7/9] Update Solar_Logger.ino --- firmware/Solar_Logger/Solar_Logger.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino index 01ef350..859859f 100644 --- a/firmware/Solar_Logger/Solar_Logger.ino +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -122,7 +122,7 @@ void loop() { // Second line lcd.setCursor(3, 1); - lcd.print(F("Energy")); + lcd.print(F("Energy ")); lcd.setCursor(11, 1); lcd.print(wattHours); lcd.setCursor(14, 1); From 884335e82f57d3411f04a8cc60eb4974d513be97 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Wed, 30 Dec 2020 11:56:40 +0200 Subject: [PATCH 8/9] Update Solar_Logger.ino --- firmware/Solar_Logger/Solar_Logger.ino | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino index 859859f..0c6bfe6 100644 --- a/firmware/Solar_Logger/Solar_Logger.ino +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -54,6 +54,9 @@ void setup() { delay(2000); lcd.clear(); + + /*========SD========*/ + SD.begin(chipSelect); /*=============================TIME & DATE SET=============================*/ setTime(BUILD_HOUR, BUILD_MIN, BUILD_SEC, BUILD_DAY, BUILD_MONTH, BUILD_YEAR); @@ -67,9 +70,9 @@ void loop() { /*============================MEASUREMENTS===========================*/ volts = (float)(analogRead(VOLT_PIN) - VOLT_OFFSET) * VOLT_MULTIPLIER; // (Raw volt value - offset) * multiplier - //volts = (float)analogRead(VOLT_PIN); // Read raw volt value + //volts = analogRead(VOLT_PIN); // Read raw volt value amps = (float)(analogRead(AMP_PIN) - AMP_OFFSET) * AMP_MULTIPLIER; // (Raw amp value - offset) * multiplier - //amps = (float)analogRead(VOLT_PIN); // Read raw amp value + //amps = analogRead(VOLT_PIN); // Read raw amp value watts = (float)volts * amps; if (amps < 0) { @@ -87,7 +90,7 @@ void loop() { prevTime = currentTime; - if (currentTime > 4294967000) { + if (currentTime >= 4294967000) { prevTime = 0; } @@ -180,8 +183,6 @@ void loop() { wattsAvg = totalWattHours - prevWattHours; prevWattHours = totalWattHours; - SD.begin(chipSelect); - String dataString = ""; dataString += String(hour()); dataString += F(":"); From 55c863e92482260cc1e14692d7680b0597df4055 Mon Sep 17 00:00:00 2001 From: vitaliy172 <68148475+vitaliy172@users.noreply.github.com> Date: Wed, 30 Dec 2020 12:06:51 +0200 Subject: [PATCH 9/9] Update Solar_Logger.ino --- firmware/Solar_Logger/Solar_Logger.ino | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/firmware/Solar_Logger/Solar_Logger.ino b/firmware/Solar_Logger/Solar_Logger.ino index 0c6bfe6..74d40ad 100644 --- a/firmware/Solar_Logger/Solar_Logger.ino +++ b/firmware/Solar_Logger/Solar_Logger.ino @@ -1,4 +1,5 @@ /*==========SETTINGS==========*/ +//read README.md to calibrate properly #define VOLT_OFFSET 2 #define VOLT_MULTIPLIER 0.0161 #define AMP_OFFSET 761 @@ -13,7 +14,6 @@ LiquidCrystal_I2C lcd(0x27, 20, 4); #include -const int chipSelect = BUILTIN_SDCARD; /*======PINS======*/ #define VOLT_PIN 15 @@ -56,7 +56,7 @@ void setup() { lcd.clear(); /*========SD========*/ - SD.begin(chipSelect); + SD.begin(BUILTIN_SDCARD); /*=============================TIME & DATE SET=============================*/ setTime(BUILD_HOUR, BUILD_MIN, BUILD_SEC, BUILD_DAY, BUILD_MONTH, BUILD_YEAR); @@ -207,6 +207,4 @@ void loop() { prevMinute = minute(); prevHour = hour(); } - - delay(20); }