GithubHelp home page GithubHelp logo

arendst / sonoff-mqtt-ota-arduino Goto Github PK

View Code? Open in Web Editor NEW
618.0 618.0 197.0 6.06 MB

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE - Now EOL

PHP 0.12% Python 0.77% Arduino 90.64% C 0.07% Objective-C 8.09% C++ 0.31%

sonoff-mqtt-ota-arduino's People

Contributors

arendst avatar vondraussen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonoff-mqtt-ota-arduino's Issues

Majordomo: 1 mqtt topic for command and status

Good day. I use majordomo system and in it to display the status of the switch is used MQTT topic which can be 0 or 1. I changed it in the code. When you toogle the switch system sends 0 or 1 in topic which use for status. But when I try to use the same topic for commands and status it doesn't work. I would like to ask if there is way to manage sonoff same MQTT topic which is published status.
Thank you.

WKaku 10k resistor

Hello, I was looking at WKaku schematics and I noticed 10k resistor for GPIO15 is missing. What' s the purpose of that resistor?

Great project! I'm using it on my SONOFF and works perfectly with Home Assistant

Sonoff crashing/looping with Exception (28) error.

Hi Theo,

I've just installed your code to a new Sonoff module. It compiles and uploads fine, but doesn't connect to the wifi. All the parameters appear to be correct, but the esp8266 appears to crash and the restart in a permanent loop. The output from the serial console is -

 ets Jan  8 2013,rst cause:1, boot mode:(3,2)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld
)

Exception (28):
epc1=0x4000bf64 epc2=0x00000000 epc3=0x00000000 excvaddr=0x001bd9b1 depc=0x00000000

ctx: cont 
sp: 3ffeff30 end: 3fff0270 offset: 01a0

Then some more stack data then it starts again.

The Sonoff hardware seems to be OK as I can install the ESPeasy firmware and that seems to work OK, as does the SonoffWebserver firmware. The power supply seems to be ample as I can remotely use the relay with SonoffWebserver. Both of these firmwares connect to the wifi correctly too. Sadly neither have the functionality of your MQTT/OTA firmware.

All this ESP hardware/software is new to me as I'm a long time AVR/Arduino user, and googling hasn't produced anything useful, so I thought I'd cut to the source to see if there's anything fundamentally wrong.

Minor bug - status 1 command

Theo,

