Browse Source

Merged Mancave Made ESPLive board definition

Conflicts:
	code/espurna/hardware.ino
fastled
Xose Pérez 7 years ago
parent
commit
1baba3bab4
8 changed files with 114 additions and 17 deletions
  1. +34
    -0
      code/espurna/config/hardware.h
  2. +12
    -0
      code/espurna/config/sensors.h
  3. +22
    -10
      code/espurna/ds18b20.ino
  4. +5
    -0
      code/espurna/espurna.ino
  5. +12
    -0
      code/espurna/hardware.ino
  6. +4
    -4
      code/espurna/relay.ino
  7. +3
    -3
      code/espurna/web.ino
  8. +22
    -0
      code/platformio.ini

+ 34
- 0
code/espurna/config/hardware.h View File

@ -923,6 +923,40 @@
#define ECH1560_MISO_PIN 5 #define ECH1560_MISO_PIN 5
#define ECH1560_INVERTED 0 #define ECH1560_INVERTED 0
// -----------------------------------------------------------------------------
// ESPLive
// https://github.com/ManCaveMade/ESP-Live
// -----------------------------------------------------------------------------
#elif defined(MANCAVEMADE_ESPLIVE)
// Info
#define MANUFACTURER "MANCAVEMADE"
#define DEVICE "ESPLIVE"
// Buttons
#define BUTTON1_PIN 4
#define BUTTON2_PIN 5
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON2_RELAY 2
// Relays
#define RELAY1_PIN 12
#define RELAY2_PIN 13
#define RELAY1_TYPE RELAY_TYPE_NORMAL
#define RELAY2_TYPE RELAY_TYPE_NORMAL
// DB18B20
#define DS18B20_SUPPORT 1
#define DS18B20_PIN 2
#define DS18B20_UPDATE_INTERVAL 5000
#define DS18B20_UPDATE_ON_CHANGE 1.0
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Unknown hardware // Unknown hardware
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 12
- 0
code/espurna/config/sensors.h View File

@ -77,9 +77,21 @@
#define DS18B20_SUPPORT 0 #define DS18B20_SUPPORT 0
#endif #endif
#ifndef DS18B20_PIN
#define DS18B20_PIN 14 #define DS18B20_PIN 14
#endif
#ifndef DS18B20_UPDATE_INTERVAL
#define DS18B20_UPDATE_INTERVAL 60000 #define DS18B20_UPDATE_INTERVAL 60000
#endif
#ifndef DS18B20_TEMPERATURE_TOPIC
#define DS18B20_TEMPERATURE_TOPIC "temperature" #define DS18B20_TEMPERATURE_TOPIC "temperature"
#endif
#ifndef DS18B20_UPDATE_ON_CHANGE
#define DS18B20_UPDATE_ON_CHANGE 0.0
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Internal power montior // Internal power montior


+ 22
- 10
code/espurna/ds18b20.ino View File

