Merge branch 'arendst/development' into development

This commit is contained in:
reloxx13 2018-02-04 00:24:54 +01:00
commit 7f3fc8869c
30 changed files with 378 additions and 4552 deletions

View File

@ -1,7 +1,7 @@
## Sonoff-Tasmota
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
Current version is **5.11.1h** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
Current version is **5.11.1i** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions

File diff suppressed because it is too large Load Diff

View File

@ -1,131 +0,0 @@
# ESP8266 platform
# ------------------------------
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=ESP8266 Modules
version=2.4.0
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
build.lwip_lib=-llwip_gcc
build.lwip_flags=-DLWIP_OPEN_SRC
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
compiler.sdk.path={runtime.platform.path}/tools/sdk
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/lwip/include" "-I{compiler.libc.path}/include" "-I{build.path}/core"
compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
compiler.S.cmd=xtensa-lx106-elf-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc
compiler.cpp.cmd=xtensa-lx106-elf-g++
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
compiler.as.cmd=xtensa-lx106-elf-as
compiler.ar.cmd=xtensa-lx106-elf-ar
compiler.ar.flags=cru
compiler.elf2hex.cmd=esptool
compiler.elf2hex.flags=
compiler.size.cmd=xtensa-lx106-elf-size
compiler.esptool.cmd=esptool
compiler.esptool.cmd.windows=esptool.exe
# This can be overriden in boards.txt
build.extra_flags=-DESP8266
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
## generate file with git version number
## needs bash, git, and echo
## windows-compatible version may be added later
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/arduino.ar" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/arduino.ar" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}"
## Create eeprom
recipe.objcopy.eep.pattern=
## Create hex
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
recipe.objcopy.hex.pattern="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
## Save hex
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.irom0\.text|\.text|\.data|\.rodata|)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*
#recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
# ------------------------------
tools.esptool.cmd=esptool
tools.esptool.cmd.windows=esptool.exe
tools.esptool.path={runtime.tools.esptool.path}
tools.esptool.network_cmd=python
tools.esptool.network_cmd.windows=python.exe
tools.esptool.upload.protocol=esp
tools.esptool.upload.params.verbose=-vv
tools.esptool.upload.params.quiet=
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"
tools.esptool.upload.network_pattern="{network_cmd}" "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
tools.mkspiffs.cmd=mkspiffs
tools.mkspiffs.cmd.windows=mkspiffs.exe
tools.mkspiffs.path={runtime.tools.mkspiffs.path}
tools.espupload.cmd=python
tools.espupload.cmd.windows=python.exe
tools.espupload.path={runtime.platform.path}/tools
tools.espupload.upload.protocol=espupload
tools.espupload.upload.params.verbose=
tools.espupload.upload.params.quiet=
tools.espupload.upload.pattern="{cmd}" "{path}/espupload.py" -f "{build.path}/{build.project_name}.bin"

File diff suppressed because it is too large Load Diff

View File

@ -1,131 +0,0 @@
# ESP8266 platform
# ------------------------------
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
name=ESP8266 Modules
version=2.4.0
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
build.lwip_lib=-llwip_gcc
build.lwip_flags=-DLWIP_OPEN_SRC
compiler.path={runtime.tools.xtensa-lx106-elf-gcc.path}/bin/
compiler.sdk.path={runtime.platform.path}/tools/sdk
compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/lwip/include" "-I{compiler.libc.path}/include" "-I{build.path}/core"
compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
compiler.S.cmd=xtensa-lx106-elf-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
compiler.c.elf.flags=-g {compiler.warning_flags} -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-L{compiler.libc.path}/lib" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -laxtls -lespnow -lsmartconfig -lairkiss -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc
compiler.cpp.cmd=xtensa-lx106-elf-g++
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
compiler.as.cmd=xtensa-lx106-elf-as
compiler.ar.cmd=xtensa-lx106-elf-ar
compiler.ar.flags=cru
compiler.elf2hex.cmd=esptool
compiler.elf2hex.flags=
compiler.size.cmd=xtensa-lx106-elf-size
compiler.esptool.cmd=esptool
compiler.esptool.cmd.windows=esptool.exe
# This can be overriden in boards.txt
build.extra_flags=-DESP8266
# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
## generate file with git version number
## needs bash, git, and echo
## windows-compatible version may be added later
## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.c.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpreprocessor.flags} {compiler.cpp.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.cpreprocessor.flags} {compiler.S.flags} -DF_CPU={build.f_cpu} {build.lwip_flags} {build.debug_port} {build.debug_level} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} -DARDUINO_BOARD="{build.board}" {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/arduino.ar" "{object_file}"
## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{build.path}/arduino.ar" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}"
## Create eeprom
recipe.objcopy.eep.pattern=
## Create hex
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
recipe.objcopy.hex.pattern="{runtime.tools.esptool.path}/{compiler.esptool.cmd}" -eo "{runtime.platform.path}/bootloaders/eboot/eboot.elf" -bo "{build.path}/{build.project_name}.bin" -bm {build.flash_mode} -bf {build.flash_freq} -bz {build.flash_size} -bs .text -bp 4096 -ec -eo "{build.path}/{build.project_name}.elf" -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
## Save hex
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin
## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.irom0\.text|\.text|\.data|\.rodata|)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*
#recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
# ------------------------------
tools.esptool.cmd=esptool
tools.esptool.cmd.windows=esptool.exe
tools.esptool.path={runtime.tools.esptool.path}
tools.esptool.network_cmd=python
tools.esptool.network_cmd.windows=python.exe
tools.esptool.upload.protocol=esp
tools.esptool.upload.params.verbose=-vv
tools.esptool.upload.params.quiet=
tools.esptool.upload.pattern="{path}/{cmd}" {upload.verbose} -cd {upload.resetmethod} -cb {upload.speed} -cp "{serial.port}" -ca 0x00000 -cf "{build.path}/{build.project_name}.bin"
tools.esptool.upload.network_pattern="{network_cmd}" "{runtime.platform.path}/tools/espota.py" -i "{serial.port}" -p "{network.port}" "--auth={network.password}" -f "{build.path}/{build.project_name}.bin"
tools.mkspiffs.cmd=mkspiffs
tools.mkspiffs.cmd.windows=mkspiffs.exe
tools.mkspiffs.path={runtime.tools.mkspiffs.path}
tools.espupload.cmd=python
tools.espupload.cmd.windows=python.exe
tools.espupload.path={runtime.platform.path}/tools
tools.espupload.upload.protocol=espupload
tools.espupload.upload.params.verbose=
tools.espupload.upload.params.quiet=
tools.espupload.upload.pattern="{cmd}" "{path}/espupload.py" -f "{build.path}/{build.project_name}.bin"

View File