First, a very big "Thank You!" for such a marvellous package (I'm a big fan!). I couldn't believe how much functionality you'd managed to get into Sonoff-MQTT-OTA and have it working with a sensible MQTT command/string structure, too.

I've been playing with it quite a bit recently, trying to put together a reference/tutorial with a few working examples and I came across only one obvious anomaly. The "status 1" command produces output on the serial console (whether triggered from the serial console or from MQTT), but doesn't produce any output to MQTT. Plain "status" and "status 2" work fine in all cases.

The main difference seems to be that for the "status 1" command, the output far exceeds the size assigned to svalue[]. With fully qualified hostnames, the output from "status 1" in my case is 140 characters long. It looks as though the issue is that PubSubClient just quietly returns "false" to the publish request, presumably because the size of the data payload is just too big. I tried tweaking the size assignment, but without success. However, if I remove the longest string (sysCfg.otaUrl) from the "status 1" output, it works in both cases (serial monitor and MQTT) as expected. I ended up just creating a couple of other status options (3 & 4) for MQTT and OTA status, respectively:-

if (!strcmp(type,"STATUS")) { sprintf_P(svalue, PSTR("%s, %s, %s, %d, %d"), VERSION, sysCfg.mqtt_topic, sysCfg.mqtt_subtopic, sysCfg.power, sysCfg.timezone); if ((data_len > 0) && (payload == 1)) { sprintf_P(svalue, PSTR("NET: %s, "MQTT_CLIENT_ID", %s, %s, %d, %d"), sysCfg.mqtt_grptopic, ESP.getChipId(), sysCfg.sta_ssid, sysCfg.sta_pwd, heartbeat, sysCfg.saveFlag); // sysCfg.mqtt_grptopic, ESP.getChipId(), sysCfg.sta_ssid, sysCfg.sta_pwd, sysCfg.mqtt_host, heartbeat, sysCfg.saveFlag); } if ((data_len > 0) && (payload == 2)) { sprintf_P(svalue, PSTR("FMWR: Version %s, Boot %d, SDK %s"), VERSION, ESP.getBootVersion(), ESP.getSdkVersion()); } if ((data_len > 0) && (payload == 3)) { sprintf_P(svalue, PSTR("MQTT: %s, MQTT-MAX-PACKET: %d, MQTT-KEEPALIVE: %d"), sysCfg.mqtt_host, MQTT_MAX_PACKET_SIZE, MQTT_KEEPALIVE); } if ((data_len > 0) && (payload == 4)) { sprintf_P(svalue, PSTR("OTA: %s"), sysCfg.otaUrl); } } else if....

(I included the MQTT_MAX_PACKET_SIZE mainly because I thought that might be the problem, when the tweak of svalue[SIZE] didn't work, but it is being set to 1024).

Intermittent Relay Off-On

Hi,

Big thumbs up for the effort to make this available to the everyday tinkerer :) This has allowed me to start to delve into HA and actually make stuff work!

Question though, I have an issue which is noticed when a light is on, intermittently the relay will click off and then back on. It is very quick, and I don't know what could be causing this.

On my HA (OpenHAB) I have taken a look at logs and there is no indication of a change in MQTT status, and in Mosquitto logs it does not show a change in MQTT status for the SonOff, but the relay does click off and back on.

I don't have a consistent timeframe either that I can put this down to.

Any hints where I can start looking? Could it be the SonOff is actually rebooting and then restoring its last known state? Or would this take longer for it to do so and not a click-click that is less than 1/2 second?

Thanks again for the code.

Des.

Enhancement request HTTP server

Hello (again)

I realy like the solution but would like to have a simple HTTP server too. There may be circumstances, where no MQTT broker is available.

I am not sure if the software design allows a simple http server too. A http web server should enable one to check the status (on/off), change the status and possibly start a OTA update.

Unfortunately I am not that familar with ESP8266 and the client and server libs usable.

MANY thanks

Josef

Upgrade error

Hello.
I'm trying upgrade from version 1.0.32 to version 2.0.5.
Through the web-server I get the message:

Upload failed
Update error code 2
Update error code 8

Through OTA I get the message:
Failed HTTP error: connection refused

No response when Mosquitto service is stopped

Hi Theo,

first of all a big THANK YOU for your work.
I tried ESP Easy also, but cannot live with the instabilty which undermines the WAF...

I noticed a small problem which might (or not) apply to your applications of Sonoff too: when the MQTT service cannot be reached, the software remains in a loop to try and (re-)connect. During that time it is unresponsive to the push-button.
In my case this means IT-interventions are neccesary to get the household running again. The other members of the family seem to see this as an issue :-)

I think things would work even better, if manual operation remains possible, even when the MQTT-service cannot be reached.

I tried the following fix:

sonoff.ino.txt

How do you feel about this?

Kind regards,
Rob

DS18B20 on gpio 14?

can i modify the user_config.h so that i can use GPIO14 for DS18B20?

thanks

WIFI connected, but no serial or mqtt response

Hi,

i have a problem with my Sonoff RF devices.
I compiled your software and flashed it, the led blinks, the button works, the rf remote works and WIFI is connected and i can ping the device.

The device is connected to the mqtt server and i could control it. But after a restart of the MQTT Server there comes no response anymore. So i connected the device to a serialport and powered it via a lab psu. In the Serial Monitor i see the start message from the ESP but nothing from your software (and yes i changed the baudrate between the tests but there is nothing :-) ). if i type a command via serial i get a response message via mqtt (but nothing on the serial line) until i restart the mqtt server. Then there comes nothing to.

The USB connection should be ok because i can see the boot message from the esp until "ld"

So i have two problems:

1.) No Serial response on commands
2.) No MQTT reconnect and only sporadic function

I hope you can help me.

Thank you for your great work !!!

Regards

Flo

Stat

I am using Node-Red on a Pi.
I have several Sonoff-MQTT Switches up and working fine.
I would like to read the status of them or get a notification when they switch.
I have tried several combinations using the 'stat' and it does not work for me as expected.
Can you give some examples how it should work?

I have it setup as follows:
cmnd/bedroom/light/power controls the light
I have tried things like:
stat/bedroom/light/power
stat/bedroom/light
cmnd/bedroom/light/info
cmnd/bedroom/light/power/info

Setting time zone

Timezone is set to 99.
Can/how do you set it up for DST/STD and Pacific Time?

When I watch the serial on boot I see:
00:00:10 RTC: (UTC) Sat Oct 22 03:00:34 2016
00:00:10 RTC: (DST) Sun Mar 27 02:00:00 2016
00:00:10 RTC: (STD) Sun Oct 30 03:00:00 2016

I'm a little confused, why so many days between these?
My current time is 8:02 PM Pacific DST.

Once it get NTP sync it goes to shows:
05:02:30 MQTT: oled/TIME = 2016-10-22T05:02:30

