EEPROM SmallRoom

This commit is contained in:
2020-12-03 19:30:03 +03:00
parent 73615da0f1
commit 297f4be45d
2 changed files with 6 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ framework = arduino
board_build.ldscript = eagle.flash.1m.ld board_build.ldscript = eagle.flash.1m.ld
board_build.f_cpu = 26000000L board_build.f_cpu = 26000000L
upload_protocol = espota upload_protocol = espota
upload_port = 192.168.1.7 upload_port = 192.168.1.148
lib_deps = lib_deps =
Adafruit HTU21DF Library @ ^1.1.0 Adafruit HTU21DF Library @ ^1.1.0
PubSubClient @ ^2.8 PubSubClient @ ^2.8

View File

@@ -32,7 +32,7 @@ unsigned long cRun;
int minCnt = 0; int minCnt = 0;
int measCnt = 1; int measCnt = 1;
uint8_t mv, oldmv; uint8_t mv, oldmv;
int adc, oldadc, delta; uint16_t adc, oldadc, delta;
void reconnect(); void reconnect();
void publishMin(); void publishMin();
@@ -205,7 +205,7 @@ void publishSec()
client.publish("/hometest/smallroom/millis", strFVal); client.publish("/hometest/smallroom/millis", strFVal);
ltoa(adc, strFVal, 10); ltoa(adc, strFVal, 10);
client.publish("/hometest/smallroom/light", strFVal); client.publish("/hometest/smallroom/light", strFVal);
ultoa(delta, strFVal, 10); itoa(delta, strFVal, 10);
client.publish("/hometest/smallroom/ldelta", strFVal); client.publish("/hometest/smallroom/ldelta", strFVal);
//digitalWrite(LED_GREEN, LOW); //digitalWrite(LED_GREEN, LOW);
} }
@@ -213,7 +213,9 @@ void publishSec()
void callback(char* topic, byte* payload, unsigned int length) { void callback(char* topic, byte* payload, unsigned int length) {
if(strcmp(topic,"/home/smallroom/ldelta") == 0){ if(strcmp(topic,"/home/smallroom/ldelta") == 0){
delta = atoi((char*)payload); payload[length] = '\0';
String pl = String((char*)payload);
delta = pl.toInt();// atoi((char*)payload);
EEPROM.put(0, delta); EEPROM.put(0, delta);
EEPROM.commit(); EEPROM.commit();
} }