Introduction: Using the Sonoff Basic With ESPHome
The most common devices around your home may not have smart capabilities and sometimes, you might simply want to switch them ON/OFF at predetermined times. We have previously looked at the Sonoff S26 that can be used to do this and we now take a look at another popular solution which is the Sonoff Basic.
Since it does not work with ESPHome out of the box, we will take it apart, flash new firmware to it and configure it within ESPHome. From there, you will be able to push future updates wirelessly, using the OTA feature.
Step 1: Watch the Video
Take a moment to watch the video above as it goes over the entire process and also shows you why it is better for you to use an off the shelf module like the Sonoff Basic instead of building your own - mainly for safety reasons.
Step 2: Enable ESPHome Compatibility
In order to make it compatible with ESPHome, we need to update its firmware. We first need to obtain this firmware which is also called a binary file so open up ESPHome and start by creating a new node. Give it a useful name, select the default board option which is "Generic ESP8266 (for example Sonoff)", and finally, add your WiFi details to complete the setup. Then, use the node options to compile the default firmware and obtain the binary file.
Once done, use the wiring diagram to connect a 3.3V USB to serial converter to the PCB. Please make sure the USB to serial converter is set to 3.3V or else you will damage the ESP8266 chip. You then need to press and hold the switch on the PCB while you connect the USB to serial converter to your computer. Make sure the LED on the PCB does not flash, if it does, then you need to unplug the USB to serial converter power, press and hold the switch down and try again.
Finally, you need to open up the ESPHome flasher tool, select the serial port, binary file and then flash it to the board. Give it a minute to complete and once done, restart the board by disconnecting the power from the USB to serial converter and then plugging it back again. The board will now connect to your WiFi network and you will be able to view it's status as being online under ESPHome. Any future updates will be able to be made using OTA updates.
Step 3: Add Support for Relay & Button
Now that the module is showing up in ESPHome, we need to add support for the relay and control button. This can be done by updating its configuration.
Use the link above to view the final configuration and copy the last section from "binary_sensor" onwards. Paste it in the node configuration file and then hit the upload button to update the node wirelessly. It will automatically update it and the node will then be back up online again after a few seconds. You can now disconnect the USB to serial converter from the PCB and close everything together so that we can test it with mains power.
Step 4: Add Controls
The final step is adding the control entities to the dashboard. Navigate to Configuration->Integrations and click the node name that you had given. Now, click the device that shows up to view all the entities that it contains. Click the button at the bottom to add all the entities to the dashboard, which is also called Lovelace. Follow the on-screen instructions to complete this and you are good to go.
Connect a suitable device to the unit and then use the dashboard to control it. You can also press the button on the module to manually control the device as needed.
CAUTION: The Sonoff basic only has screw terminals for the power pins and not earth so if your device uses the earth connection, then please make sure you manually connect this or else it will be a safety hazard.
If you like projects like these, then please consider subscribing to our YouTube channel using the link below: https://www.youtube.com/channel/UCbWiK1A5RqAugSqu...
Thank you for reading!