PS: Donate Button?

Itead Sonoff RF

Hello,
Please add support for Sonoff RF. I hope it won't be too much work :-)

random reboots and relay clicking... watchdogs and exceptions

setup:
connects to my local wifi, no problem.
connects to my free MQTT instance at http://www.cloudmqtt.com/ no problem

issue:
resets / reboots randomly, sometimes every few seconds, sometimes stays up for 5minutes.

tested with:
Arduino IDE 1.6.12 ( latest )
esp8266 board manager plugin version 2.3.0 ( latest )
Master github code for Sonoff-MQTT-OTA-Arduino from 18th Oct ( practically latest )

notable changes: I'm using WIFI_CONFIG_TOOL => WIFI_MANAGER

more details gleaned from the "webserver information" screen over the course of just a few minutes:

Version 2.0.5
Core/SDK version    2_3_0/1.5.3(aec24ac9)
Uptime  0 Hours
Flash write count   114
Boot count  86
Reset reason    Hardware Watchdog

SSId (RSSI) ***************** (78%)
Hostname    sonoff-5406
IP address  192.168.192.71
Gateway 192.168.192.1
MAC address 60:01:94:07:B5:1E

MQTT Host   m12.cloudmqtt.com
MQTT Port   19498
MQTT Client and
 Fallback Topic DVES_07B51E
MQTT User   ******
MQTT Password   ********
MQTT Topic  sonoff
MQTT Group Topic    sonoffs

ESP Chip id 505118
Flash Chip id   1327343
Flash size  1024kB
Sketch flash size   1024kB
Sketch size 371kB
Free sketch space   568kB
Free memory 32kB


------------------------------------------------------------
Boot count  87
Reset reason    Software/System restart

------------------------------------------------------------
Boot count  88
Reset reason    Hardware Watchdog
------------------------------------------------------------
Boot count  90
Reset reason    Hardware Watchdog
------------------------------------------------------------
Boot count  91
Reset reason    Hardware Watchdog
------------------------------------------------------------
Boot count  94
Reset reason    Hardware Watchdog
------------------------------------------------------------

Boot count  95
Reset reason    Exception
------------------------------------------------------------
Boot count  97
Reset reason    Hardware Watchdog
------------------------------------------------------------
Boot count  98
Reset reason    Exception
------------------------------------------------------------
Boot count  99
Reset reason    Hardware Watchdog
------------------------------------------------------------
Boot count  100
Reset reason    Hardware Watchdog
------------------------------------------------------------

Relay state after power failure

Hi,

I am not sure if I am missing something, but after a power failure the sonoff will always switch the relay on, whether it was on or off before the power failure.

I have played with the following two settings in the config, but it did not change the behavior:

define APP_POWER 0

and

define APP_POWER 1

Is this by design?

Thanks,

Org

Sonoff acts as access point all the time

Is there any reason why Sonoff-MQTT acts always as an AP ESP_hex) instead of as Station only?

This will occupy one additional channel in the WLAN and possibly interfers with existing APs.

Possibly add Wifi.mode(STA).

Feature request: Have you considered a different pubsubclient library

Hi

Great work. I can see a lot of thought has gone into this. Have you considered using lmroy/pubsubclient? I ask because it expands on the original work that Nick O'Leary did and adds a whole bunch of classes, in particular the ability to send QOS 1 & 2 messages, keepalive settings in the sketch etc etc, Would really round off your work quite nicely.

Otherwise great job.

Does not turn on after flash

So I managed to flash it. Says upload complete. But when i put the sonoff in AC current, no LED lights up nor anything happens when i press the button.

Where can i start debugging? Have i bricked my sonoff?

Sonoff does not connect to WiFi

My issue is probably the same as #15 but I do not know how to obtain the serial logging info to be sure. Hence, raising this as a new issue.

I purchased 10 sonoff units from Banggood and set about using them with this firmware. Oddly, the first 4 accepted the new firmware v1.0.14 without drama. None of the other 6 will connect to the WiFi although the firmware is clearly loaded (all of the button push commands work as expected).

I have tried updating to 1.0.16 with the same result, even though the previously working 4 units happily upgraded OTA from 1.0.14 to 1.0.16. They also reset to the default user_config settings which indicates that the build is OK.

All of the units from Banggood have the PCB marking "Sonoff TH" and have 5 holes for headers.

Anyone getting any further with this. Would also appreciate instructions on how to collect debug information from the board so I can post that output here.

BTW - This is an awesome library which should let me add control of all 10 lights in my house using node red - thanks for sharing.

