Skip to content

Commit

Permalink
init code and got symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
merlokk committed May 4, 2017
1 parent a6ef788 commit f6be6d6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
57 changes: 55 additions & 2 deletions ESP14MES/ESP14MES.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,71 @@
#define DEBUG // enable debugging
#define DEBUG_SERIAL logger

// device modbus address
#define MODBUS_ADDRESS 42
#define MODBUS_OBJ_NAME esp14

// LEDs and pins
#define PIN_PGM 0 // programming pin
#define LED1 12 // led 1
#define LED1 12 // led 1 TODO: delete leds
#define LED2 13 // led 2
#define LEDON LOW
#define LEDOFF HIGH

// objects
ModbusPoll esp14;

void setup() {
Serial.setDebugOutput(false);
Serial1.setDebugOutput(true);
Serial.begin(115200);
// ESP.rtcUserMemoryWrite(offset, &data, sizeof(data)) and ESP.rtcUserMemoryRead(offset, &data, sizeof(data)) 512 bytes - live between sleeps
Serial1.begin(115200);

pinMode(PIN_PGM, OUTPUT);
digitalWrite(PIN_PGM, LEDOFF);

sprintf(HARDWARE_ID, "%06X", ESP.getChipId());

// start logger
initLogger();

delay(200);
initPrintStartDebugInfo();

WiFi.hostname(HARDWARE_ID);

// setup xparam lib
initXParam();

// connect to default wifi
WiFi.begin();

// modbus poll
esp14.SetDeviceAddress(MODBUS_ADDRESS);
esp14.SetLogger(&logger);
DEBUG_PRINT(F("DeviceType: "));
DEBUG_PRINTLN(params[F("device_type")]);
esp14.ModbusSetup(params[F("device_type")].c_str());

String str;
esp14.getStrModbusConfig(str);
DEBUG_PRINTLN(F("Modbus config:"));
DEBUG_PRINTLN(str);

// wait wifi to connect
if (WiFi.status() != WL_CONNECTED) {
DEBUG_WPRINTLN(F("Wifi is not connected. Wait..."));
delay(5000);
}

// mqtt init and pub
initMQTT("esp14");



ESP.deepSleep(60 * 1000000); // 60 sec

// config here
}

void loop() {
Expand Down
5 changes: 5 additions & 0 deletions create_general_symlink.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set drive=%~dp0
set drivep=%drive%

mklink %drivep%\ESP14MES\general.h %drivep%\ESP8266EASTRON\general.h
mklink %drivep%\ESP14MES\general.ino %drivep%\ESP8266EASTRON\general.ino

0 comments on commit f6be6d6

Please sign in to comment.