Fork of the espurna firmware for `mhsw` switches
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.

82 lines
3.1 KiB

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