Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7 KiB

8 years ago
  1. # ITead Sonoff Custom Firmware
  2. This is a custom C firmware for [ITead Sonoff][1] Smart WiFi Switch. This device
  3. has an ESP8266 on board with a 8Mbit flash memory chip, a mains to 3V3 transformer
  4. and a relay (GPIO12). It also features a button (GPIO0), a LED (GPIO13) and
  5. an unpopulated header you can use to reprogram it.
  6. ## Features
  7. * WebServer for configuration and simple relay toggle
  8. * You can configure up to 3 WIFI networks
  9. * MQTT support with configurable host and topic
  10. * Manual switch ON/OFF with button
  11. * Visual status of the connection via the LED
  12. ## Flashing
  13. The unpopulated header has all the required pins. My board has a 5 pins header
  14. in-line with the button. They are (from the button outwards):
  15. * 3V3
  16. * RX
  17. * TX
  18. * GND
  19. * MTNS
  20. Last one is not necessary. Mind it's a **3V3 device**, if connected to 5V you will
  21. probably fry it. Button is connected to GPIO0 on the ESP8266 chip, so to enter
  22. flash mode you have to hold the button pressed while powering on the board, then
  23. you can realease it again.
  24. ## Firmware
  25. The project is ready to be build using [PlatformIO][2].
  26. Please refer to their web page for instructions on how to install the builder.
  27. Once installed:
  28. ```bash
  29. > platformio init -b esp01_1m
  30. > platformio run
  31. > platformio run --target upload
  32. > platformio run --target uploadfs
  33. ```
  34. Library dependencies are automatically managed via PlatformIO Library Manager.
  35. ## Usage
  36. On normal boot (i.e. button not pressed) it will execute the firmware.
  37. It configures the hardware (button, LED, relay), the SPIFFS memory access, the
  38. WIFI, the WebServer and MQTT connection.
  39. Obviously the default values for WIFI network and MQTT will probably not match
  40. your requirements. Either it connects to a WiFi or not, it will set up a Soft AP
  41. named "SONOFF_XXXX", where XXXX are the las 2 bytes of the radio MAC. Connect with
  42. phone, PC, laptop, whatever to that network, password is "fibonacci". Once connected
  43. browse to 192.168.4.1 and you will be presented a configuration page where you will
  44. be able to define up to 3 possible WIFI networks and the MQTT configuration parameters.
  45. It will then try to connect to the first WIFI network. If fail it will try the second
  46. in 30 seconds, and so on. Once connected it will try to connect the MQTT server.
  47. The device will publish the relay state to the given topic and it will subscribe to
  48. the same topic plus "/set" for remote switching. So if your topic is "/home/living/switch"
  49. you will be able to switch it on/off sending "1"/"0" to "/home/living/switch/set".
  50. You can also use "{identifier}" as place holder in the topic. It will be translated to
  51. your device ID (same as the soft AP network it creates).
  52. [1]: https://www.itead.cc/sonoff-wifi-wireless-switch.html
  53. [2]: http://www.platformio.org