Remote start single Phase Submersible Pump starter (with OLR and Relays)

Trying to start an agricultural pump which is located 300 km away from where I am staying now. This is a single phase pump connected with single phase starter unit. There are 3 capacitors (1 x start capacitor and 2x Run capacitors), Over Load Relay and 2 Pole contactor. I am trying to automate the pump starting and stopping via schedule or ad-hoc as per the need. This starter has one non-contact push switch to start and another one to stop. I am trying to set up a parallel circuit that can be started/stopped from a 16A switch that is cloud operated(Similar to Tuya). I am keeping 3 relays (30A/240V with Optocoupler) that will work in place of the 1 NC(Stop) and 2 NO switches(start and Run). The cloud based switch will be providing 230v supply to 1 Channel 220V AC Optocoupler Isolation Module (This one). Based on the AC presence detection from the Opto-Isolation, esp8266 d1 mini will start the first NO relay (marked as Start), wait for 4 seconds and will Switch the relay Off. In parallel it will close the 2nd NO (Marked as Run) after 4 seconds and will keep it in closed state. If we want to stop the pump, we will toggle the cloud based switch to Off state. This will update the d1 mini to push the Stop (NC) Relay and move the Start and Run Relays to NO state.

I am attaching a sample code here (portion of the logic) and schematic diagram. Connectivity till the Coil Relay is currently there today. The connection below the coil relay are yet to be set up. I am waiting for the optocoupler-isolation and relays to be delivered. I will update my remaining YAML post that.
Since its a remote area, we don’t have any system running Home Assistant. Post programming and validations, the d1 mini will be disconnected from the local network, connected using Mobile based internet and will be moved to destination. I will take necessary modification in the YAML, so the d1 mini will not reboot without Home Assistant’s connectivity.
Is this a workable solution? Are there any better approach for me to trigger the relays using the d1 mini? With the lack of Home Assistant or any other computer in the destination, operating d1 mini remotely is not feasible. Looking for your suggestions and inputs.

captive_portal:
web_server:
  port: 80

switch:
  - platform: gpio
    pin: D1
    name: "Start"
    id: relay1
    inverted: True
    restore_mode: ALWAYS_OFF
    on_turn_on:
    - delay: 4s
    - switch.turn_off: relay1
    - switch.turn_on: relay2

  - platform: gpio
    pin: D2
    name: "Run"
    id: relay2
    inverted: True
    restore_mode: ALWAYS_OFF

Probably. Will there be internet at the destination? How do you plan to connect to the device?

Thanks for your immediate reply on this. Yes, the internet will be provided via 4G Dongle. The Smart Switch (Cloud Based) and the D1 Mini will be connecting to same WiFi network provided by this Dongle. In order to make sure there are no surprises, I will test that entire solution at my place using some test lamps before moving to destination.

On what hardware?

Something similar to this one with inbuilt battery.These are mobile SIM based devices.

I am beginning to get the picture. Will you be using a router or just a single ESP device on the LAN? Connected by Ethernet?

This device will work similar to Mobile hotspot that we enable in our phone. It will act like a Wireless Acess Point + Router. More than one device can connect to it and share the internet bandwidth. We may only send the signals to On or Off, The D1 mini and smart switch will be using it for NTP there will not be much traffic. You may get additional information from here

Can you set the IP of the router?
If you can, then you may be able to make a VPN connection to the Wemos.

That’s interesting to know. Are there documentation or link that I refer to? I will have a look at that.

It’s something I have been experimenting with and I am impressed with what I am seeing. It’s called Zerotier. According to their docs- I haven’t tried it- you can put Zerotier on some routers making the remote location part of your LAN.

Thanks for sharing the details. I did go through supported devices. No one is staying at present in the the location I am going to deploy this particular setup, no high end devices are there. I will explore the zerotier for other user cases where the supported devices like opnsense, etc., exist.

Found some logical errors while reviewing the connection diagram. I have updated with additional details and corrected the error especially around the “Stop” button section.

