Revert "v5.10.0a - Fixes ADS1115 and Sonoff Dual R2"

This reverts commit 73547c8bd7.
This commit is contained in:
arendst 2017-12-02 12:38:50 +01:00
parent 73547c8bd7
commit 5731c975e4
7 changed files with 35 additions and 100 deletions

View File

@ -1,62 +0,0 @@
## 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.10.0a** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions
Only Flash Mode DOUT is supported. Do not use Flash Mode DIO / QIO / QOUT as it might seem to brick your device.
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips) for background information.
### ATTENTION Version 5 and up
These versions use a new linker script to free flash memory for future code additions. It moves the settings from Spiffs to Eeprom. If you compile your own firmware download the new linker to your IDE or Platformio base folder. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).
Best practice to implement is:
- Open the webpage to your device
- Perform option ``Backup Configuration``
- Upgrade new firmware using ``Firmware upgrade``
- If configuration conversion fails keep the webpage open and perform ``Restore Configuration``
You should now have a device with 32k more code memory to play with.
### Version Information
- Sonoff-Tasmota provides all (Sonoff) modules in one file and starts with module Sonoff Basic.
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
- After reboot select config menu again or use commands ```GPIOs``` and ```GPIO``` to change GPIO with desired sensor.
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffbasic.jpg" width="250" align="right" />
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki) for more information.<br />
See [Community](https://groups.google.com/d/forum/sonoffusers) for forum and more user experience.
The following devices are supported:
- [iTead Sonoff Basic](https://www.itead.cc/smart-home/sonoff-wifi-wireless-switch-1.html)
- [iTead Sonoff RF](https://www.itead.cc/smart-home/sonoff-rf.html)
- [iTead Sonoff SV](https://www.itead.cc/smart-home/sonoff-sv.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff_th.jpg" width="250" align="right" />
- [iTead Sonoff TH10/TH16 with temperature sensor](https://www.itead.cc/smart-home/sonoff-th.html)
- [iTead Sonoff Dual (R2)](https://www.itead.cc/smart-home/sonoff-dual.html)
- [iTead Sonoff Pow](https://www.itead.cc/smart-home/sonoff-pow.html)
- [iTead Sonoff 4CH](https://www.itead.cc/smart-home/sonoff-4ch.html)
- [iTead Sonoff 4CH Pro](https://www.itead.cc/smart-home/sonoff-4ch-pro.html)
- [iTead S20 Smart Socket](https://www.itead.cc/smart-socket.html)
- [iTead Slampher](https://www.itead.cc/slampher.html)
- [iTead Sonoff Touch](https://www.itead.cc/sonoff-touch.html)
- [iTead Sonoff T1](https://www.itead.cc/sonoff-t1.html)
- [iTead Sonoff SC](https://www.itead.cc/sonoff-sc.html)
- [iTead Sonoff Led](https://www.itead.cc/sonoff-led.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff4ch.jpg" height="250" align="right" />
- [iTead Sonoff BN-SZ01 Ceiling Led](https://www.itead.cc/bn-sz01.html)
- [iTead Sonoff B1](https://www.itead.cc/sonoff-b1.html)
- [iTead Sonoff RF Bridge 433](https://www.itead.cc/sonoff-rf-bridge-433.html)
- [iTead Sonoff Dev](https://www.itead.cc/sonoff-dev.html)
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
- [AI Light or any my9291 compatible RGBW LED](http://www.ebay.com/itm/172644855726)
- MagicHome and AriLux AL-LC01 and AL-LC11
### License
This program is licensed under GPL-3.0

View File

@ -1,7 +1,5 @@
/* 5.10.0a /* 5.10.0a
* Add (experimental) support for sensor SHT3x * Add (experimental) support for sensor SHT3x
* Change ADS1115 default voltage range from +/-2V to +/-4V (#1289)
* Add multipress support and more user configurable options to Sonoff Dual R2 (#1291)
* *
* 5.10.0 20171201 * 5.10.0 20171201
* Upgrade library ArduinoJson to 5.11.2 * Upgrade library ArduinoJson to 5.11.2

View File

@ -1925,7 +1925,7 @@ void ButtonHandler()
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
button = PRESSED; button = PRESSED;
if (0xF500 == dual_button_code) { // Button hold if (0xF500 == dual_button_code) { // Button hold
holdbutton[i] = (Settings.param[P_HOLD_TIME] * (STATES / 10)) -1; holdbutton[i] = (Settings.param[P_HOLD_TIME] * (STATES / 10)) -1;
} }
dual_button_code = 0; dual_button_code = 0;
@ -1952,28 +1952,28 @@ void ButtonHandler()
if ((NOT_PRESSED == button) && (PRESSED == lastbutton[i])) { if ((NOT_PRESSED == button) && (PRESSED == lastbutton[i])) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_LEVEL_01), i +1); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_LEVEL_01), i +1);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
if (!holdbutton[i]) { // Do not allow within 1 second if (!holdbutton[i]) { // Do not allow within 1 second
button_pressed = true; button_pressed = true;
} }
} }
if (button_pressed) { if (button_pressed) {
if (!send_button_power(0, i +1, 2)) { // Execute Toggle command via MQTT if ButtonTopic is set if (!send_button_power(0, i +1, 2)) { // Execute Toggle command via MQTT if ButtonTopic is set
ExecuteCommandPower(i +1, 2); // Execute Toggle command internally ExecuteCommandPower(i +1, 2); // Execute Toggle command internally
} }
} }
} else { } else {
if ((PRESSED == button) && (NOT_PRESSED == lastbutton[i])) { if ((PRESSED == button) && (NOT_PRESSED == lastbutton[i])) {
if (Settings.flag.button_single) { // Allow only single button press for immediate action if (Settings.flag.button_single) { // Allow only single button press for immediate action
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_IMMEDIATE), i +1); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_IMMEDIATE), i +1);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
if (!send_button_power(0, i +1, 2)) { // Execute Toggle command via MQTT if ButtonTopic is set if (!send_button_power(0, i +1, 2)) { // Execute Toggle command via MQTT if ButtonTopic is set
ExecuteCommandPower(i +1, 2); // Execute Toggle command internally ExecuteCommandPower(i +1, 2); // Execute Toggle command internally
} }
} else { } else {
multipress[i] = (multiwindow[i]) ? multipress[i] +1 : 1; multipress[i] = (multiwindow[i]) ? multipress[i] +1 : 1;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_MULTI_PRESS " %d"), i +1, multipress[i]); snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " %d " D_MULTI_PRESS " %d"), i +1, multipress[i]);
AddLog(LOG_LEVEL_DEBUG); AddLog(LOG_LEVEL_DEBUG);
multiwindow[i] = STATES /2; // 0.5 second multi press window multiwindow[i] = STATES /2; // 0.5 second multi press window
} }
blinks = 201; blinks = 201;
} }
@ -1982,33 +1982,33 @@ void ButtonHandler()
holdbutton[i] = 0; holdbutton[i] = 0;
} else { } else {
holdbutton[i]++; holdbutton[i]++;
if (Settings.flag.button_single) { // Allow only single button press for immediate action if (Settings.flag.button_single) { // Allow only single button press for immediate action
if (holdbutton[i] == Settings.param[P_HOLD_TIME] * (STATES / 10) * 4) { // Button hold for four times longer if (holdbutton[i] == Settings.param[P_HOLD_TIME] * (STATES / 10) * 4) { // Button hold for four times longer
// Settings.flag.button_single = 0; // Settings.flag.button_single = 0;
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_SETOPTION "13 0")); // Disable single press only snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_SETOPTION "13 0")); // Disable single press only
ExecuteCommand(scmnd); ExecuteCommand(scmnd);
} }
} else { } else {
if (holdbutton[i] == Settings.param[P_HOLD_TIME] * (STATES / 10)) { // Button hold if (holdbutton[i] == Settings.param[P_HOLD_TIME] * (STATES / 10)) { // Button hold
multipress[i] = 0; multipress[i] = 0;
if (!Settings.flag.button_restrict) { // No button restriction if (!Settings.flag.button_restrict) { // No button restriction
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_RESET " 1")); snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_RESET " 1"));
ExecuteCommand(scmnd); ExecuteCommand(scmnd);
} else { } else {
send_button_power(0, i +1, 3); // Execute Hold command via MQTT if ButtonTopic is set send_button_power(0, i +1, 3); // Execute Hold command via MQTT if ButtonTopic is set
} }
} }
} }
} }
if (!Settings.flag.button_single) { // Allow multi-press if (!Settings.flag.button_single) { // Allow multi-press
if (multiwindow[i]) { if (multiwindow[i]) {
multiwindow[i]--; multiwindow[i]--;
} else { } else {
if (!restart_flag && !holdbutton[i] && (multipress[i] > 0) && (multipress[i] < MAX_BUTTON_COMMANDS +3)) { if (!restart_flag && !holdbutton[i] && (multipress[i] > 0) && (multipress[i] < MAX_BUTTON_COMMANDS +3)) {
boolean single_press = false; boolean single_press = false;
if (multipress[i] < 3) { // Single or Double press if (multipress[i] < 3) { // Single or Double press
if ((SONOFF_DUAL_R2 == Settings.module) || (SONOFF_DUAL == Settings.module) || (CH4 == Settings.module)) { if ((SONOFF_DUAL == Settings.module) || (CH4 == Settings.module)) {
single_press = true; single_press = true;
} else { } else {
single_press = (Settings.flag.button_swap +1 == multipress[i]); single_press = (Settings.flag.button_swap +1 == multipress[i]);
@ -2018,13 +2018,13 @@ void ButtonHandler()
if (single_press && send_button_power(0, i + multipress[i], 2)) { // Execute Toggle command via MQTT if ButtonTopic is set if (single_press && send_button_power(0, i + multipress[i], 2)) { // Execute Toggle command via MQTT if ButtonTopic is set
// Success // Success
} else { } else {
if (multipress[i] < 3) { // Single or Double press if (multipress[i] < 3) { // Single or Double press
if (WifiState()) { // WPSconfig, Smartconfig or Wifimanager active if (WifiState()) { // WPSconfig, Smartconfig or Wifimanager active
restart_flag = 1; restart_flag = 1;
} else { } else {
ExecuteCommandPower(i + multipress[i], 2); // Execute Toggle command internally ExecuteCommandPower(i + multipress[i], 2); // Execute Toggle command internally
} }
} else { // 3 - 7 press } else { // 3 - 7 press
if (!Settings.flag.button_restrict) { if (!Settings.flag.button_restrict) {
snprintf_P(scmnd, sizeof(scmnd), kCommands[multipress[i] -3]); snprintf_P(scmnd, sizeof(scmnd), kCommands[multipress[i] -3]);
ExecuteCommand(scmnd); ExecuteCommand(scmnd);

View File

@ -765,15 +765,15 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
0, 0 0, 0
}, },
{ "Sonoff Dual R2", // Sonoff Dual R2 (ESP8285) { "Sonoff Dual R2", // Sonoff Dual R2 (ESP8285)
GPIO_USER, // GPIO00 Button 0 on header (0 = On, 1 = Off) GPIO_SWT1, // GPIO00 Button 1 on header
GPIO_USER, // GPIO01 Serial RXD and Optional sensor GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0, 0,
GPIO_USER, // GPIO03 Serial TXD and Optional sensor GPIO_USER, // GPIO03 Serial TXD and Optional sensor
0, 0,
GPIO_REL2, // GPIO05 Relay 2 (0 = Off, 1 = On) GPIO_REL2, // GPIO05 Relay 2 (0 = Off, 1 = On)
0, 0, 0, // Flash connection 0, 0, 0, // Flash connection
GPIO_USER, // GPIO09 Button 1 on header (0 = On, 1 = Off) GPIO_SWT2, // GPIO09 Button 2 on header
GPIO_KEY1, // GPIO10 Button on casing GPIO_KEY1, // GPIO10 Button 3 on casing
0, // Flash connection 0, // Flash connection
GPIO_REL1, // GPIO12 Relay 1 (0 = Off, 1 = On) GPIO_REL1, // GPIO12 Relay 1 (0 = Off, 1 = On)
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off) GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)

View File

@ -33,19 +33,19 @@
* ADS1115 * ADS1115
* ------- * -------
* ADS1115_REG_CONFIG_PGA_6_144V // 2/3x gain +/- 6.144V 1 bit = 0.1875mV * ADS1115_REG_CONFIG_PGA_6_144V // 2/3x gain +/- 6.144V 1 bit = 0.1875mV
* ADS1115_REG_CONFIG_PGA_4_096V // 1x gain +/- 4.096V 1 bit = 0.125mV (default) * ADS1115_REG_CONFIG_PGA_4_096V // 1x gain +/- 4.096V 1 bit = 0.125mV
* ADS1115_REG_CONFIG_PGA_2_048V // 2x gain +/- 2.048V 1 bit = 0.0625mV * ADS1115_REG_CONFIG_PGA_2_048V // 2x gain +/- 2.048V 1 bit = 0.0625mV (default)
* ADS1115_REG_CONFIG_PGA_1_024V // 4x gain +/- 1.024V 1 bit = 0.03125mV * ADS1115_REG_CONFIG_PGA_1_024V // 4x gain +/- 1.024V 1 bit = 0.03125mV
* ADS1115_REG_CONFIG_PGA_0_512V // 8x gain +/- 0.512V 1 bit = 0.015625mV * ADS1115_REG_CONFIG_PGA_0_512V // 8x gain +/- 0.512V 1 bit = 0.015625mV
* ADS1115_REG_CONFIG_PGA_0_256V // 16x gain +/- 0.256V 1 bit = 0.0078125mV * ADS1115_REG_CONFIG_PGA_0_256V // 16x gain +/- 0.256V 1 bit = 0.0078125mV
\*********************************************************************************************/ \*********************************************************************************************/
#define ADS1115_ADDRESS_ADDR_GND 0x48 // address pin low (GND) #define ADS1115_ADDRESS_ADDR_GND 0x48 // address pin low (GND)
#define ADS1115_ADDRESS_ADDR_VDD 0x49 // address pin high (VCC) #define ADS1115_ADDRESS_ADDR_VDD 0x49 // address pin high (VCC)
#define ADS1115_ADDRESS_ADDR_SDA 0x4A // address pin tied to SDA pin #define ADS1115_ADDRESS_ADDR_SDA 0x4A // address pin tied to SDA pin
#define ADS1115_ADDRESS_ADDR_SCL 0x4B // address pin tied to SCL pin #define ADS1115_ADDRESS_ADDR_SCL 0x4B // address pin tied to SCL pin
#define ADS1115_CONVERSIONDELAY (8) // CONVERSION DELAY (in mS) #define ADS1115_CONVERSIONDELAY (8) // CONVERSION DELAY (in mS)
/*====================================================================== /*======================================================================
POINTER REGISTER POINTER REGISTER
@ -126,7 +126,7 @@ void Ads1115StartComparator(uint8_t channel, uint16_t mode)
uint16_t config = mode | uint16_t config = mode |
ADS1115_REG_CONFIG_CQUE_NONE | // Comparator enabled and asserts on 1 match ADS1115_REG_CONFIG_CQUE_NONE | // Comparator enabled and asserts on 1 match
ADS1115_REG_CONFIG_CLAT_NONLAT | // Non Latching mode ADS1115_REG_CONFIG_CLAT_NONLAT | // Non Latching mode
ADS1115_REG_CONFIG_PGA_4_096V | // ADC Input voltage range (Gain) ADS1115_REG_CONFIG_PGA_2_048V | // ADC Input voltage range (Gain)
ADS1115_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val) ADS1115_REG_CONFIG_CPOL_ACTVLOW | // Alert/Rdy active low (default val)
ADS1115_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val) ADS1115_REG_CONFIG_CMODE_TRAD | // Traditional comparator (default val)
ADS1115_REG_CONFIG_DR_6000SPS; // 6000 samples per second ADS1115_REG_CONFIG_DR_6000SPS; // 6000 samples per second

View File

@ -84,7 +84,7 @@ void Ads1115Detect()
ADS1115 adc0(ads1115_address); ADS1115 adc0(ads1115_address);
if (adc0.testConnection()) { if (adc0.testConnection()) {
adc0.initialize(); adc0.initialize();
adc0.setGain(ADS1115_PGA_4P096); // Set the gain (PGA) +/-4.096V adc0.setGain(ADS1115_PGA_2P048); // Set the gain (PGA) +/-4.096V
adc0.setRate(ADS1115_RATE_860); adc0.setRate(ADS1115_RATE_860);
adc0.setMode(ADS1115_MODE_CONTINUOUS); adc0.setMode(ADS1115_MODE_CONTINUOUS);
ads1115_type = 1; ads1115_type = 1;

View File

@ -1,7 +1,7 @@
/* /*
xsns_14_sht3x.ino - SHT3X temperature and humidity sensor support for Sonoff-Tasmota xsns_15SHT3X.ino - WeMos SHT30 Shield
Copyright (C) 2017 Theo Arends Copyright (C) 2017 Palich2000
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -20,11 +20,10 @@
#ifdef USE_I2C #ifdef USE_I2C
#ifdef USE_SHT3X #ifdef USE_SHT3X
/*********************************************************************************************\ /*********************************************************************************************\
* SHT3X - Temperature and Humidy * WeMos SHT30 Shield
* https://wiki.wemos.cc/products:d1_mini_shields:sht30_shield
* *
* Required library: none but based on Adafruit Industries SHT31 library * https://github.com/wemos/WEMOS_SHT3x_Arduino_Library
*
* I2C Address: 0x44 or 0x45
\*********************************************************************************************/ \*********************************************************************************************/
#define SHT3X_ADDR_GND 0x44 // address pin low (GND) #define SHT3X_ADDR_GND 0x44 // address pin low (GND)