From 594e97880cb6027314e18968bd7e5e8f589c042a Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 29 Mar 2019 15:43:28 +0300 Subject: [PATCH 1/4] fix cse7766 magnitude count --- code/espurna/sensors/CSE7766Sensor.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/espurna/sensors/CSE7766Sensor.h b/code/espurna/sensors/CSE7766Sensor.h index be611f16..ffd4a9b9 100644 --- a/code/espurna/sensors/CSE7766Sensor.h +++ b/code/espurna/sensors/CSE7766Sensor.h @@ -22,7 +22,7 @@ class CSE7766Sensor : public BaseSensor { // --------------------------------------------------------------------- CSE7766Sensor(): BaseSensor(), _data() { - _count = 6; + _count = 7; _sensor_id = SENSOR_CSE7766_ID; } @@ -161,7 +161,7 @@ class CSE7766Sensor : public BaseSensor { if (index == 0) return MAGNITUDE_CURRENT; if (index == 1) return MAGNITUDE_VOLTAGE; if (index == 2) return MAGNITUDE_POWER_ACTIVE; - if (index == 3) return MAGNITUDE_POWER_REACTIVE; + if (index == 3) return MAGNITUDE_POWER_REACTIVE; if (index == 4) return MAGNITUDE_POWER_APPARENT; if (index == 5) return MAGNITUDE_POWER_FACTOR; if (index == 6) return MAGNITUDE_ENERGY; @@ -275,10 +275,10 @@ class CSE7766Sensor : public BaseSensor { } } - // Calculate reactive power - _reactive = 0; - unsigned int active = _active; - unsigned int apparent = _voltage * _current; + // Calculate reactive power + _reactive = 0; + unsigned int active = _active; + unsigned int apparent = _voltage * _current; if (apparent > active) { _reactive = sqrt(apparent * apparent - active * active); } else { From 6732487469be3ae91d2f13a0543e1034c431be94 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Thu, 4 Apr 2019 21:51:06 +0300 Subject: [PATCH 2/4] MAX6675: default pins and SENSOR_SUPPORT dependency (#1646, #1666) --- code/espurna/config/sensors.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/code/espurna/config/sensors.h b/code/espurna/config/sensors.h index e0ac7e76..af481da2 100644 --- a/code/espurna/config/sensors.h +++ b/code/espurna/config/sensors.h @@ -856,6 +856,22 @@ #define VL53L1X_INTER_MEASUREMENT_PERIOD 50 // Period, in milliseconds, determining how #endif // often the sensor takes a measurement. +//------------------------------------------------------------------------------ +// MAX6675 +// Enable support by passing MAX6675_SUPPORT=1 build flag +//------------------------------------------------------------------------------ +#ifndef MAX6675_CS_PIN +#define MAX6675_CS_PIN 13 +#endif + +#ifndef MAX6675_SO_PIN +#define MAX6675_SO_PIN 12 +#endif + +#ifndef MAX6675_SCK_PIN +#define MAX6675_SCK_PIN 14 +#endif + //------------------------------------------------------------------------------ // EZOPH pH meter // Enable support by passing EZOPH_SUPPORT=1 build flag @@ -916,6 +932,7 @@ V9261F_SUPPORT || \ VEML6075_SUPPORT || \ VL53L1X_SUPPORT || \ + MAX6675_SUPPORT || \ EZOPH_SUPPORT \ ) #endif From eb504e5f580ac44e8df1fef6619d02aefd031fa6 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 3 Apr 2019 18:38:52 +0300 Subject: [PATCH 3/4] Fix Travis failing with INFLUXDB_SUPPORT --- code/espurna/libs/SyncClientWrap.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/code/espurna/libs/SyncClientWrap.h b/code/espurna/libs/SyncClientWrap.h index c22d27f9..b252eaf5 100644 --- a/code/espurna/libs/SyncClientWrap.h +++ b/code/espurna/libs/SyncClientWrap.h @@ -9,13 +9,29 @@ Temporary wrap to fix https://github.com/me-no-dev/ESPAsyncTCP/issues/109 #include +// ref Core 2.5.0: cores/esp8266/IPAddress.h +#ifndef CONST +#include + +#if LWIP_VERSION_MAJOR == 1 +#define CONST +#else +#define CONST const +#endif + +#endif + class SyncClientWrap: public SyncClient { public: + SyncClientWrap() {} + ~SyncClientWrap() {} + + // int connect(const char*, uint16_t); + using SyncClient::connect; - int connect(const char *host, uint16_t port); - int connect(CONST IPAddress& ip, uint16_t port) { return connect(ip, port); } - bool flush(unsigned int maxWaitMs = 0) { flush(); return true; } - bool stop(unsigned int maxWaitMs = 0) { stop(); return true; } + int connect(CONST IPAddress& ip, uint16_t port) { IPAddress _ip(ip); return SyncClient::connect(_ip, port); } + bool flush(unsigned int maxWaitMs = 0) { SyncClient::flush(); return true; } + bool stop(unsigned int maxWaitMs = 0) { SyncClient::stop(); return true; } }; From 903ceb1e844586a6b954c294d7a4438c75a08467 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Wed, 3 Apr 2019 18:39:32 +0300 Subject: [PATCH 4/4] Use local includes for NtpClient wrapper --- code/espurna/ntp.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/espurna/ntp.ino b/code/espurna/ntp.ino index 153df10e..de9353e0 100644 --- a/code/espurna/ntp.ino +++ b/code/espurna/ntp.ino @@ -12,7 +12,7 @@ Copyright (C) 2016-2019 by Xose PĂ©rez #include #include -#include +#include "libs/NtpClientWrap.h" Ticker _ntp_defer;