I have tested the above connections with esp32, Isolator and 4 relays. It is working with below given YAML. Since I need 2 ADC inputs to check voltage as input and to prevent dry run, I have changed my design to use esp32 instead of d1 mini.

However there is a challenge. Since Opto-Isolator’s output is low when the AC side is powered on, my logic is working in opposite direction. That is, when my cloud based smart electrical switch is powered on, my device connected after the relay is off. When the smart switch is off, the device is getting switched on. I know I can take the voltage value as low instead of high, try to power on the device. However for some reason my cloud based switch fails then the device will be automatically switched on, which I don’t want to happen. If there are any other option or logic that can be modified?

esphome:
  name: es32motorstart
  friendly_name: es32motorstart

esp32:
  board: esp32dev
  framework:
    type: arduino

switch:
  - platform: gpio
    pin: GPIO23  
    id: relay1
    name: "Stop Motor"

  - platform: gpio
    pin: GPIO25  
    id: relay2
    name: "Start Motor" #Here I am giving same GPIO to turn on "start capacitor relay" as well to avoid any time delay. I have tested and it is working fine in my test bench. 

  #- platform: gpio
  #  pin: GPIO26  
  #  id: relay3
  #  name: "Start Capacitor"

  - platform: gpio
    pin: GPIO27  
    id: relay4
    name: "Solenoid 1"

  - platform: template        
    name: "Motor Power"
    id: motor_power
    optimistic: true 

sensor:
  - platform: adc
    pin: GPIO39
    id: optovolt
    attenuation: 6dB
    accuracy_decimals: 1
    name: "Opto Volt"
    update_interval: 10s
    filters:
      - calibrate_linear:
          - 0.1 -> 0
          - 0.2 -> 0        
          - 0.3 -> 0
          - 0.4 -> 0
          - 0.5 -> 0
          - 0.7 -> 0
          - 0.8 -> 0
          - 0.9 -> 0
          - 1.2 -> 3.2
          #- 3.83 -> 3.0
    on_value_range:
      - above: 2.5    
        below: 3.5
        then:
          - if:
              condition:
                switch.is_off: motor_power
              then:                     
                - switch.turn_on: relay2 # relay 3 is also connected and will be turned on
                - switch.turn_on: motor_power
                #- switch.turn_on: relay2
                - delay: 4s
                - switch.turn_off: relay2  # relay 3 is also connected and will be turned off
                #- switch.turn_off: relay2
      - below: 2.4
        then:
          - if:
              condition:
                switch.is_on: motor_power
              then:  
                - switch.turn_on: relay1
                - delay: 2s
                - switch.turn_off: relay1
                - switch.turn_off: motor_power

Thanks for your suggestion about zerotier. We are planning to deploy this definitely in phase 2 of this setup we are working on. I am going through relevent HACS addons and other things. In future a Raspberry Pi 5 will be deployed with Home Assistant and Zero Tier for remote management and Integrations in the farm shelter. :handshake:

I only recently heard about Zerotier, and decided to try it out. Shortly after I heard about Tailscale, and decided to try that out, too. I personally decided to go with Tailscale, and it works really well.

I recently tested with zero tier. Since you tried both are you finding any specific advantage compared to zero tier?

I think I just found Tailscale much simpler to use. Adding machines, allowing routing, etc were very easy. Also, I seem to remember something about DNS names that Zerotier doesn’t do properly, which Tailscale seems to do well.

1 Like

I will explore the Tailscale as well. Thanks for your suggestions.

Hi Stephen,

Thanks for guiding me about the ZeroTier solution. I had no idea earlier about this. I convinced my Friend to install HA on a Refurbished Dell 7050 Micro instance and put the above discussed setup in the wild. We are able to Power ON and Off the Water Pump on scheduled jobs and Ad-Hoc.
Via ZeroTier he is able to get alerts on his Mobile HA companion app and see the status of the Pump and the water flowing as well. We are continuing the project with Solenoids at present to setup watering based on the need. Thanks once again for your inputs and suggestion.