@ -51,6 +51,10 @@ void dsLoop() {
// Check if we should read new data // Check if we should read new data
static unsigned long last_update = 0; static unsigned long last_update = 0;
static bool requested = false; static bool requested = false;
static double last_temperature = 0.0;
bool send_update = false;
if ((millis() - last_update > DS18B20_UPDATE_INTERVAL) || (last_update == 0)) { if ((millis() - last_update > DS18B20_UPDATE_INTERVAL) || (last_update == 0)) {
if (!requested) { if (!requested) {
ds18b20.requestTemperatures(); ds18b20.requestTemperatures();
@ -80,6 +84,12 @@ void dsLoop() {
DEBUG_MSG_P(PSTR("[DS18B20] Error reading sensor\n")); DEBUG_MSG_P(PSTR("[DS18B20] Error reading sensor\n"));
} else { } else {
//If the new temperature is different from the last
if (fabs(t - last_temperature) >= DS18B20_UPDATE_ON_CHANGE) {
last_temperature = t;
send_update = true;
}
_dsTemperature = t; _dsTemperature = t;
@ -95,17 +105,19 @@ void dsLoop() {
getDSTemperatureStr(), getDSTemperatureStr(),
(_dsIsConnected ? ((tmpUnits == TMP_CELSIUS) ? "ºC" : "ºF") : "")); (_dsIsConnected ? ((tmpUnits == TMP_CELSIUS) ? "ºC" : "ºF") : ""));
// Send MQTT messages
mqttSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
if (send_update) {
// Send MQTT messages
mqttSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
// Send to Domoticz
#if DOMOTICZ_SUPPORT
domoticzSend("dczTmpIdx", 0, _dsTemperatureStr);
#endif
// Send to Domoticz
#if DOMOTICZ_SUPPORT
domoticzSend("dczTmpIdx", 0, _dsTemperatureStr);
#endif
#if INFLUXDB_SUPPORT
influxDBSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
#endif
#if INFLUXDB_SUPPORT
influxDBSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
#endif
}
// Update websocket clients // Update websocket clients
#if WEB_SUPPORT #if WEB_SUPPORT
@ -113,7 +125,7 @@ void dsLoop() {
snprintf_P(buffer, sizeof(buffer), PSTR("{\"dsVisible\": 1, \"dsTmp\": %s, \"tmpUnits\": %d}"), getDSTemperatureStr(), tmpUnits); snprintf_P(buffer, sizeof(buffer), PSTR("{\"dsVisible\": 1, \"dsTmp\": %s, \"tmpUnits\": %d}"), getDSTemperatureStr(), tmpUnits);
wsSend(buffer); wsSend(buffer);
#endif #endif
} }
} }


+ 5
- 0
code/espurna/espurna.ino View File

@ -43,6 +43,11 @@ void hardwareSetup() {
SPIFFS.begin(); SPIFFS.begin();
#endif #endif
#if defined(ESPLIVE)
//The ESPLive has an ADC MUX which needs to be configured.
pinMode(16, OUTPUT);
digitalWrite(16, HIGH); //Defualt CT input (pin B, solder jumper B)
#endif
} }
void hardwareLoop() { void hardwareLoop() {


+ 12
- 0
code/espurna/hardware.ino View File

@ -455,6 +455,18 @@ void hwUpwardsCompatibility() {
setSetting("cf1GPIO", 13); setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14); setSetting("cfGPIO", 14);
#elif defined(MANCAVEMADE_ESPLIVE)
setSetting("board", 40);
setSetting("btnGPIO", 1, 4);
setSetting("btnGPIO", 2, 5);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#else #else
#error "UNSUPPORTED HARDWARE!" #error "UNSUPPORTED HARDWARE!"


+ 4
- 4
code/espurna/relay.ino View File

@ -377,9 +377,9 @@ void relaySetupAPI() {
if (value == 0) { if (value == 0) {
relayStatus(relayID, false); relayStatus(relayID, false);
} elseif (value == 1) {
} else if (value == 1) {
relayStatus(relayID, true); relayStatus(relayID, true);
} elseif (value == 2) {
} else if (value == 2) {
relayToggle(relayID); relayToggle(relayID);
} }
@ -470,9 +470,9 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
// Action to perform // Action to perform
if (value == 0) { if (value == 0) {
relayStatus(relayID, false, mqttForward()); relayStatus(relayID, false, mqttForward());
} elseif (value == 1) {
} else if (value == 1) {
relayStatus(relayID, true, mqttForward()); relayStatus(relayID, true, mqttForward());
} elseif (value == 2) {
} else if (value == 2) {
relayToggle(relayID); relayToggle(relayID);
} }


+ 3
- 3
code/espurna/web.ino View File

@ -148,7 +148,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
relayWS(); relayWS();
} elseif (value < 3) {
} else if (value < 3) {
unsigned int relayID = 0; unsigned int relayID = 0;
if (data.containsKey("id")) { if (data.containsKey("id")) {
@ -159,9 +159,9 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
// Action to perform // Action to perform
if (value == 0) { if (value == 0) {
relayStatus(relayID, false); relayStatus(relayID, false);
} elseif (value == 1) {
} else if (value == 1) {
relayStatus(relayID, true); relayStatus(relayID, true);
} elseif (value == 2) {
} else if (value == 2) {
relayToggle(relayID); relayToggle(relayID);
} }


+ 22
- 0
code/platformio.ini View File

@ -908,6 +908,28 @@ upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266 upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200 monitor_baud = 115200
[env:mancavemade-esplive]
platform = espressif8266
framework = arduino
board = d1_mini
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE
upload_speed = 460800
monitor_baud = 115200
[env:mancavemade-esplive-ota]
platform = espressif8266
framework = arduino
board = d1_mini
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE
upload_speed = 460800
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# GENERIC OTA ENVIRONMENTS # GENERIC OTA ENVIRONMENTS
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------


Loading…
Cancel
Save