Do you have a 'Donate Button' somewhere?

I love your project. I find it useful. Your support is outstanding. And basically it all works.
I'd like to buy you a beer, pizza or whatever.
If you have a Donate Button somewhere, please let me know.

Thanks
Tim

PlatformIO: Correct version of platform.txt?

Hi Theo,

Looking through the files, I saw that the '2.3.0' version of platform.txt in your git have the wrong version number:

version=2.2.0

Is this intentional or a copy&paste error?

BR, Thomas

typo error under 'Prerequisite'

In the paragraph where you advise changes to MQTT_MAX_PACKET_SIZE & MQTT_KEEPALIVE
you have referred to pubsubclient\src\PubSubClient.h instead of pubsubclient\src\MQTT.h

OTA upload error

Hi Theo!

When doing an upgrade (payload = 1), I keep getting the following response:

cmnd/sonoff6/upgrade : msg.payload : string [1]
1
stat/sonoff6/UPGRADE : msg.payload : string [68]
Upgrade 1.0.33 from http: //api. ...my server... .se/arduino/sonoff.ino.bin

stat/sonoff6/UPGRADE : msg.payload : string [29]
Failed Server not Report Size

If I instead upload using the web-server, then the upgrade goes ok.
I have tried to search for the origin of this error message, but I have failed so far :(
Any ideas?

Cheers,
Thomas

Roadmap Suggestions

Theo,

Your work here is great. Thank you so much.

Last month I built a wishlist of things I was going to add to the project:

  1. wifimanager
  2. more status commands
  3. telemetry messages
  4. compatibility with DHT22 and Elecrodragon

I see that you've already added 1) and 2) THANK YOU

  1. Would it make sense to have the status messages come back in JSON format? That would allow future changes to be backward compatible, but might break existing apps. Example:
    status 3 -> LOG: Seriallog 2, Syslog 0, LogHost p600, SSId B31, Password omnibus
    would change to
    status 3 -> {"LOG" : { "Seriallog" : 2, "Syslog" : 0, "LogHost" : "p600", "SSId" : "B31", "Password" : "omnibus" } }

  2. I really like the way you're using "cmnd/..." and "stat/..." as prefixes. This makes my server code easy to write. I propose adding the "tele/..." prefix for periodic signals (telemetry) from the device. For example, you currently send a HEARTBEAT as
    stat/device_name/HEARTBEAT %d
    Under the telemetry proposal, you could send
    tele/device_name/HEARTBEAT %d
    I originally added this for my DHT22 devices to send back temperature and humidity (and a time-stamp)

tele/Piche_DHT/TEMPERATURE 22.1
tele/Piche_DHT/HUMIDITY 58.3
tele/Piche_DHT/TIME 2016-08-29T09:33:35
  1. I have ported your code over to the ElectroDragon and to an ESP-01+DHT22 temperature/humidity monitor. The ElectroDragon requires two control bits for the two relays. It only has one LED. And the control buttons are inside the protective cabinet. So it's a little more tricky to install; once it's configured, it works very well.

The DHT22 device needs to simply report temperature/humidity on a certain clock tick.

So I propose adding

cmnd/device_name/power2 0/1/on/off    # control ElectroDragon
cmnd/device_name/topic2 topic_name    # I stole topic2 for the 2nd relay
cmnd/device_name/temperature 0/1      # get temperature on demand
cmnd/device_name/humidity 0/1         # get humidity on demand
cmmd/device_name/telemetry_period number_of_seconds  # 0=no telemetry
stat/device_name/POWER2 state         # response to a set/reset/query
stat/device_name/TOPIC2 topic_name
stat/device_name/TELEMETRY_PERIOD number_of_seconds   # response to a set/disable/query
tele/device_name/TEMPERATURE 21.2
tele/device_name/HUMIDITY 45.3
tele/device_name/POWER ON
tele/device_name/POWER2 ON
tele/device_name/TIME YYYY-MM-DDTHH:MM:SS  # sent at the end of a telemetry cluster

I will be happy to write&merge code to implement this later on this year.

OpenHAB2: Switch and status

Hi,
How can I get OpenHAB to update the status of the switch if manually triggered?

This is what I currently have. Switching works but status update doesn't :-(

{mqtt=">[broker:cmnd/sonoff/1/LIGHT/state:command:ON:ON],>[broker:cmnd/sonoff/1/LIGHT/state:command:OFF:OFF],<[broker:stat/sonoff/1/LIGHT:state:default"}

SmartConfig

Hello,
all work properly (communication with MQTT broker is OK, and command are executed by sonoff and stats emitted), but I cannot use SmartConfig app (communication fail, but LED on sonoff is blinking correctly).

SmartConfig is useful to change WiFi settings (by documentation, changing via MQTT commands SSID and pwd in 2 steps is more difficult because I must retain during config 1 old setting on WiFi network before change both).

How can I resolve this issue?

Many thanks in advance

Leonardo

P.S. as suggestion, also solutions like https://github.com/tzapu/WiFiManager can be interesting for my issue

Puzzling corruption

Hi!

I've got a strange corruption issue, which I haven't yet figured.

Using a Sonoff to control a fish tank light via Node-Red/MQTT, which works very nicely. Tried this with firmware as of a month or so ago, and as of about a week ago.

The failure is that after a while (maybe a few days) things fail. The light suddenly develop a mind of its own, turning on/off intermittently (more on than off). It no longer connects to the MQTT server, and on connecting to the serial console, all you see is the watchdog timer being triggered and it repeatedly rebooting - the software itself never seems to initialise properly and it never connects to the MQTT server.

It isn't fixed by power cycling, and reprogramming it is the only way forward.

I've even tried a different sonoff, and after a week or two, it's failed in the same way.

Has anyone seen this yet?

David

ElectroDragon relay reversed

Theo,

I'm sorry, it appears that I gave you the incorrect information about the ElectroDragon relay config.

The easier relay to connect is the one associated with GPIO13 (relay) and GPIO2 (button). I verified this GPIO13/GPIO2 wiring on Rev 1 and Rev 1.1 boards.

So could you please change this code

#elif MODULE == ELECTRO_DRAGON              // programming header 5V/3V/gnd/
  #define APP_NAME             "ElectroDragon module"
  #define LED_PIN              16           // GPIO 16 = Led (0 = Off, 1 = On)
  #define LED_INVERTED         0            // 0 = (1 = On, 0 = Off), 1 = (0 = On, 1 = Off)
  #define REL_PIN              12           // GPIO 12 = Red Led and Relay 2 (0 = Off, 1 = On)
  #define KEY_PIN              0            // GPIO 00 = Button 2
  #define REL1_PIN             13           // GPIO 13 = Red Led and Relay 1 (0 = Off, 1 = On)
  #define KEY1_PIN             2            // GPIO 02 = Button 1

into this new code

#elif MODULE == ELECTRO_DRAGON              // programming header 5V/3V/gnd/
  #define APP_NAME             "ElectroDragon module"
  #define LED_PIN              16           // GPIO 16 = Led (0 = Off, 1 = On)
  #define LED_INVERTED         0            // 0 = (1 = On, 0 = Off), 1 = (0 = On, 1 = Off)
  #define REL_PIN              13           // GPIO 13 = Red Led and Relay 1 (0 = Off, 1 = On)
  #define KEY_PIN              2            // GPIO 02 = Button 1
  #define REL1_PIN             12           // GPIO 12 = Red Led and Relay 2 (0 = Off, 1 = On)
  #define KEY1_PIN             0            // GPIO 00 = Button 2

Thanks

NOTE:

  • There is a JPEG of Rev 1.1 on the ED website that seems to have incorrect information; I should have checked with the hardware; my apologies.
  • I have not checked this wiring on the newest boards that use the 5A relays.
  • The inverted LED works perfectly

DHT22

Hello, thank you so much for your work! I have a Sonoff TH board and was wondering if you were going to add DHT22 capabilities to the code any time in the future. Just wondering, thanks again!

Itead Sonoff Pow

I've just ordered a few Sonoff Pow. Schematics are available here. Looks good to be compatible. Are there any plans to integrate the new telemetry power consumption? I would be able to provide first data (as soon as they arrive) if needed.

Upgrade from Sonoff-MQTT-OTA?

Hi Theo!

First - thanks for your great work and inspiration! :)

