Control Space

From HSG Wiki
Revision as of 01:09, 1 June 2018 by Thequux (talk | contribs) (Configuration)
Jump to: navigation, search


Building the firmware

Start from https://github.com/arendst/Sonoff-Tasmota. Apply the following patch, fixing the contents of STA_PASS1.

diff --git a/platformio.ini b/platformio.ini
index cb5da39..2fde240 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -65,7 +65,7 @@ monitor_speed = 115200
 ;upload_speed = 115200
 upload_speed = 512000
 upload_resetmethod = nodemcu
-upload_port = COM5
+upload_port = /dev/ttyUSB0
 ; *** Fix Esp/Arduino core 2.4.x induced Tasmota unused floating point includes
 extra_scripts = pio/strip-floats.py
 
@@ -331,3 +331,20 @@ monitor_speed = ${common.monitor_speed}
 upload_speed = ${common.upload_speed}
 upload_port = ${common.upload_port}
 extra_scripts = ${common.extra_scripts}
+
+[env:wemos-d1-mini]
+platform = espressif8266
+framework = arduino
+board = esp01_1m
+board_flash_mode = dout
+build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMQTT_MAX_PACKET_SIZE=1000
+lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
+extra_scripts = pio/strip-floats.py
+
+; *** Serial Monitor options
+monitor_baud = 115200
+
+; *** Upload Serial reset method for Wemos and NodeMCU
+upload_resetmethod = nodemcu
+upload_speed = 115200
+;upload_port = COM6
diff --git a/sonoff/user_config.h b/sonoff/user_config.h
index 8cc07d3..a09444b 100644
--- a/sonoff/user_config.h
+++ b/sonoff/user_config.h
@@ -59,8 +59,8 @@
 #define WIFI_SUBNETMASK        "255.255.255.0"   // [IpAddress3] If not using DHCP set Network mask
 #define WIFI_DNS               "192.168.2.27"    // [IpAddress4] If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
 
-#define STA_SSID1              ""                // [Ssid1] Wifi SSID
-#define STA_PASS1              ""                // [Password1] Wifi password
+#define STA_SSID1              "0x20"            // [Ssid1] Wifi SSID
+#define STA_PASS1              "[redacted]"      // [Password1] Wifi password
 #define STA_SSID2              ""                // [Ssid2] Optional alternate AP Wifi SSID
 #define STA_PASS2              ""                // [Password2] Optional alternate AP Wifi password
 #define WIFI_CONFIG_TOOL       WIFI_WPSCONFIG    // [WifiConfig] Default tool if wifi fails to connect
@@ -79,7 +79,7 @@
 // -- MQTT ----------------------------------------
 #define MQTT_USE               1                 // [SetOption3] Select default MQTT use (0 = Off, 1 = On)
 
-#define MQTT_HOST              ""                // [MqttHost]
+#define MQTT_HOST              "buzz.0x20"       // [MqttHost]
 #define MQTT_FINGERPRINT1      "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07"  // [MqttFingerprint1]
 #define MQTT_FINGERPRINT2      "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07"  // [MqttFingerprint2]
 #define MQTT_PORT              1883              // [MqttPort] MQTT port (10123 on CloudMQTT)
@@ -121,7 +121,7 @@
 // -- HTTP ----------------------------------------
 #define WEB_SERVER             2                 // [WebServer] Web server (0 = Off, 1 = Start as User, 2 = Start as Admin)
 #define WEB_PASSWORD           ""                // [WebPassword] Web server Admin mode Password for WEB_USERNAME (empty string = Disable)
-#define FRIENDLY_NAME          "Sonoff"          // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
+#define FRIENDLY_NAME          "Sonoff SV"       // [FriendlyName] Friendlyname up to 32 characters used by webpages and Alexa
 #define EMULATION              EMUL_NONE         // [Emulation] Select Belkin WeMo (single relay/light) or Hue Bridge emulation (multi relay/light) (EMUL_NONE, EMUL_WEMO or EMUL_HUE)
 
 // -- Time - Up to three NTP servers in your region
@@ -232,7 +232,7 @@
 // -- HTTP ----------------------------------------
 #define USE_WEBSERVER                            // Enable web server and wifi manager (+66k code, +8k mem)
   #define WEB_PORT             80                // Web server Port for User and Admin mode
-  #define WEB_USERNAME         "admin"           // Web server Admin mode user name
+  #define WEB_USERNAME         "0x20"            // Web server Admin mode user name
   #define USE_EMULATION                          // Enable Belkin WeMo and Hue Bridge emulation for Alexa (+16k code, +2k mem)
 
 // -- mDNS ----------------------------------------

Follow the instructions on the above project's wiki to build and install the firmware.

Configuration

Watch the MQTT channels tele/sonoff/INFO1 and tele/sonoff/INFO2 on buzz (username pi/password [redacted]). (e.g., mosquitto_sub -h buzz.0x20 -v -t "tele/sonoff/#") while the device is first booted.

You will see:

tele/sonoff/INFO1 {"Module":"Sonoff Basic","Version":"5.14.0b","FallbackTopic":"DVES_8E52C7","GroupTopic":"sonoffs"}
tele/sonoff/INFO2 {"WebServerMode":"Admin","Hostname":"sonoff-4807","IPAddress":"10.20.1.127"}

There may be other lines between these.

Note the suffix after DVES in the first line and after sonoff- in the second. Make a label containing those suffixes separated by a slash, e.g., for the above lines, the label would be 8E52C7/4807.

I found the following messages useful:

# Set switches to send both transitions. 2 is the same but inverted
cmnd/DVES_189EE1/SwitchMode 1
# Set target device to control from switches. No message controls itself
cmnd/DVES_189EE1/SwitchTopic DVES_1141BC
# Control target device from buttons
cmnd/DVES_189EE1/ButtonTopic DVS_1141BC

# Set relay status (also try ON and OFF)
cmnd/DVES_189EE1/POWER1 TOGGLE