@ -108,8 +108,14 @@ bool TasmotaSerial::isValidGPIOpin(int pin)
return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15);
}
bool TasmotaSerial::begin(long speed) {
// Use getCycleCount() loop to get as exact timing as possible
m_bit_time = ESP.getCpuFreqMHz() *1000000 /speed;
return m_valid && (speed <= TM_SERIAL_BAUDRATE);
}
bool TasmotaSerial::begin() {
return m_valid;
return begin(TM_SERIAL_BAUDRATE);
}
void TasmotaSerial::flush() {
@ -142,8 +148,11 @@ int TasmotaSerial::available()
return avail;
}
//#define TM_SERIAL_WAIT { while (ESP.getCycleCount()-start < wait) optimistic_yield(1); wait += m_bit_time; } // Watchdog timeouts
#ifdef TM_SERIAL_USE_IRAM
#define TM_SERIAL_WAIT { while (ESP.getCycleCount()-start < wait) optimistic_yield(1); wait += m_bit_time; } // Watchdog timeouts
#else
#define TM_SERIAL_WAIT { while (ESP.getCycleCount()-start < wait); wait += m_bit_time; }
#endif
size_t TasmotaSerial::write(uint8_t b)
{
@ -167,22 +176,6 @@ size_t TasmotaSerial::write(uint8_t b)
return 1;
}
/*
size_t TasmotaSerial::write(const uint8_t *buffer, size_t size)
{
if (-1 == m_tx_pin) {
return 0;
}
size_t n = 0;
// Flush input buffer on every write
m_in_pos = m_out_pos = 0;
while(size--) {
n += txWrite(*buffer++);
}
return n;
}
*/
#ifdef TM_SERIAL_USE_IRAM
void ICACHE_RAM_ATTR TasmotaSerial::rxRead()
{
@ -206,7 +199,7 @@ void TasmotaSerial::rxRead()
TM_SERIAL_WAIT;
// Store the received value in the buffer unless we have an overflow
int next = (m_in_pos+1) % TM_SERIAL_BUFFER_SIZE;
if (next != m_out_pos) {
if (next != (int)m_out_pos) {
m_buffer[m_in_pos] = rec;
m_in_pos = next;
}

View File

@ -20,20 +20,25 @@
#ifndef TasmotaSerial_h
#define TasmotaSerial_h
/*********************************************************************************************\
* TasmotaSerial supports 9600 baud with fixed buffer size of 20 bytes using optional no iram
* TasmotaSerial supports up to 9600 baud with fixed buffer size of 64 bytes using optional no iram
*
* Based on EspSoftwareSerial v3.3.1 by Peter Lerup (https://github.com/plerup/espsoftwareserial)
\*********************************************************************************************/
#define TM_SERIAL_BAUDRATE 9600
#define TM_SERIAL_BUFFER_SIZE 64
//#define TM_SERIAL_USE_IRAM // Enable to use iram (+368 bytes)
#define TM_SERIAL_BAUDRATE 9600 // Max supported baudrate
#define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
#define TM_SERIAL_USE_IRAM // Enable to use iram (+368 bytes)
#endif
#include <Stream.h>
class TasmotaSerial : public Stream {
public:
TasmotaSerial(int receive_pin, int transmit_pin);
bool begin(long speed);
bool begin();
int peek();
@ -42,10 +47,6 @@ class TasmotaSerial : public Stream {
virtual int available();
virtual void flush();
// size_t write(const uint8_t *buffer, size_t size = 1);
// int read();
// int available();
void rxRead();
using Print::write;

15
pio/strip-floats.py Normal file
View File

@ -0,0 +1,15 @@
Import('env')
#
# Dump build environment (for debug)
#print env.Dump()
#
flags = " ".join(env['LINKFLAGS'])
flags = flags.replace("-u _printf_float", "")
flags = flags.replace("-u _scanf_float", "")
newflags = flags.split()
env.Replace(
LINKFLAGS=newflags
)

View File

@ -29,6 +29,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -44,7 +45,7 @@ monitor_baud = 115200
; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/http-uploader.py
;extra_scripts = pio/strip-floats.py, pio/http-uploader.py
[env:sonoff-DE]
platform = espressif8266
@ -53,6 +54,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=de-DE
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -64,6 +66,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=es-AR
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -75,6 +78,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=fr-FR
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -86,6 +90,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=it-IT
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -97,6 +102,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=nl-NL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -108,6 +114,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pl-PL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -119,6 +126,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-CN
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
@ -130,6 +138,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DBE_MINIMAL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; Serial Monitor options
monitor_baud = 115200
@ -141,6 +150,7 @@ board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_DS18x20
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; Serial Monitor options
monitor_baud = 115200

View File

@ -1,4 +1,12 @@
/* 5.11.1h
/* 5.11.1i
* Update TasmotaSerial library to 1.1.0
* Rename commands HlwPCal, HlwUCal and HlwICal to PowerCal, VoltageCal and CurrentCal to be used for both Pow and S31 calibration
* Rename commands HlwPSet, HlwUSet and HlwISet to PowerSet, VoltageSet and CurrentSet to be used for both Pow and S31 calibration
* Add support for Sonoff S31 Smart Socket with Power Consumption Detection (#1626)
* Fix IRReceive Data value (#1663)
* Fix compiler warnings (#1774)
*
* 5.11.1h
* Rewrite webserver argument processing gaining 5k code space (#1705)
* Redesign weblog storage (#1730)
* Fix command SetOption20 (#1741)

View File

@ -278,12 +278,12 @@
#define D_CMND_CURRENTLOW "CurrentLow"
#define D_CMND_CURRENTHIGH "CurrentHigh"
#define D_CMND_ENERGYRESET "EnergyReset"
#define D_CMND_HLWPCAL "HlwPcal"
#define D_CMND_HLWPSET "HlwPset"
#define D_CMND_HLWUCAL "HlwUcal"
#define D_CMND_HLWUSET "HlwUset"
#define D_CMND_HLWICAL "HlwIcal"
#define D_CMND_HLWISET "HlwIset"
#define D_CMND_POWERCAL "PowerCal"
#define D_CMND_POWERSET "PowerSet"
#define D_CMND_VOLTAGECAL "VoltageCal"
#define D_CMND_VOLTAGESET "VoltageSet"
#define D_CMND_CURRENTCAL "CurrentCal"
#define D_CMND_CURRENTSET "CurrentSet"
#define D_CMND_MAXPOWER "MaxPower"
#define D_CMND_MAXPOWERHOLD "MaxPowerHold"
#define D_CMND_MAXPOWERWINDOW "MaxPowerWindow"
@ -382,6 +382,7 @@ const char kUnitNames[] PROGMEM =
D_UNIT_WATTHOUR ;
const char S_JSON_COMMAND_NVALUE_SPACE_UNIT[] PROGMEM = "{\"%s\":\"%d %s\"}";
const char S_JSON_COMMAND_LVALUE_SPACE_UNIT[] PROGMEM = "{\"%s\":\"%lu %s\"}";
const char S_JSON_COMMAND_SVALUE_SPACE_UNIT[] PROGMEM = "{\"%s\":\"%s %s\"}";
const char S_JSON_COMMAND_NVALUE_UNIT[] PROGMEM = "{\"%s\":\"%d%s\"}";
const char S_JSON_COMMAND_NVALUE_UNIT_NVALUE_UNIT[] PROGMEM = "{\"%s\":\"%d%s (%d%s)\"}";
@ -390,10 +391,12 @@ const char S_JSON_COMMAND_NVALUE_SVALUE[] PROGMEM = "{\"%s\":\"%d (%s)
const char S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE[] PROGMEM = "{\"%s\":\"%d (" D_JSON_ACTIVE " %d)\"}";
const char S_JSON_COMMAND_NVALUE[] PROGMEM = "{\"%s\":%d}";
const char S_JSON_COMMAND_LVALUE[] PROGMEM = "{\"%s\":%lu}";
const char S_JSON_COMMAND_SVALUE[] PROGMEM = "{\"%s\":\"%s\"}";
const char S_JSON_COMMAND_XVALUE[] PROGMEM = "{\"%s\":%s}"; // %s must provide quotes on non-number
const char S_JSON_COMMAND_INDEX_NVALUE[] PROGMEM = "{\"%s%d\":%d}";
const char S_JSON_COMMAND_INDEX_LVALUE[] PROGMEM = "{\"%s%d\":%lu}";
const char S_JSON_COMMAND_INDEX_SVALUE[] PROGMEM = "{\"%s%d\":\"%s\"}";
const char S_JSON_COMMAND_INDEX_SVALUE_SVALUE[] PROGMEM = "{\"%s%d\":\"%s%s\"}";

View File

@ -152,12 +152,12 @@ struct SYSCFG {
uint16_t domoticz_update_timer; // 340
uint16_t pwm_range; // 342
unsigned long domoticz_relay_idx[MAX_DOMOTICZ_IDX]; // 344
unsigned long domoticz_key_idx[MAX_DOMOTICZ_IDX]; // 354
unsigned long domoticz_relay_idx[MAX_DOMOTICZ_IDX]; // 344
unsigned long domoticz_key_idx[MAX_DOMOTICZ_IDX]; // 354
unsigned long hlw_power_calibration; // 364
unsigned long hlw_voltage_calibration; // 368
unsigned long hlw_current_calibration; // 36C
unsigned long energy_power_calibration; // 364
unsigned long energy_voltage_calibration; // 368
unsigned long energy_current_calibration; // 36C
unsigned long energy_kWhtoday; // 370
unsigned long energy_kWhyesterday; // 374
uint16_t energy_kWhdoy; // 378
@ -168,11 +168,11 @@ struct SYSCFG {
uint16_t energy_min_current; // 382
uint16_t energy_max_current; // 384
uint16_t energy_max_power_limit; // 386 MaxPowerLimit
uint16_t energy_max_power_limit_hold; // 388 MaxPowerLimitHold
uint16_t energy_max_power_limit_window; // 38A MaxPowerLimitWindow
uint16_t energy_max_power_safe_limit; // 38C MaxSafePowerLimit
uint16_t energy_max_power_safe_limit_hold; // 38E MaxSafePowerLimitHold
uint16_t energy_max_power_safe_limit_window; // 390 MaxSafePowerLimitWindow
uint16_t energy_max_power_limit_hold; // 388 MaxPowerLimitHold
uint16_t energy_max_power_limit_window; // 38A MaxPowerLimitWindow
uint16_t energy_max_power_safe_limit; // 38C MaxSafePowerLimit
uint16_t energy_max_power_safe_limit_hold; // 38E MaxSafePowerLimitHold
uint16_t energy_max_power_safe_limit_window; // 390 MaxSafePowerLimitWindow
uint16_t energy_max_energy; // 392 MaxEnergy
uint16_t energy_max_energy_start; // 394 MaxEnergyStart
uint16_t mqtt_retry; // 396

View File

@ -478,9 +478,9 @@ void SettingsDefaultSet2()
// Settings.domoticz_switch_idx[i] = 0;
}
Settings.hlw_power_calibration = HLW_PREF_PULSE;
Settings.hlw_voltage_calibration = HLW_UREF_PULSE;
Settings.hlw_current_calibration = HLW_IREF_PULSE;
Settings.energy_power_calibration = HLW_PREF_PULSE;
Settings.energy_voltage_calibration = HLW_UREF_PULSE;
Settings.energy_current_calibration = HLW_IREF_PULSE;
// Settings.energy_kWhtoday = 0;
// Settings.energy_kWhyesterday = 0;
// Settings.energy_kWhdoy = 0;

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/
#define VERSION 0x050B0108 // 5.11.1h
#define VERSION 0x050B0109 // 5.11.1i
// Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
@ -109,6 +109,7 @@ const char kOptionBlinkOff[] PROGMEM = "BLINKOFF|" D_BLINKOFF ;
// Global variables
int baudrate = APP_BAUDRATE; // Serial interface baud rate
SerialConfig serial_config = SERIAL_8N1; // Serial interface configuration 8 data bits, No parity, 1 stop bit
byte serial_in_byte; // Received byte
int serial_in_byte_counter = 0; // Index in receive buffer
byte dual_hex_code = 0; // Sonoff dual input flag
@ -583,7 +584,6 @@ boolean MqttCommand(boolean grpflg, char *type, uint16_t index, char *dataBuf, u
char command [CMDSZ];
boolean serviced = true;
char stemp1[TOPSZ];
char stemp2[10];
char scommand[CMDSZ];
uint16_t i;
@ -797,9 +797,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
char command [CMDSZ];
char stemp1[TOPSZ];
char *p;
char *mtopic = NULL;
char *type = NULL;
byte otype = 0;
byte ptype = 0;
byte jsflg = 0;
byte lines = 1;
@ -999,7 +997,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
// type = NULL;
// }
}
else if ((CMND_SETOPTION == command_code) && ((index >= 0) && (index <= 20)) || ((index > 31) && (index <= P_MAX_PARAM8 +31))) {
else if ((CMND_SETOPTION == command_code) && ((index <= 20) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
if (index <= 31) {
ptype = 0; // SetOption0 .. 31
} else {
@ -1205,7 +1203,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
else if (CMND_PWMRANGE == command_code) {
if ((1 == payload) || ((payload > 254) && (payload < 1024))) {
Settings.pwm_range = (1 == payload) ? PWM_RANGE : payload;
for (byte i; i < MAX_PWMS; i++) {
for (byte i = 0; i < MAX_PWMS; i++) {
if (Settings.pwm_value[i] > Settings.pwm_range) {
Settings.pwm_value[i] = Settings.pwm_range;
}
@ -1219,7 +1217,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
RtcSettings.pulse_counter[index -1] = payload16;
Settings.pulse_counter[index -1] = payload16;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_NVALUE, command, index, RtcSettings.pulse_counter[index -1]);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_LVALUE, command, index, RtcSettings.pulse_counter[index -1]);
}
else if ((CMND_COUNTERTYPE == command_code) && (index > 0) && (index <= MAX_COUNTERS)) {
if ((payload >= 0) && (payload <= 1) && (pin[GPIO_CNTR1 + index -1] < 99)) {
@ -1545,7 +1543,6 @@ boolean send_button_power(byte key, byte device, byte state)
char stopic[TOPSZ];
char scommand[CMDSZ];
char stemp1[10];
boolean result = false;
char *key_topic = (key) ? Settings.switch_topic : Settings.button_topic;
@ -2421,6 +2418,17 @@ void SerialInput()
}
}
/*-------------------------------------------------------------------------------------------*\
* Sonoff S31 4800 baud serial interface
\*-------------------------------------------------------------------------------------------*/
if (SONOFF_S31 == Settings.module) {
if (CseSerialInput()) {
serial_in_byte_counter = 0;
Serial.flush();
return;
}
}
/*-------------------------------------------------------------------------------------------*/
if (serial_in_byte > 127) { // binary data...
@ -2451,7 +2459,7 @@ void SerialInput()
else if (serial_in_byte == '\n') {
serial_in_buffer[serial_in_byte_counter] = 0; // serial data completed
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? LOG_LEVEL_INFO : Settings.seriallog_level;
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (byte)LOG_LEVEL_INFO : Settings.seriallog_level;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
AddLog(LOG_LEVEL_INFO);
ExecuteCommand(serial_in_buffer);
@ -2721,7 +2729,7 @@ void setup()
SetDevicePower(power);
break;
case POWER_ALL_SAVED_TOGGLE:
power = Settings.power & ((1 << devices_present) -1) ^ POWER_MASK;
power = (Settings.power & ((1 << devices_present) -1)) ^ POWER_MASK;
if (Settings.flag.save_state) {
SetDevicePower(power);
}

View File

@ -175,6 +175,7 @@ enum SupportedModules {
ARILUX_LC11,
SONOFF_DUAL_R2,
ARILUX_LC06,
SONOFF_S31,
MAXMODULE };
/********************************************************************************************/
@ -199,6 +200,7 @@ const uint8_t kNiceList[MAXMODULE] PROGMEM = {
SONOFF_DUAL,
SONOFF_DUAL_R2,
SONOFF_POW,
SONOFF_S31,
SONOFF_4CH,
SONOFF_4CHPRO,
SONOFF_SV,
@ -771,6 +773,17 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
GPIO_PWM1, // GPIO14 RGB LED Red
GPIO_USER, // GPIO15 RGBW LED White
0, 0
},
{ "Sonoff S31", // Sonoff S31 (ESP8266)
GPIO_KEY1, // GPIO00 Button
0, // GPIO01 Serial RXD 4800 baud 8E1 CSE7766 energy sensor
0,
0, // GPIO03 Serial TXD
0, 0,
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
0, 0, 0, 0
}
};

View File

@ -408,7 +408,7 @@ void SetSerialBaudrate(int baudrate)
}
delay(100);
Serial.flush();
Serial.begin(baudrate);
Serial.begin(baudrate, serial_config);
delay(10);
Serial.println();
}
@ -998,17 +998,15 @@ String GetBuildDateAndTime()
{
// "2017-03-07T11:08:02" - ISO8601:2004
char bdt[21];
char *str;
char *p;
char *smonth;
char mdate[] = __DATE__; // "Mar 7 2017"
int month;
int day;
int year;
char *smonth = mdate;
int day = 0;
int year = 0;
// sscanf(mdate, "%s %d %d", bdt, &day, &year); // Not implemented in 2.3.0 and probably too many code
// sscanf(mdate, "%s %d %d", bdt, &day, &year); // Not implemented in 2.3.0 and probably too much code
byte i = 0;
for (str = strtok_r(mdate, " ", &p); str && i < 3; str = strtok_r(NULL, " ", &p)) {
for (char *str = strtok_r(mdate, " ", &p); str && i < 3; str = strtok_r(NULL, " ", &p)) {
switch (i++) {
case 0: // Month
smonth = str;
@ -1020,7 +1018,7 @@ String GetBuildDateAndTime()
year = atoi(str);
}
}
month = (strstr(kMonthNamesEnglish, smonth) -kMonthNamesEnglish) /3 +1;
int month = (strstr(kMonthNamesEnglish, smonth) -kMonthNamesEnglish) /3 +1;
snprintf_P(bdt, sizeof(bdt), PSTR("%d" D_YEAR_MONTH_SEPARATOR "%02d" D_MONTH_DAY_SEPARATOR "%02d" D_DATE_TIME_SEPARATOR "%s"), year, month, day, __TIME__);
return String(bdt);
}

View File

@ -576,7 +576,7 @@ void HandleAjaxStatusRefresh()
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{t}"));
XsnsCall(FUNC_WEB_APPEND);
if (D_DECIMAL_SEPARATOR[0] != '.') {
for (int i = 0; i < strlen(mqtt_data); i++) {
for (uint16_t i = 0; i < strlen(mqtt_data); i++) {
if ('.' == mqtt_data[i]) {
mqtt_data[i] = D_DECIMAL_SEPARATOR[0];
}

View File

@ -677,7 +677,7 @@ void LightSetPower()
void LightAnimate()
{
uint8_t cur_col[5];
uint16_t light_still_on;
uint16_t light_still_on = 0;
strip_timer_counter++;
if (!light_power) { // Power Off

View File

@ -107,8 +107,8 @@ void IrReceiveCheck()
if ((iridx < 0) || (iridx > 14)) {
iridx = 0;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":\"%X\"}}"),
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, results.value);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":\"%lX\"}}"),
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, (uint32_t)results.value);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
#ifdef USE_DOMOTICZ
unsigned long value = results.value | (iridx << 28); // [Protocol:4, Data:28]
@ -132,7 +132,6 @@ boolean IrHvacToshiba(const char *HVAC_Mode, const char *HVAC_FanMode, boolean H
byte data[HVAC_TOSHIBA_DATALEN] = {0xF2, 0x0D, 0x03, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00};
char *p;
char *token;
uint8_t mode;
if (HVAC_Mode == NULL) {
@ -176,7 +175,7 @@ boolean IrHvacToshiba(const char *HVAC_Mode, const char *HVAC_FanMode, boolean H
else {
Temp = HVAC_Temp;
}
data[5] = (byte)Temp - 17 << 4;
data[5] = (byte)(Temp - 17) << 4;
data[HVAC_TOSHIBA_DATALEN - 1] = 0;
for (int x = 0; x < HVAC_TOSHIBA_DATALEN - 1; x++) {
@ -219,7 +218,6 @@ boolean IrHvacToshiba(const char *HVAC_Mode, const char *HVAC_FanMode, boolean H
boolean IrHvacMitsubishi(const char *HVAC_Mode, const char *HVAC_FanMode, boolean HVAC_Power, int HVAC_Temp)
{
char *p;
char *token;
uint8_t mode;
mitsubir->stateReset();
@ -286,12 +284,6 @@ boolean IrSendCommand()
uint32_t bits = 0;
uint32_t data = 0;
const char *HVAC_Mode;
const char *HVAC_FanMode;
const char *HVAC_Vendor;
int HVAC_Temp = 21;
boolean HVAC_Power = true;
for (uint16_t i = 0; i <= sizeof(dataBufUc); i++) {
dataBufUc[i] = toupper(XdrvMailbox.data[i]);
}
@ -349,6 +341,12 @@ boolean IrSendCommand()
}
#ifdef USE_IR_HVAC
else if (!strcasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_IRHVAC))) {
const char *HVAC_Mode;
const char *HVAC_FanMode;
const char *HVAC_Vendor;
int HVAC_Temp = 21;
boolean HVAC_Power = true;
if (XdrvMailbox.data_len) {
StaticJsonBuffer<164> jsonBufer;
JsonObject &root = jsonBufer.parseObject(dataBufUc);

View File

@ -26,17 +26,17 @@
#define FEATURE_POWER_LIMIT true
enum EnergyHardware { ENERGY_NONE, ENERGY_HLW8012, ENERGY_PZEM004T };
enum EnergyHardware { ENERGY_NONE, ENERGY_HLW8012, ENERGY_CSE7766, ENERGY_PZEM004T };
enum EnergyCommands {
CMND_POWERLOW, CMND_POWERHIGH, CMND_VOLTAGELOW, CMND_VOLTAGEHIGH, CMND_CURRENTLOW, CMND_CURRENTHIGH,
CMND_HLWPCAL, CMND_HLWPSET, CMND_HLWUCAL, CMND_HLWUSET, CMND_HLWICAL, CMND_HLWISET,
CMND_POWERCAL, CMND_POWERSET, CMND_VOLTAGECAL, CMND_VOLTAGESET, CMND_CURRENTCAL, CMND_CURRENTSET,
CMND_ENERGYRESET, CMND_MAXENERGY, CMND_MAXENERGYSTART,
CMND_MAXPOWER, CMND_MAXPOWERHOLD, CMND_MAXPOWERWINDOW,
CMND_SAFEPOWER, CMND_SAFEPOWERHOLD, CMND_SAFEPOWERWINDOW };
const char kEnergyCommands[] PROGMEM =
D_CMND_POWERLOW "|" D_CMND_POWERHIGH "|" D_CMND_VOLTAGELOW "|" D_CMND_VOLTAGEHIGH "|" D_CMND_CURRENTLOW "|" D_CMND_CURRENTHIGH "|"
D_CMND_HLWPCAL "|" D_CMND_HLWPSET "|" D_CMND_HLWUCAL "|" D_CMND_HLWUSET "|" D_CMND_HLWICAL "|" D_CMND_HLWISET "|"
D_CMND_POWERCAL "|" D_CMND_POWERSET "|" D_CMND_VOLTAGECAL "|" D_CMND_VOLTAGESET "|" D_CMND_CURRENTCAL "|" D_CMND_CURRENTSET "|"
D_CMND_ENERGYRESET "|" D_CMND_MAXENERGY "|" D_CMND_MAXENERGYSTART "|"
D_CMND_MAXPOWER "|" D_CMND_MAXPOWERHOLD "|" D_CMND_MAXPOWERWINDOW "|"
D_CMND_SAFEPOWER "|" D_CMND_SAFEPOWERHOLD "|" D_CMND_SAFEPOWERWINDOW ;
@ -72,7 +72,7 @@ byte energy_fifth_second = 0;
Ticker ticker_energy;
/*********************************************************************************************\
* HLW8012 - Energy
* HLW8012 - Energy (Sonoff Pow)
*
* Based on Source: Shenzhen Heli Technology Co., Ltd
\*********************************************************************************************/
@ -142,7 +142,7 @@ void HlwEverySecond()
hlw_len = 10000 / hlw_energy_period_counter;
hlw_energy_period_counter = 0;
if (hlw_len) {
hlw_temp = ((HLW_PREF * Settings.hlw_power_calibration) / hlw_len) / 36;
hlw_temp = ((HLW_PREF * Settings.energy_power_calibration) / hlw_len) / 36;
energy_kWhtoday += hlw_temp;
RtcSettings.energy_kWhtoday = energy_kWhtoday;
@ -164,7 +164,7 @@ void HlwEvery200ms()
}
if (hlw_cf_pulse_length && (power &1) && !hlw_load_off) {
hlw_w = (HLW_PREF * Settings.hlw_power_calibration) / hlw_cf_pulse_length;
hlw_w = (HLW_PREF * Settings.energy_power_calibration) / hlw_cf_pulse_length;
energy_power = (float)hlw_w / 10;
} else {
energy_power = 0;
@ -186,7 +186,7 @@ void HlwEvery200ms()
hlw_cf1_voltage_max_pulse_counter = hlw_cf1_pulse_counter;
if (hlw_cf1_voltage_pulse_length && (power &1)) { // If powered on always provide voltage
hlw_u = (HLW_UREF * Settings.hlw_voltage_calibration) / hlw_cf1_voltage_pulse_length;
hlw_u = (HLW_UREF * Settings.energy_voltage_calibration) / hlw_cf1_voltage_pulse_length;
energy_voltage = (float)hlw_u / 10;
} else {
energy_voltage = 0;
@ -197,7 +197,7 @@ void HlwEvery200ms()
hlw_cf1_current_max_pulse_counter = hlw_cf1_pulse_counter;
if (hlw_cf1_current_pulse_length && energy_power) { // No current if no power being consumed
hlw_i = (HLW_IREF * Settings.hlw_current_calibration) / hlw_cf1_current_pulse_length;
hlw_i = (HLW_IREF * Settings.energy_current_calibration) / hlw_cf1_current_pulse_length;
energy_current = (float)hlw_i / 1000;
} else {
energy_current = 0;
@ -211,10 +211,10 @@ void HlwEvery200ms()
void HlwInit()
{
if (!Settings.hlw_power_calibration || (4975 == Settings.hlw_power_calibration)) {
Settings.hlw_power_calibration = HLW_PREF_PULSE;
Settings.hlw_voltage_calibration = HLW_UREF_PULSE;
Settings.hlw_current_calibration = HLW_IREF_PULSE;
if (!Settings.energy_power_calibration || (4975 == Settings.energy_power_calibration)) {
Settings.energy_power_calibration = HLW_PREF_PULSE;
Settings.energy_voltage_calibration = HLW_UREF_PULSE;
Settings.energy_current_calibration = HLW_IREF_PULSE;
}
hlw_cf_pulse_length = 0;
@ -241,6 +241,156 @@ void HlwInit()
hlw_cf1_timer = 0;
}
/*********************************************************************************************\
* CSE7766 - Energy (Sonoff S31)
*
* Based on datasheet from http://www.chipsea.com/UploadFiles/2017/08/11144342F01B5662.pdf
\*********************************************************************************************/
#define CSE_NOT_CALIBRATED 0xAA
#define CSE_PREF 1000
#define CSE_UREF 100
uint8_t cse_receive_flag = 0;
bool cse_load_off = 0;
long voltage_cycle = 0;
long current_cycle = 0;
long power_cycle = 0;
long cf_pulses = 0;
long cf_pulses_last_time = 0;
void CseDumpSerial()
{
char svalue[90];
svalue[0] = '\0';
for (byte i = 0; i < serial_in_byte_counter; i++) {
snprintf_P(svalue, sizeof(svalue), PSTR("%s%02X "), svalue, serial_in_buffer[i]);
}
snprintf_P(log_data, sizeof(log_data), PSTR("CSE: " D_RECEIVED " %s"), svalue);
AddLog(LOG_LEVEL_DEBUG);
}
void CseReceived()
{
if (LOG_LEVEL_DEBUG_MORE == Settings.weblog_level) CseDumpSerial();
uint8_t header = serial_in_buffer[0];
if ((header & 0xFC) == 0xFC) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: Abnormal hardware"));
// CseDumpSerial();
return;
}
// Calculate checksum
uint8_t checksum = 0;
for (byte i = 2; i < 23; i++) checksum += serial_in_buffer[i];
if (checksum != serial_in_buffer[23]) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: " D_CHECKSUM_FAILURE));
// CseDumpSerial();
return;
}
// Get chip calibration data (coefficients) and use as initial defaults
if (HLW_UREF_PULSE == Settings.energy_voltage_calibration) {
long voltage_coefficient = 191200; // uSec
if (CSE_NOT_CALIBRATED != header) {
voltage_coefficient = serial_in_buffer[2] << 16 | serial_in_buffer[3] << 8 | serial_in_buffer[4];
}
Settings.energy_voltage_calibration = voltage_coefficient / CSE_UREF;
}
if (HLW_IREF_PULSE == Settings.energy_current_calibration) {
long current_coefficient = 16140; // uSec
if (CSE_NOT_CALIBRATED != header) {
current_coefficient = serial_in_buffer[8] << 16 | serial_in_buffer[9] << 8 | serial_in_buffer[10];
}
Settings.energy_current_calibration = current_coefficient;
}
if (HLW_PREF_PULSE == Settings.energy_power_calibration) {
long power_coefficient = 5364000; // uSec
if (CSE_NOT_CALIBRATED != header) {
power_coefficient = serial_in_buffer[14] << 16 | serial_in_buffer[15] << 8 | serial_in_buffer[16];
}
Settings.energy_power_calibration = power_coefficient / CSE_PREF;
}
uint8_t adjustement = serial_in_buffer[20];
voltage_cycle = serial_in_buffer[5] << 16 | serial_in_buffer[6] << 8 | serial_in_buffer[7];
current_cycle = serial_in_buffer[11] << 16 | serial_in_buffer[12] << 8 | serial_in_buffer[13];
power_cycle = serial_in_buffer[17] << 16 | serial_in_buffer[18] << 8 | serial_in_buffer[19];
cf_pulses = serial_in_buffer[21] << 8 | serial_in_buffer[22];
if (adjustement & 0x80) { // CF overflow
cf_pulses = cf_pulses | 0x10000;
}
if (power &1) { // Powered on
if (adjustement & 0x40) { // Voltage valid
energy_voltage = (float)(Settings.energy_voltage_calibration * CSE_UREF) / (float)voltage_cycle;
}
if (adjustement & 0x10) { // Power valid
if ((header & 0xF2) == 0xF2) { // Power cycle exceeds range
energy_power = 0;
} else {
energy_power = (float)(Settings.energy_power_calibration * CSE_PREF) / (float)power_cycle;
}
} else {
energy_power = 0; // Powered on but no load
}
if (adjustement & 0x20) { // Current valid
if (0 == energy_power) {
energy_current = 0;
} else {
energy_current = (float)Settings.energy_current_calibration / (float)current_cycle;
}
}
} else { // Powered off
energy_voltage = 0;
energy_power = 0;
energy_current = 0;
}
}
bool CseSerialInput()
{
if (cse_receive_flag) {
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
if (24 == serial_in_byte_counter) {
CseReceived();
cse_receive_flag = 0;
return 1;
}
} else {
if (0x5A == serial_in_byte) { // 0x5A - Packet header 2
cse_receive_flag = 1;
} else {
serial_in_byte_counter = 0;
}
serial_in_buffer[serial_in_byte_counter++] = serial_in_byte;
}
serial_in_byte = 0; // Discard
return 0;
}
void CseEverySecond()
{
if (cf_pulses < cf_pulses_last_time) cf_pulses_last_time = 0;
unsigned long cf_frequency = cf_pulses - cf_pulses_last_time;
if (cf_frequency) {
cf_pulses_last_time = cf_pulses;
unsigned long energy_temp = (cf_frequency * Settings.energy_power_calibration) / 36;
energy_kWhtoday += energy_temp;
RtcSettings.energy_kWhtoday = energy_kWhtoday;
energy_total = (float)(RtcSettings.energy_kWhtotal + (energy_kWhtoday / 1000)) / 100000;
energy_daily = (float)energy_kWhtoday / 100000000;
}
}
/********************************************************************************************/
#ifdef USE_PZEM004T
/*********************************************************************************************\
* PZEM004T - Energy
@ -296,7 +446,7 @@ void PzemSend(uint8_t cmd)
PZEMCommand pzem;
pzem.command = cmd;
for (int i = 0; i < sizeof(pzem.addr); i++) {
for (uint8_t i = 0; i < sizeof(pzem.addr); i++) {
pzem.addr[i] = pzem_ip[i];
}
pzem.data = 0;
@ -310,7 +460,7 @@ void PzemSend(uint8_t cmd)
bool PzemReceiveReady()
{
return PzemSerial->available() >= sizeof(PZEMCommand);
return PzemSerial->available() >= (int)sizeof(PZEMCommand);
}
bool PzemRecieve(uint8_t resp, float *data)
@ -389,7 +539,7 @@ void PzemEvery200ms()
if (!energy_startup) {
if (energy_total < energy_start) {
energy_start = energy_total;
Settings.hlw_power_calibration = energy_start * 1000;
Settings.energy_power_calibration = energy_start * 1000;
}
energy_kWhtoday = (energy_total - energy_start) * 100000000;
energy_daily = (float)energy_kWhtoday / 100000000;
@ -431,6 +581,10 @@ void Energy200ms()
HlwEverySecond();
}
if (ENERGY_CSE7766 == energy_flg) {
CseEverySecond();
}
if (RtcTime.valid) {
if (LocalTime() == Midnight()) {
Settings.energy_kWhyesterday = energy_kWhtoday;
@ -442,7 +596,7 @@ void Energy200ms()
#ifdef USE_PZEM004T
if (ENERGY_PZEM004T == energy_flg) {
energy_start = energy_total;
Settings.hlw_power_calibration = energy_start * 1000;
Settings.energy_power_calibration = energy_start * 1000;
}
#endif // USE_PZEM004T
energy_max_energy_state = 3;
@ -454,7 +608,7 @@ void Energy200ms()
energy_kWhtoday = Settings.energy_kWhtoday;
energy_period = energy_kWhtoday;
RtcSettings.energy_kWhtoday = energy_kWhtoday;
energy_start = (float)Settings.hlw_power_calibration / 1000; // Used by PZEM004T to store total yesterday
energy_start = (float)Settings.energy_power_calibration / 1000; // Used by PZEM004T to store total yesterday
energy_startup = 0;
}
}
@ -510,10 +664,10 @@ void EnergySetPowerSteadyCounter()
void EnergyMarginCheck()
{
uint16_t energy_daily_u;
uint16_t energy_power_u;
uint16_t energy_voltage_u;
uint16_t energy_current_u;
uint16_t energy_daily_u = 0;
uint16_t energy_power_u = 0;
uint16_t energy_voltage_u = 0;
uint16_t energy_current_u = 0;
boolean flag;
boolean jsonflg;
@ -724,51 +878,68 @@ boolean EnergyCommand()
command, energy_total_chr, energy_yesterday_chr, stoday_energy);
status_flag = 1;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWPCAL == command_code)) {
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_POWERCAL == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 32001)) {
Settings.hlw_power_calibration = (XdrvMailbox.payload > 4000) ? XdrvMailbox.payload : HLW_PREF_PULSE; // 12530
Settings.energy_power_calibration = (XdrvMailbox.payload > 4000) ? XdrvMailbox.payload : HLW_PREF_PULSE; // HLW = 12530, CSE = 5364
}
nvalue = Settings.hlw_power_calibration;
nvalue = Settings.energy_power_calibration;
unit = UNIT_MICROSECOND;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWPSET == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 3601) && hlw_cf_pulse_length) {
Settings.hlw_power_calibration = (XdrvMailbox.payload * 10 * hlw_cf_pulse_length) / HLW_PREF;
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_POWERSET == command_code)) { // Watt
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 3601)) {
if ((ENERGY_HLW8012 == energy_flg) && hlw_cf_pulse_length) {
Settings.energy_power_calibration = (XdrvMailbox.payload * 10 * hlw_cf_pulse_length) / HLW_PREF;
}
else if ((ENERGY_CSE7766 == energy_flg) && power_cycle) {
Settings.energy_power_calibration = (XdrvMailbox.payload * power_cycle) / CSE_PREF;
}
}
snprintf_P(command, sizeof(command), PSTR(D_CMND_HLWPCAL));
nvalue = Settings.hlw_power_calibration;
snprintf_P(command, sizeof(command), PSTR(D_CMND_POWERCAL));
nvalue = Settings.energy_power_calibration;
unit = UNIT_MICROSECOND;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWUCAL == command_code)) {
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_VOLTAGECAL == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 32001)) {
Settings.hlw_voltage_calibration = (XdrvMailbox.payload > 999) ? XdrvMailbox.payload : HLW_UREF_PULSE; // 1950
Settings.energy_voltage_calibration = (XdrvMailbox.payload > 999) ? XdrvMailbox.payload : HLW_UREF_PULSE; // HLW = 1950, CSE = 1912
}
nvalue = Settings.hlw_voltage_calibration;
nvalue = Settings.energy_voltage_calibration;
unit = UNIT_MICROSECOND;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWUSET == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 501) && hlw_cf1_voltage_pulse_length) {
Settings.hlw_voltage_calibration = (XdrvMailbox.payload * 10 * hlw_cf1_voltage_pulse_length) / HLW_UREF;
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_VOLTAGESET == command_code)) { // Volt
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 501)) {
if ((ENERGY_HLW8012 == energy_flg) && hlw_cf1_voltage_pulse_length) {
Settings.energy_voltage_calibration = (XdrvMailbox.payload * 10 * hlw_cf1_voltage_pulse_length) / HLW_UREF;
}
else if ((ENERGY_CSE7766 == energy_flg) && voltage_cycle) {
Settings.energy_voltage_calibration = (XdrvMailbox.payload * voltage_cycle) / CSE_UREF;
}
}
snprintf_P(command, sizeof(command), PSTR(D_CMND_HLWUCAL));
nvalue = Settings.hlw_voltage_calibration;
snprintf_P(command, sizeof(command), PSTR(D_CMND_VOLTAGECAL));
nvalue = Settings.energy_voltage_calibration;
unit = UNIT_MICROSECOND;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWICAL == command_code)) {
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_CURRENTCAL == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 32001)) {
Settings.hlw_current_calibration = (XdrvMailbox.payload > 1100) ? XdrvMailbox.payload : HLW_IREF_PULSE; // 3500
Settings.energy_current_calibration = (XdrvMailbox.payload > 1100) ? XdrvMailbox.payload : HLW_IREF_PULSE; // HLW = 3500, CSE = 16140
}
nvalue = Settings.hlw_current_calibration;
nvalue = Settings.energy_current_calibration;
unit = UNIT_MICROSECOND;
}
else if ((ENERGY_HLW8012 == energy_flg) && (CMND_HLWISET == command_code)) {
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 16001) && hlw_cf1_current_pulse_length) {
Settings.hlw_current_calibration = (XdrvMailbox.payload * hlw_cf1_current_pulse_length) / HLW_IREF;
else if (((ENERGY_HLW8012 == energy_flg) || (ENERGY_CSE7766 == energy_flg)) && (CMND_CURRENTSET == command_code)) { // milliAmpere
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload < 16001)) {
if ((ENERGY_HLW8012 == energy_flg) && hlw_cf1_current_pulse_length) {
Settings.energy_current_calibration = (XdrvMailbox.payload * hlw_cf1_current_pulse_length) / HLW_IREF;
}
if ((ENERGY_CSE7766 == energy_flg) && current_cycle) {
Settings.energy_current_calibration = (XdrvMailbox.payload * current_cycle) / 1000;
}
}
snprintf_P(command, sizeof(command), PSTR(D_CMND_HLWICAL));
nvalue = Settings.hlw_current_calibration;
snprintf_P(command, sizeof(command), PSTR(D_CMND_CURRENTCAL));
nvalue = Settings.energy_current_calibration;
unit = UNIT_MICROSECOND;
}
#if FEATURE_POWER_LIMIT
else if (CMND_MAXPOWER == command_code) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < 3601)) {
@ -833,9 +1004,9 @@ boolean EnergyCommand()
}
if (!status_flag) {
if (Settings.flag.value_units) {
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_SPACE_UNIT, command, nvalue, GetTextIndexed(sunit, sizeof(sunit), unit, kUnitNames));
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_LVALUE_SPACE_UNIT, command, nvalue, GetTextIndexed(sunit, sizeof(sunit), unit, kUnitNames));
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, nvalue);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_LVALUE, command, nvalue);
}
}
return serviced;
@ -843,17 +1014,31 @@ boolean EnergyCommand()
/********************************************************************************************/
void EnergyInit()
void EnergyDrvInit()
{
energy_flg = ENERGY_NONE;
if ((pin[GPIO_HLW_SEL] < 99) && (pin[GPIO_HLW_CF1] < 99) && (pin[GPIO_HLW_CF] < 99)) {
energy_flg = ENERGY_HLW8012;
HlwInit();
} else if (SONOFF_S31 == Settings.module) {
baudrate = 4800;
serial_config = SERIAL_8E1;
energy_flg = ENERGY_CSE7766;
#ifdef USE_PZEM004T
} else if ((pin[GPIO_PZEM_RX] < 99) && (pin[GPIO_PZEM_TX])) {
if (PzemInit()) {
energy_flg = ENERGY_PZEM004T;
}
#endif // USE_PZEM004T
}
}
void EnergyInit()
{
if (ENERGY_HLW8012 == energy_flg) {
HlwInit();
#ifdef USE_PZEM004T
} else if (ENERGY_PZEM004T == energy_flg) {
// PzemInit();
#endif // USE_PZEM004T
}
@ -938,6 +1123,9 @@ boolean Xdrv03(byte function)
if (energy_flg) {
switch (function) {
case FUNC_INIT:
EnergyDrvInit();
break;
case FUNC_COMMAND:
result = EnergyCommand();
break;

View File

@ -48,6 +48,7 @@ const char kDomoticzSensors[] PROGMEM =
D_DOMOTICZ_TEMP "|" D_DOMOTICZ_TEMP_HUM "|" D_DOMOTICZ_TEMP_HUM_BARO "|" D_DOMOTICZ_POWER_ENERGY "|" D_DOMOTICZ_ILLUMINANCE "|" D_DOMOTICZ_COUNT "|" D_DOMOTICZ_VOLTAGE "|" D_DOMOTICZ_CURRENT "|" D_DOMOTICZ_AIRQUALITY ;
const char S_JSON_DOMOTICZ_COMMAND_INDEX_NVALUE[] PROGMEM = "{\"" D_CMND_DOMOTICZ "%s%d\":%d}";
const char S_JSON_DOMOTICZ_COMMAND_INDEX_LVALUE[] PROGMEM = "{\"" D_CMND_DOMOTICZ "%s%d\":%lu}";
char domoticz_in_topic[] = DOMOTICZ_IN_TOPIC;
char domoticz_out_topic[] = DOMOTICZ_OUT_TOPIC;
@ -127,7 +128,6 @@ void DomoticzMqttSubscribe()
boolean DomoticzMqttData()
{
char stemp1[10];
char scommand[10];
unsigned long idx = 0;
int16_t nvalue;
int16_t found = 0;
@ -165,7 +165,7 @@ boolean DomoticzMqttData()
snprintf_P(XdrvMailbox.data, XdrvMailbox.data_len, PSTR("%d"), nvalue);
found = 1;
} else {
if (((power >> i) &1) == nvalue) {
if (((power >> i) &1) == (power_t)nvalue) {
return 1;
}
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_POWER "%s"), (devices_present > 1) ? stemp1 : "");
@ -205,13 +205,13 @@ boolean DomoticzCommand()
Settings.domoticz_relay_idx[XdrvMailbox.index -1] = XdrvMailbox.payload;
restart_flag = 2;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_DOMOTICZ_COMMAND_INDEX_NVALUE, command, XdrvMailbox.index, Settings.domoticz_relay_idx[XdrvMailbox.index -1]);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_DOMOTICZ_COMMAND_INDEX_LVALUE, command, XdrvMailbox.index, Settings.domoticz_relay_idx[XdrvMailbox.index -1]);
}
else if ((CMND_KEYIDX == command_code) && (XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DOMOTICZ_IDX)) {
if (XdrvMailbox.payload >= 0) {
Settings.domoticz_key_idx[XdrvMailbox.index -1] = XdrvMailbox.payload;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_DOMOTICZ_COMMAND_INDEX_NVALUE, command, XdrvMailbox.index, Settings.domoticz_key_idx[XdrvMailbox.index -1]);
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_DOMOTICZ_COMMAND_INDEX_LVALUE, command, XdrvMailbox.index, Settings.domoticz_key_idx[XdrvMailbox.index -1]);
}
else if ((CMND_SWITCHIDX == command_code) && (XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DOMOTICZ_IDX)) {
if (XdrvMailbox.payload >= 0) {
@ -332,7 +332,6 @@ void HandleDomoticzConfiguration()
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_DOMOTICZ);
char stemp[32];
char *sensortype;
String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_CONFIGURE_DOMOTICZ));

View File

@ -616,7 +616,6 @@ void HueLights(String *path)
String response;
uint8_t device = 1;
uint16_t tmp = 0;
int16_t pos = 0;
float bri = 0;
float hue = 0;
float sat = 0;
@ -624,7 +623,6 @@ void HueLights(String *path)
bool resp = false;
bool on = false;
bool change = false;
char id[4];
uint8_t maxhue = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
path->remove(0,path->indexOf("/lights")); // Remove until /lights

View File

@ -56,7 +56,7 @@ int32_t DhtExpectPulse(byte sensor, bool level)
int32_t count = 0;
while (digitalRead(Dht[sensor].pin) == level) {
if (count++ >= dht_max_cycles) {
if (count++ >= (int32_t)dht_max_cycles) {
return -1; // Timeout
}
}

View File

@ -206,6 +206,7 @@ float HtuCompensatedHumidity(float humidity, float temperature)
if(temperature > 0.00 && temperature < 80.00) {
return (-0.15)*(25-temperature)+humidity;
}
return humidity;
}
/********************************************************************************************/

View File

@ -98,16 +98,16 @@ boolean Bmp180Calibration()
return false;
}
if ((cal_ac1 == 0xFFFF) |
(cal_ac2 == 0xFFFF) |
(cal_ac3 == 0xFFFF) |
if ((cal_ac1 == (int16_t)0xFFFF) |
(cal_ac2 == (int16_t)0xFFFF) |
(cal_ac3 == (int16_t)0xFFFF) |
(cal_ac4 == 0xFFFF) |
(cal_ac5 == 0xFFFF) |
(cal_ac6 == 0xFFFF) |
(cal_b1 == 0xFFFF) |
(cal_b2 == 0xFFFF) |
(cal_mc == 0xFFFF) |
(cal_md == 0xFFFF)) {
(cal_b1 == (int16_t)0xFFFF) |
(cal_b2 == (int16_t)0xFFFF) |
(cal_mc == (int16_t)0xFFFF) |
(cal_md == (int16_t)0xFFFF)) {
return false;
}
return true;
@ -128,9 +128,6 @@ double Bmp180ReadTemperature()
double Bmp180ReadPressure()
{
int32_t p;
uint8_t msb;
uint8_t lsb;
uint8_t xlsb;
I2cWrite8(bmp_address, BMP180_REG_CONTROL, BMP180_PRESSURE3); // Highest resolution
delay(2 + (4 << BMP180_OSS)); // 26ms conversion time at ultra high resolution