Secondly - I have some Sonoff units flashed with Sonoff-MQTT-OTA, and I wonder if it is possible to OTA upgrade these to Sonoff-MQTT-OTA-Arduino? I did a simple test, but it just seemed to keep the older version.
Or do I have to disconnect them and upgrade using the serial cable?

Best regards,
Thomas

MQTT-commands

Hi,

I cannot get the MQTT-commands to work.

The name of the Sonoff: "DVES_06E890"
The topic I subscribed the Sonoff to: "sonoff"

What is wrong with my command that I enter in the terminal?

mosquitto_pub -t 'cmnd/sonoff' -h localhost -m 'cmnd/sonoff/power toggle'

It connects fine to my MQTT server (Mosquitto)

1476372515: New client connected from 192.168.1.221 as DVES_06E890 (c1, k120, ulennart).
1476372515: Sending CONNACK to DVES_06E890 (0)
1476372515: Received SUBSCRIBE from DVES_06E890
1476372515: cmnd/sonoff/# (QoS 0)
1476372515: DVES_06E890 0 cmnd/sonoff/#
1476372515: Sending SUBACK to DVES_06E890
1476372515: Received SUBSCRIBE from DVES_06E890
1476372515: cmnd/sonoffs/# (QoS 0)
1476372515: DVES_06E890 0 cmnd/sonoffs/#
1476372515: Sending SUBACK to DVES_06E890
1476372515: Received SUBSCRIBE from DVES_06E890
1476372515: cmnd/DVES_06E890/# (QoS 0)
1476372515: DVES_06E890 0 cmnd/DVES_06E890/#
1476372515: Sending SUBACK to DVES_06E890
1476372515: Received PUBLISH from DVES_06E890 (d0, q0, r0, m0, 'stat/sonoff/INFO', ... (69 bytes))
1476372515: Received PUBLISH from DVES_06E890 (d0, q0, r0, m0, 'stat/sonoff/INFO', ... (71 bytes))

