Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Not Responding to MQTT #162

Closed
HairBear22 opened this issue Dec 27, 2016 · 13 comments
Closed

Bug: Not Responding to MQTT #162

HairBear22 opened this issue Dec 27, 2016 · 13 comments

Comments

@HairBear22
Copy link

I looked around as best as I could... I hope this isn't too obvious of a fix. But my sonoff isn't responding to cmnd/sonoff/power on, and is flashing it's green LED every 2-3 seconds. The serial output in the Arduino IDE shows a bunch of gibberish everytime it blinks, mostly question marks.

Sample:
G����F_��N������������FG��ECG�������_��Z�������������������V�����������������C������B�����F���F�����_�������Z���������Z����Z������S���������W������C��F_CZ��FF�������F�������������Z����c_�rS�fj�����gg����g�Oc�

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

While looking around I suppose you found the Wiki (at the top of this page).

The serial interface should be set to 115200 baud (unless it's a dual which needs 19200 baud).
Before MQTT can work you'll have to make a connection with your WiFi router so SSID1 and Password1 should be correct (use serial commands or set them in user_config.h and recompile).

@HairBear22
Copy link
Author

HairBear22 commented Dec 27, 2016

Okay, now that I have the serial interface set right, I can see what's going on. It appears the Sonoff is connecting to WiFi fine, but as soon as it connects to the MQTT Server, it crashes.

Example:

ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v09826c6d
~ld
�
00:00:00 APP: Project sonoff (Topic sonoff, Fallback DVES_95450E, GroupTopic sonoffs) Version 3.1.3
00:00:00 Wifi: Connecting to AP1 Time Capsule () in mode 11N as sonoff-1294...
00:00:03 Wifi: Connected
00:00:03 HTTP: Webserver active on sonoff-1294 with IP address 10.0.1.37
10:33:19 MQTT: Attempting connection...
10:33:19 MQTT: Connected

Exception (3):
epc1=0x402026c6 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40000001 depc=0x00000000

ctx: cont 
sp: 3fff0f00 end: 3fff18b0 offset: 01a0

>>>stack>>>
3fff10a0:  3fff10c0 3fff10b0 0000000c 402026a0  
3fff10b0:  3fff1122 3ffee158 feefeffe 3ffe8834  
3fff10c0:  3ffe8ced 0000002b 3ffee158 3fff10f0  
3fff10d0:  00000007 00000000 000000f1 4020647d  
3fff10e0:  00000000 3fff1110 3fff1210 00000002  
3fff10f0:  0000007f feefeffe feefeffe feefeffe  
3fff1100:  4010483c 00080000 7fffffff feefeffe  
3fff1110:  65776f70 00312072 feefeffe feefeffe  
3fff1120:  6f43227b 6e616d6d 00317364 7453223a  
3fff1130:  73757461 6153202c 61446576 202c6174  
3fff1140:  65766153 65746153 7055202c 64617267  
3fff1150:  4f202c65 72756174 52202c6c 61747365  
3fff1160:  202c7472 65736552 57202c74 43696669  
3fff1170:  69666e6f 53202c67 61697265 676f6c6c  
3fff1180:  7953202c 676f6c73 6f4c202c 736f4867  
3fff1190:  4c202c74 6f50676f 202c7472 64495353  
3fff11a0:  53202c31 32644953 6150202c 6f777373  
3fff11b0:  2c316472 73615020 726f7773 202c3264  
3fff11c0:  202c5041 74736f48 656d616e fe007d22  
3fff11d0:  feefeffe feefeffe feefeffe feefeffe  
3fff11e0:  feefeffe feefeffe feefeffe feefeffe  
3fff11f0:  feefeffe feefeffe feefeffe feefeffe  
3fff1200:  feefeffe feefeffe feefeffe feefeffe  
3fff1210:  45574f50 00312052 feefeffe feefeffe  
3fff1220:  5454514d 4552203a 56494543 4f542045  
3fff1230:  20434950 444e4d43 4e4f532f 2f46464f  
3fff1240:  4144202c 53204154 20455a49 44202c37  
3fff1250:  20415441 45574f50 00312052 ffffffff  
3fff1260:  40214df7 00000000 0000007f 00000000  
3fff1270:  00000000 3f800000 007fffff 005858ba  
3fff1280:  3ffedea0 00ffffff 0000004d 00000000  
3fff1290:  ffffffff 00000000 3ffea0e1 00000030  
3fff12a0:  feefeffe feefeffe feefeffe feefeffe  
3fff12b0:  feefeffe feefeffe feefeffe feefeffe  
3fff12c0:  feefeffe feefeffe feefeffe feefeffe  
3fff12d0:  feefeffe feefeffe feefeffe feefeffe  
3fff12e0:  feefeffe feefeffe feefeffe feefeffe  
3fff12f0:  feefeffe feefeffe feefeffe feefeffe  
3fff1300:  000000fe 00000018 0000002b 3fff418c  
3fff1310:  3fff418c 3fff4060 3fff2764 40241c8c  
3fff1320:  3fff288d 3fff15cb ffffffff 00000030  
3fff1330:  0000000a 00008a96 0000000a 40242bd8  
3fff1340:  000000c0 00000010 00000000 3fff26dc  
3fff1350:  3fff4060 3fff405c 00000080 00000006  
3fff1360:  00000000 00000000 3ffea0e1 00000000  
3fff1370:  000019d1 3fff405c 6f6e6f73 00006666  
3fff1380:  00000000 00000000 00000000 00000000  
3fff1390:  00000000 00000000 00000000 00000000  
3fff13a0:  00000000 00000000 00000000 00000000  
3fff13b0:  00000000 00000000 00000003 00000000  
3fff13c0:  3fff405c 3fff4060 00000006 00000001  
3fff13d0:  4010547c 3ffef98f 0000000c 4020ba26  
3fff13e0:  3ffef190 3fff1422 00000031 4020ba26  
3fff13f0:  00000000 3ffef98c 3ffef988 00000000  
3fff1400:  3fff1110 00000001 00000000 3fff1378  
3fff1410:  3fff10f0 3fff1210 3fff13fc 00000000  
3fff1420:  000000f0 3ffe9278 00000001 4020b984  
3fff1430:  3fff1460 00000001 0000000c 00000001  
3fff1440:  0000000c 000016a8 3ffef988 402123f8  
3fff1450:  3fff026d 000016a8 3ffef988 4020df98  
3fff1460:  3fff1501 00000000 3ffef988 4020ddfa  
3fff1470:  00000004 3ffef98b 00000017 3fff022b  
3fff1480:  3fff026d 3ffe87f6 3ffef988 3fff022b  
3fff1490:  3fff026d 3ffe87f6 3ffef988 4020326e  
3fff14a0:  00000002 3fff1510 3ffefb74 4020303e  
3fff14b0:  00000000 00000000 00000000 00000000  
3fff14c0:  00000000 00000000 00000000 00000000  
3fff14d0:  00000000 333a3031 39313a33 ffffff00  
3fff14e0:  3fff14bc 000003c2 000003c2 00000009  
3fff14f0:  00000408 00000000 00000001 00000000  
3fff1500:  00000080 3ffefee0 00000002 40203aa8  
3fff1510:  5454514d 6f43203a 63656e6e 00646574  
3fff1520:  3fff3fec 3fff4060 00000006 00000001  
3fff1530:  4010547c 00334c91 3fff0700 00000001  
3fff1540:  000016a1 3fff3fec 3fff3f64 4020b9c5  
3fff1550:  00000000 3fff1592 00000000 4020ba26  
3fff1560:  4020123a 00001388 3ffef988 4020d8ac  
3fff1570:  3ffef98c 00000000 3fff1590 00000000  
3fff1580:  00000001 3ffef988 00000002 4020d9d5  
3fff1590:  646e6d63 4556442f 35395f53 45303534  
3fff15a0:  3f00232f 00000000 00000000 40212208  
3fff15b0:  3fff01a5 00000021 3ffef98c 3fff16dc  
3fff15c0:  00003a97 3ffef988 00000000 4020dc78  
3fff15d0:  514d0400 3f045454 00000001 00000000  
3fff15e0:  3fff020a 3ffefee1 00000000 000000d1  
3fff15f0:  3fff3ed0 3fff1620 3ffef988 00000000  
3fff1600:  00000080 3ffefee0 3ffef988 402045d7  
3fff1610:  00000000 3fff16a0 312e302e 0037332e  
3fff1620:  40204cac 3ffef950 40212400 402123e8  
3fff1630:  4020aef3 3fff1660 3ffef953 ffffffff  
3fff1640:  2501000a 00ffffff 0101000a 3fff06e4  
3fff1650:  0000000a 00000002 3ffef954 40206e08  
3fff1660:  40229d62 3fff06b4 3ffef955 3ffe8394  
3fff1670:  3fff16a0 3fff16a0 00000002 4010184a  
3fff1680:  2501000a 00ffffff 0101000a 3ffefed8  
3fff1690:  3ffe8394 00000002 3fff06b4 40207048  
3fff16a0:  6c66664f 00656e69 00000020 4010184a  
3fff16b0:  00000005 00000000 00000020 4010184a  
3fff16c0:  3ffe9f95 40104b27 3ffeda20 00000001  
3fff16d0:  00000005 00000000 00000020 656c6574  
3fff16e0:  6e6f732f 2f66666f 0054574c 401026ec  
3fff16f0:  00000000 00000000 0000001f 40105339  
3fff1700:  40229d62 3ffeffbc 3ffef965 3ffe8394  
3fff1710:  4022abaf 00000030 00000013 ffffffff  
3fff1720:  3fff22c4 4020afec 0000001f 3ffefed8  
3fff1730:  3ffe8394 3ffef965 3ffeffbc 40207511  
3fff1740:  4020b8bd 00000030 00000013 ffffffff  
3fff1750:  4020ed55 3fff1850 3fff30d0 3fff06d0  
3fff1760:  00000000 00000000 0000001f 40105339  
3fff1770:  4000050c 3fffc6fc 00000001 3fff30ac  
3fff1780:  40000e27 00000030 00000013 ffffffff  
3fff1790:  40212171 00000001 00000000 00000000  
3fff17a0:  00000000 00000000 00000000 fffffffe  
3fff17b0:  ffffffff 3fffc6fc 00000001 3fff0880  
3fff17c0:  00000000 3fffdad0 3fff0888 00000030  
3fff17d0:  00000000 3fffdad0 3fff0888 00000030  
3fff17e0:  00000000 3fffdad0 3fff0888 00000030  
3fff17f0:  00000000 3fffdad0 3fff0888 00000030  
3fff1800:  2066666f 706f5428 73206369 666f6e6f  
3fff1810:  46202c66 626c6c61 3fff30ac 4020be36  
3fff1820:  3435395f 2c453035 6f724720 6f547075  
3fff1830:  20636970 6f6e6f73 3fff0890 40212760  
3fff1840:  3fffdad0 00000000 3fff30ac 4020ed55  
3fff1850:  3ffe8d70 00000000 000003e8 00000000  
3fff1860:  00000000 00000000 40212150 3fff0890  
3fff1870:  3fffdad0 00000000 3fff0880 3fff0888  
3fff1880:  3fffdad0 00000000 3fff0880 40207575  
3fff1890:  3fffdad0 00000000 3fff0880 4021219c  
3fff18a0:  feefeffe feefeffe 3fff0890 40100718  
<<<stack<<<

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

Try enabling more logging with command seriallog 3 as soon as the first messages come up.

Could you show your user_config.h until line 120

@HairBear22
Copy link
Author

HairBear22 commented Dec 27, 2016

I didn't see a difference when I ran cmnd/sonoff/SerialLog 3, but here is my user_config

`/*********************************************************************************************\
 * User specific configuration parameters
 * 
 * ATTENTION: Changes to most PARAMETER defines will only override flash settings if you change
 *            define CFG_HOLDER. 
 *            Most parameters can be changed online using commands via MQTT, WebConsole or serial
 *
 * Corresponding MQTT/Serial/Console commands in [brackets]
\*********************************************************************************************/

// Enable only one out of five MODULE defines below
#define MODULE                 SONOFF            // Sonoff Basic, Sonoff RF, Sonoff SV, Sonoff Dual, Sonoff TH, S20 Smart Socket
//#define MODULE                 SONOFF_2          // Sonoff Touch, Sonoff 4CH
//#define MODULE                 SONOFF_POW        // Sonoff Pow
//#define MODULE                 MOTOR_CAC         // iTead Motor Clockwise/Anticlockwise
//#define MODULE                 ELECTRO_DRAGON    // Electro Dragon Wifi IoT Relay Board Based on ESP8266

// -- Project --------------------------------
#define PROJECT                "sonoff"     // PROJECT is used as the default topic delimiter and OTA file name
                                            //   As an IDE restriction it needs to be the same as the main .ino file

#define CFG_HOLDER             0x20161209   // [Reset 1] Change this value to load following default configuration parameters
#define SAVE_DATA              1            // [SaveData] Save changed parameters to Flash (0 = disable, 1 - 3600 seconds)
#define SAVE_STATE             1            // [SaveState] Save changed power state to Flash (0 = disable, 1 = enable)

// -- Wifi -----------------------------------
#define STA_SSID1              "Time Capsule"      // [Ssid1] Wifi SSID
#define STA_PASS1              ""  // [Password1] Wifi password
#define STA_SSID2              ""      // [Ssid2] Optional alternate AP Wifi SSID
#define STA_PASS2              ""  // [Password2] Optional alternate AP Wifi password
#define WIFI_HOSTNAME          "%s-%04d"         // [Hostname] Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
#define WIFI_CONFIG_TOOL       WIFI_RESTART    // [WifiConfig] Default tool if wifi fails to connect
                                                 //   (WIFI_RESTART, WIFI_SMARTCONFIG, WIFI_MANAGER, WIFI_WPSCONFIG, WIFI_RETRY)
// -- Syslog ---------------------------------
#define SYS_LOG_HOST           "domus1"        // [LogHost] (Linux) syslog host
#define SYS_LOG_PORT           514             // [LogPort] default syslog UDP port
#define SYS_LOG_LEVEL          LOG_LEVEL_NONE  // [SysLog]
#define SERIAL_LOG_LEVEL       LOG_LEVEL_INFO  // [SerialLog]
#define WEB_LOG_LEVEL          LOG_LEVEL_INFO  // [WebLog]

// -- Ota ------------------------------------
#if (ARDUINO >= 168)
  #define OTA_URL              ""  // [OtaUrl]
#else
  #define OTA_URL              ""  // [OtaUrl]
#endif

// -- MQTT -----------------------------------
// !!! TLS uses a LOT OF MEMORY (20k) so be careful to enable other options at the same time !!!
//#define USE_MQTT_TLS                        // EXPERIMENTAL Use TLS for MQTT connection (+53k code, +20k mem)
                                            //   Needs Fingerprint, TLS Port, UserId and Password
#ifdef USE_MQTT_TLS
  #define MQTT_HOST            "m20.cloudmqtt.com"  // [MqttHost]
  #define MQTT_FINGERPRINT     "A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07"  // [MqttFingerprint]
  #define MQTT_PORT            20123                // [MqttPort] MQTT TLS port
  #define MQTT_USER            "cloudmqttuser"      // [MqttUser] Mandatory user
  #define MQTT_PASS            "cloudmqttpassword"  // [MqttPassword] Mandatory password
#else
  #define MQTT_HOST            "10.0.1.15"     // [MqttHost]
  #define MQTT_PORT            1883         // [MqttPort] MQTT port (10123 on CloudMQTT)
  #define MQTT_USER            ""  // [MqttUser] Optional user
  #define MQTT_PASS            ""  // [MqttPassword] Optional password
#endif

#define MQTT_CLIENT_ID         "DVES_%06X"  // [MqttClient] Also fall back topic using Chip Id = last 6 characters of MAC address

#define SUB_PREFIX             "cmnd"       // Sonoff devices subscribe to:- SUB_PREFIX/MQTT_TOPIC and SUB_PREFIX/MQTT_GRPTOPIC
#define PUB_PREFIX             "stat"       // Sonoff devices publish to:- PUB_PREFIX/MQTT_TOPIC
#define PUB_PREFIX2            "tele"       // Sonoff devices publish telemetry data to:- PUB_PREFIX2/MQTT_TOPIC/UPTIME, POWER/LIGHT and TIME
                                            //   May be named the same as PUB_PREFIX
#define MQTT_TOPIC             PROJECT      // [Topic] (unique) MQTT device topic
#define MQTT_BUTTON_RETAIN     0            // [ButtonRetain] Button may send retain flag (0 = off, 1 = on)
#define MQTT_POWER_RETAIN      0            // [PowerRetain] Power status message may send retain flag (0 = off, 1 = on)

#define MESSAGE_FORMAT         LEGACY       // [MessageFormat] MQTT Message Format (LEGACY or JSON)
#define MQTT_STATUS_ON         "ON"         // Status result when turned on (needs to be a string like "1" or "On")
#define MQTT_STATUS_OFF        "OFF"        // Status result when turned off (needs to be a string like "0" or "Off")

// -- MQTT - Telemetry -----------------------
#define TELE_PERIOD            300          // [TelePeriod] Telemetry (0 = disable, 10 - 3600 seconds)
#define SEND_TELEMETRY_UPTIME               // Enable sending uptime telemetry (if disabled will still send hourly message)
#define SEND_TELEMETRY_WIFI                 // Enable sending wifi telemetry
#define SEND_TELEMETRY_POWER                // Enable sending power telemetry

// -- MQTT - Domoticz ------------------------
#define USE_DOMOTICZ                        // Enable Domoticz (+3k code, +0.2k mem) - Disable by //
  #define DOMOTICZ_IN_TOPIC      "domoticz/in"  // [DomoticzInTopic]
  #define DOMOTICZ_OUT_TOPIC     "domoticz/out" // [DomoticzOutTopic]
  #define DOMOTICZ_RELAY_IDX1    0          // [DomoticzIdx1] Sonoff Relay 1 (0 = disable domoticz)
  #define DOMOTICZ_RELAY_IDX2    0          // [DomoticzIdx2] Sonoff Dual and 4CH Relay 2
  #define DOMOTICZ_RELAY_IDX3    0          // [DomoticzIdx3] Sonoff 4CH Relay 3
  #define DOMOTICZ_RELAY_IDX4    0          // [DomoticzIdx4] Sonoff 4CH Relay 4
  #define DOMOTICZ_KEY_IDX1      0          // [DomoticzKeyIdx1] Button single press (0 = disable)
  #define DOMOTICZ_KEY_IDX2      0          // [DomoticzKeyIdx2] Button double press (0 = disable)
  #define DOMOTICZ_KEY_IDX3      0          // [DomoticzKeyIdx3] Sonoff 4CH Button 3
  #define DOMOTICZ_KEY_IDX4      0          // [DomoticzKeyIdx4] Sonoff 4CH Button 4
  #define DOMOTICZ_UPDATE_TIMER  0          // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional)

// -- HTTP -----------------------------------
#define USE_WEBSERVER                       // Enable web server and wifi manager (+43k code, +2k mem) - Disable by //
//  #define USE_WEMO_EMULATION                // Enable Belkin WeMo PowerSwitch emulation for Alexa (+4k code, +2k mem)
  #define WEB_SERVER           2            // [WebServer] Web server (0 = Off, 1 = Start as User, 2 = Start as Admin)

// -- Time - Up to three NTP servers in your region
#define NTP_SERVER1            "pool.ntp.org"
#define NTP_SERVER2            "nl.pool.ntp.org"
#define NTP_SERVER3            "0.nl.pool.ntp.org"

// -- Time - Start Daylight Saving Time and timezone offset from UTC in minutes
#define TIME_DST               Last, Sun, Mar, 2, +120  // Last sunday in march at 02:00 +120 minutes

// -- Time - Start Standard Time and timezone offset from UTC in minutes
#define TIME_STD               Last, Sun, Oct, 3, +60   // Last sunday in october 02:00 +60 minutes

// -- Application ----------------------------
#define APP_TIMEZONE           1            // [Timezone] +1 hour (Amsterdam) (-12 .. 12 = hours from UTC, 99 = use TIME_DST/TIME_STD)
#define APP_LEDSTATE           LED_POWER    // [LedState] Function of led (LED_OFF, LED_POWER, LED_MQTTSUB, LED_POWER_MQTTSUB, LED_MQTTPUB, LED_POWER_MQTTPUB, LED_MQTT, LED_POWER_MQTT)
#define APP_PULSETIME          0            // [PulseTime] Time in 0.1 Sec to turn off power for relay 1 (0 = disabled)
#define APP_POWERON_STATE      3            // [PowerOnState] Power On Relay state (0 = Off, 1 = On, 2 = Toggle Saved state, 3 = Saved state)

`

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

user_config.h looks OK. I think I can reproduce. Let me investigate

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

Fixed two exceptions in version 3.1.4 just released. Please retry and let me know the results.

@HairBear22
Copy link
Author

So better. A lot better. I got it to boot up, I was able to change the topic, and control it over MQTT.
However, it still crashes occasionally, every few minutes. Here's the relevant serial log:

Exception (9):
epc1=0x40107276 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000631 depc=0x00000000

ctx: cont 
sp: 3fff16d0 end: 3fff18b0 offset: 01a0

>>>stack>>>
3fff1870:  3fffdad0 00000000 00000000 4021083a  
3fff1880:  3fffdad0 00000000 3fff0880 402075b5  
3fff1890:  3fffdad0 00000000 3fff0880 402121c8  
3fff18a0:  feefeffe feefeffe 3fff0890 40100718  
<<<stack<<<

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

Please turn off telemetry with command TelePeriod 0 and see if it still crashes.

If no regular crashes what''s your Topic?

@HairBear22
Copy link
Author

Still crashing - topic is "sonoffA2"

All kinds of crashes from a brief look at the serial log - highlights include exception 9, exception 28, and even some kind of panic.

@HairBear22
Copy link
Author

Okay - as it continues to crash I'm getting every exception known to man - 2, 3, 0

@arendst
Copy link
Owner

arendst commented Dec 27, 2016

Try to catch the output of command status 0.

So many exception more look like a power problem. What kind of sonoff is this? Are you running it from AC or FTDI power?

@HairBear22
Copy link
Author

Here's exception 0:

Exception (0):
epc1=0x4020e000 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000008a depc=0x00000000

ctx: cont 
sp: 3fff16a0 end: 3fff18b0 offset: 01a0

>>>stack>>>
3fff1840:  3fffdad0 00000000 3ffef988 4020decc  
3fff1850:  3ffe8d70 00000000 000003e8 00000000  
3fff1860:  00000000 00000000 4021217c 3fff0890  
3fff1870:  3fffdad0 00000000 3fff0880 3fff0888  
3fff1880:  3fffdad0 00000000 3fff0880 402075a7  
3fff1890:  3fffdad0 00000000 3fff0880 402121c8  
3fff18a0:  feefeffe feefeffe 3fff0890 40100718  
<<<stack<<<

I'm running from FTDI power still, so there's a decent chance I have a loss header or something somewhere.

@HairBear22
Copy link
Author

I'm using the basic sonoff

@arendst arendst changed the title Not Responding to MQTT Bug: Not Responding to MQTT Dec 30, 2016
@arendst arendst closed this as completed Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants