This is where solid-state relays (SSRs) are worth considering ... consists of two or three standard components packed into a module (you can even build one yourself). The first component is ...
But what if all you have on hand is an ESP8266? [TechColab] needed to control a solenoid valve with a short pulse via a solid-state relay (SSR) but found that the trusty 555 timer was tricky to ...