No matter what I try I always get this output:

16:35:49 MQTT: Receive topic cmnd/sonoff, data cmnd/sonoff/power toggle
16:35:49 MQTT: DataCb Topic sonoff, Group 0, Device 1, Type , data cmnd/sonoff/power toggle (CMND/SONOFF/POWER TOGGLE)
16:35:49 MQTT: sonoff/SYNTAX = Status, SaveData, SaveSate, Upgrade, Otaurl, Restart, Reset, WifiConfig, Seriallog, Weblog, Syslog, LogHost, LogPort, SSId, Password, Hostname, Webserver
16:35:49 MQTT: sonoff/SYNTAX = MqttHost, MqttPort, MqttUser, MqttPassword, MqttClient, Topic, ButtonTopic, ButtonRetain, GroupTopic, Timezone, Light, Power, Ledstate, TelePeriod

I tried all sort of combinations but I always get the same output. It must be something really simple that I am doing wrong. Can anyone guide my in the right direction?

Button press behavior

I have two Sonoff units that I flashed with this software.
For some reason there is a different behavior of the button press when the units are connected directly to the FTDI converter. In this case one short button press does exactly what the description mentioned: It toggles the relay on/off and sends an MQTT message.
This behavior changes when the units are powered from mains. In this case one short button press does nothing except for the LED blinking twice. No relays, no MQTT message. Two short presses on the other hand switch the relay and send stats/LIGHT on/off.

Any idea why this happens?

Would you care to elaborate on the differences between these three points:
a short press toggles the relay. This will blink the LED twice and sends a MQTT status message like stat/sonoff/POWER on

a short press toggles the relay either by sending a MQTT message like cmnd/sonoff/light 2 or directly. This will blink the LED twice and sends a MQTT status message like stat/sonoff/LIGHT on

two short presses toggles the relay. This will blink the LED twice and sends a MQTT status message like stat/sonoff/POWER on

Support for new sonoff device

Your continued pace of development with this software is impressive, and welcomed.

Just wondering if you are planning to support the new Sonoff board DC 5V-24V DIY WIFI Wireless Switch Sonoff SV Module For Smart Home? I've got one on order and will see if it works when I get it in a week or so.

One possible use is to control a garage door -- so I'm guessing that I'm going to need a push-button type output.

Thanks again for sharing - I've used v1.30 to connect 9 lights to my Home Assistant setup in a Pi.

Problems with Temp/Humidity

Hi,

I got my new Sonoff, configured the user_config file including uncommenting #define SEND_TELEMETRY_DHT, and programmed the Sonoff.

