As these boards have no USB / UART connection, only Tx/Rx TTL pins on the header for programming, we will need to use a USB to TTL adapter for the first initial configuration.
This only need to be done once, then the board will have ESPHome base config installed and be remotely reachable over WiFi from there on for further programming remotely.
The ESP32 devices are versatile, cheap and relatively easy to use (compared to other Arduino/ESP device methods) programmable IOT platform, that have been fully integrated into Home Assistant.
Some nice benefits of using ESPHome are the array of supported main boards and addons with example code and the handy ability to develop and update ESP devies wihout any full IDE environment, all possible over a web browser from your phone/laptop etc (after the initial ESPhome setup set) allowing for easy modifications and feature enhancements whilst on the road.
There are some boards which feature wide power source options, with relays capable of handling upto 240v AC / 10A and exposed GPIO pins for additonal functionality - ideal for Campervan IOT development.
2 Relay Version
ESP32 Relay Board, DC5-60V Power Supply ESP32 Dual Relay Module ESP32 Development Board ESP32-WROOM
4 Relay Version.
ESP32 WiFiDevelopment Board, 4 Way Relay Module, Programmable Resettable, Wireless, DC5-60V Power Supply
https://devices.esphome.io/devices/AC-DC-ESP32-Relay-x4
A few extras are required to get them running...
USB to TTL adapter with female Dupont header connectors.
3 Pin USB to TTL Serial 3.3V Adapter Cable
Soldering Iron + solder.
The Board will need a few things doing to get it ready...
Solder the 3x header pin rows to the board.
wire up the USB to TTL converter, connecting to the smaller 6 way header pin, the pinout descriptions are detailed in the underside of the board.
5v or 3.3v from the USB to the respective pin on the Board - depending what you have available.
Tx on the USB to Rx on the header pin
Rx on the USB to Tx on the header pin
Gnd on he USB to Gnd (ground) on the Board.
Programming ESPHome base configuration :
Ensure you have the small 2-pin jumper connected to the 6-way header, connecting he GPI0 and Gnd pins. This puts the ESP into programming mode on bootup.
Plug in the USB to TTL adapter and ensure you can see a new `Comm Port` (Com5 in my case).
In Windows, type `Device Manager` into the Search bar, open the app and Navigate to the `Port` list, you should see a USB Serial device connected.
Open a Web Browser and goto `www.ESPHome.web`
Click `Connect` and select the same `USB serial device` which relates to the USB Adapter. (Com5 in my case)
Then select `Prepare for first use`
Click `Install` and wait for a few minutes.
Once this has completed you will need to disconnect the USB adapter - it is only for the inital programming.
remove the 2-pin jumper connection so the baord boots up bormally now.
Check you have removed the 2-pin jumper connection so the board boots up normally now.
Connect up a suitable power source. These boards can accept a wide input range, ensure you connect to the approriate connector block depending on your input power.
Once the Board is powered on and set to boot up in normal mode... it will boot ESPHome and broadcast a default WiFi AP - with a unique SSID based on the boards MAC address... (eg shown on the left)
Use a suitable PC or Phone to connect to the new WiFi AP SSID, no password is required.
Your device may notice the WiFi does not provide `Internet` and ask you to confirm you want to stay connected, accept and ensure its connected.
Browse to http://192.168.4.1 and you should be presented with the Default ESPHome web configuration page.
Enter you chosen WiFi Network where Home Assistant is installed and click Save.
Reboot the device (power it down/up or press the `Reset` physical button)
The temporoary WiFi SSID should stop broadcasting and the ESP device will now connect to the chosen WiFi network.
The ESP device should be connected to the same WiFi network that Home Assistant is connected and available on.
Install the `ESPHome` Integration
wait for the new ESP device to be auto-discovered and `Adopt` into the ESPHome HA integration setup.
Install the new configuration to the device and wait for the installation to complete.
The initial ESPHome configuraion only sets up the basic device and no specific elements.
Refer to the ESPHome website for a full list of supported devices, inputs,outputs and options.... there is example code which can be patched together to simply add functionality and features
https://esphome.io/
https://esp32io.com/
For the 4 way relay.. the following code can be added or use as a basis to build your own.
To edit the device code, navigate to the ESPHome add-on webpage within HA,
Select the ESP device
modify the code, click `edit` .
then click `Save`
and finally `Install`
Select to deploy `wirelessly`
wait while the code is verified, compiled and uploaded to the ESP device,.
The following code adds 4 Relay outputs+GPIO
Relay 1 & 2, are momentary on for 1s, then off.
Relay 3 & 4 are toggle switched.
GPIO 19 pin on the Header is used as a binary input from a door switch, which shorts to ground on contact.
The ESPHome device has been configured and setup directly using the ESPHome `add-in` and now needs to be added into HA as a managed device.
HA will have been notified there is a new device to add and once the device has been setup, (or after) it can be added into HA.
just click `Configure` and add into HA
Select the `Area`
Review the new Device
The device will need to be enclosed, in some material which does not attentuate the WiFi signal.. .so avoid metal and thick materials.
Mount the device within range of the Access Point that it needs to connect to, with Power and the input/output connections.
Check ther ESP device is powered
Check its connected to WiFi:
Check its not broadcasting its default WiFi SSID whic it falls back to uis WiFi becomes unavailable.
Check its visible in HA / ESP Home.
Check the local Web app is functioning:
Browse to its local webpage
Or in the ESPHome app, click `view` to launch a web page view of it.
check the logs:
This can be done via ESPhome app, on the local device Webpage , or connect it directly to a USB port on a computer a (using the USB > TTL adapter) and view using eith ESPHome.web or a Serial telnet applciation like `Putty.exe`.
last resort... plug it into a PC usigng the UB> TTL adapter and `reinitalise` it - starting from scratch.