I then plugged in the temp/humidity sensor (all the way until you hear the click and it's securely plugged in) and waited for temp/humidity telemetry data.. Nada. All I get is this:

2:17:53 MQTT: sonoff/UPTIME = 0
12:17:53 MQTT: sonoff/RSSI = 100
12:17:53 MQTT: sonoff/LIGHT = On
12:17:53 MQTT: sonoff/TIME = 2016-10-11T12:17:53

I notice the time is wrong also (I assumed 10 would be correct as I'm in Brisbane/Australia).

Any ideas as to what might be wrong?

EDIT: I've since found, set, recompiled and uploaded new firmware with the following setting:

#define DHT_TYPE             AM2301

Still Nada.

Regards,
Michal

Wifi wkaku

Theo, great project tx. Have tried it on a a sonoff and a generic homebrew module.

I notice from the pics of your Wifi wkaku hack that the PSU has the 3.3v pin soldered. I also use similar modules and they have pads for a 1117 LDO regulator but usually no output caps, am assuming the caps on your pic are for 3.3v smoothing? Would e great if you could share your PCB design. Am curious about your ESP vertical mount as well, cool approach.

Tx, Sven

PS Am not very impressed with smartconfig but have played with WPS which works great, any thoughts why you did not go that route?

OTA UPLOAD failed

Hi Theo - thanks for sharing your great work.

I have 10 sonoff's running with v1.20 and have upgraded one to v1.30 using the serial transfer. However, the any upgrade OTA gives the following error...

3 September 2016 at 4:22:11 PM AESTa9885435.617ab8
stat/sonoff/UPLOAD : msg.payload : string [74]
Upgrade 1.0.30 from http://192.168.159.183:8081/api/arduino/sonoff.ino.bin
3 September 2016 at 4:22:16 PM AESTa9885435.617ab8
stat/sonoff/UPGRADE : msg.payload : string [20]
Failed To less space

Can you tell what I have done wrong? Here is full status information for the unit

1.0.30, sonoff, 0, LIGHT, 0, 99, 1

PRM: GroupTopic sonoffs, OtaUrl http://192.168.159.183:8081/api/arduino/sonoff.ino.bin, Uptime 1 Hr, Bootcount 3, SaveCount 8

FWR: Version 1.0.30, Boot 31, SDK 1.5.3(aec24ac9)

LOG: Seriallog 2, Weblog 2, Syslog 0, LogHost 192.168.159.195, SSId Barrow Place 600, Password xxxxx, TelePeriod 300

MEM: Sketch size 321kB, Free 104kB (Heap 39kB), Spiffs start 428kB (64kB), Flash size 1024kB (512kB)

NET: Host sonoff-0421, IP 192.168.159.129, Gateway 192.168.159.1, Subnetmask 255.255.255.0, Mac 5C:CF:7F:1C:A1:A5, Webserver 0

MQT: Host 192.168.159.195, Port 1883, Client DVES_%06X (DVES_1CA1A5), User bphauser, Password xxxx, MAX_PACKET_SIZE 256, KEEPALIVE 120

TIM: UTC Sat Sep 03 07:32:52 2016, Local Sat Sep 03 17:32:52 2016, Start DST Sun Oct 02 02:00:00 2016, End DST Sun Apr 03 02:00:00 2016

PlatformIO: Assistance with platformio compile

I fully understand that this is possibly an unreasonable request, but here goes...

I am trying to compile with platformio (on atom) against the espressif generic ESP8266-01 1M board and receive this error:

/Users/nigelball/Downloads/Sonoff-MQTT-OTA-Arduino-master/sonoff/src/sonoff.ino:204:25: error: variable or field 'WIFI_wps_status_cb' declared
void
strlcpy(sysCfg.hostname, WIFI_HOSTNAME, sizeof(sysCfg.hostname));
^
/Users/nigelball/Downloads/Sonoff-MQTT-OTA-Arduino-master/sonoff/src/sonoff.ino:204:25: error: 'wps_cb_status' was not declared in this scope

Any help would be appreciated - I'm a newbie at Arduino and a total newb at platformio!.

upload error

config:30: error: redefinition of 'void CFG_Default()'

Compiles and uploads but unit non responsive

Hi there,

Great work. Uploaded this today on 3 x Sonoff with 5 pin header after identifying the right pins. Uploaded fine and unit is joining WiFi (router leasing address) but the switch does not work to pulse the relay. Can you advise how I go about debugging this? I tried R94 of ESPEasy on one and that works just fine so I know the board/s are OK and everything is working.

MQTT Timing

I have been playing around with this firmware for a week or so now.

I've noticed that if I publish 5 times cmnd/sonoff/? to fast it will cause a reboot.
eg:
cmnd/sonoff/power
cmnd/sonoff/light
cmnd/sonoff/ledstate
cmnd/sonoff/grouptopic
cmnd/sonoff/timezone
....etc

75 millisecond delay between pubs is sufficient to not cause reboot

(actual project name and prefix are different from default but you get the idea).

from serial debug:
Wifi: Check connection
[hostByName] Host: 192.168.2.21 is a IP!
:rn 28
:c0 1, 28
DebugMsg MQTT: Receive topic lights/bedsidelamp/topic, data
MQTT: Receive topic lights/bedsidelamp/topic, data
[hostByName] Host: 192.168.2.21 is a IP!
DebugMsg MQTT: DataCb Topic bedsidelamp, Group 0, Type TOPIC, data ()
MQTT: DataCb Topic bedsidelamp, Group 0, Type TOPIC, data ()
[hostByName] Host: 192.168.2.21 is a IP!
:wr
:sent 41
:ww
DebugMsg MQTT: bedsidelamp/TOPIC = bedsidelamp
MQTT: bedsidelamp/TOPIC = bedsidelamp
[hostByName] Host: 192.168.2.21 is a IP!
:rn 31
:c0 1, 31
DebugMsg MQTT: Receive topic lights/bedsidelamp/ledstate, data
MQTT: Receive topic lights/bedsidelamp/ledstate, data
[hostByName] Host: 192.168.2.21 is a IP!
DebugMsg MQTT: DataCb Topic bedsidelamp, Group 0, Type LEDSTATE, data ()
MQTT: DataCb Topic bedsidelamp, Group 0, Type LEDSTATE, data ()
[hostByName] Host: 192.168.2.21 is a IP!
:wr
:sent 35
:rn 33
:ww
DebugMsg MQTT: bedsidelamp/LEDSTATE = On
MQTT: bedsidelamp/LEDSTATE = On
[hostByName] Host: 192.168.2.21 is a IP!
:c0 1, 33
DebugMsg MQTT: Receive topic lights/bedsidelamp/grouptopic, data
MQTT: Receive topic lights/bedsidelamp/grouptopic, data
[hostByName] Host: 192.168.2.21 is a IP!
DebugMsg MQTT: DataCb Topic bedsidelamp, Group 0, Type GROUPTOPIC, data ()
MQTT: DataCb Topic bedsidelamp, Group 0, Type GROUPTOPIC, data ()
[hostByName] Host: 192.168.2.21 is a IP!
:wr
:sent 47
:rn 31
:ww
DebugMsg MQTT: bedsidelamp/GROUPTOPIC = bedsidelamps
MQTT: bedsidelamp/GROUPTOPIC = bedsidelamps
[hostByName] Host: 192.168.2.21 is a IP!
:c0 1, 31
DebugMsg MQTT: Receive topic lights/bedsidelamp/timezone, data
MQTT: Receive topic lights/bedsidelamp/timezone, data
[hostByName] Host: 192.168.2.21 is a IP!
DebugMsg MQTT: DataCb Topic bedsidelamp, Group 0, Type TIMEZONE, data ()
MQTT: DataCb Topic bedsidelamp, Group 0, Type TIMEZONE, data ()
[hostByName] Host: 192.168.2.21 is a IP!
:wr
:sent 35
:rn 28
:ww
DebugMsg MQTT: bedsidelamp/TIMEZONE = 10
MQTT: bedsidelamp/TIMEZONE = 10
[hostByName] Host: 192.168.2.21 is a IP!
:c0 1, 28
DebugMsg MQTT: Receive topic lights/bedsidelamp/power, data
MQTT: Receive topic lights/bedsidelamp/power, data
[hostByName] Host: 192.168.2.21 is a IP!
DebugMsg MQTT: DataCb Topic bedsidelamp, Group 0, Type POWER, data ()
MQTT: DataCb Topic bedsidelamp, Group 0, Type POWER, data ()
[hostByName] Host: 192.168.2.21 is a IP!
:wr
:sent 32
:ww
DebugMsg MQTT: bedsidelamp/POWER = On
MQTT: bedsidelamp/POWER = On
[hostByName] Host: 192.168.2.21 is a IP!
Fatal exception 3(LoadStoreErrorCause):
epc1=0x402021e2, epc2=0x00000000, epc3=0x00000000, excvaddr=0x4020be5a, depc=0x00000000

Exception (3):
epc1=0x402021e2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4020be5a depc=0x00000000

ctx: cont
sp: 3fff1660 end: 3fff2c5c offset: 01a0

stack>>>
....
Soft WDT reset
ctx: cont
sp: 3fff1290 end: 3fff2c5c offset: 01b0
....
<<<stack<<<

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

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

Unable to use topic with forward slash for "topic levels"

Hey there,

first of all I want to thank you for your great work! It works just fine for me except for one problem. I am quiete new to mqtt and arduino. I want to use topic names like home//light to be able to switch on all lights in all rooms using "home/+/light". So I changed the PROJECT variable in the sonoff.ino file to "home/myname/light". I didn't change the SUB_PREFIX variable or any other MQTT variable.
Using the MyMQTT Android-App and the topic "cmnd/home/myname/light/power" and message "toggle" doesnt do anything. It does work with a PROJECT variable like "myname" though.

Am I missing something or is this an actual bug/missing feature?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.