This is a port from the ESP32 repository to a ESP8266 D1 Mini which is smaller than the ESP32 Node MCU.
Caution: This is the updated version 1.2 with changed I/O pin definitions! The PCB is also updated but untested.
This repository shows how to remotely control the anchor chain relay via WLAN from phone/tablet. Anchor chain events from the chain sensor are measured and presented on the phone/tablet.
Just set the WLAN ssid and password according to your needs. Select WLAN type with setting WiFiMode_AP_STA to "0" means Acess Point, or "1" means Client with DHCP.
Also set Chain_Calibration_Value according to your sensor (e.g. 0.33. meter per event).
If working as Access Point, connect the phone/tablet to the defined AP and start "192.168.4.1" in the browser. If working as WLAN client, check the DHCP IP address with Serial Monitor of IDE and start browser with the shown IP address.
To control the anchor chain relay just press:
- "Down" for anchor down
- "Up" for anchor up
- "Stop" for Stop
- "Reset" to reset the chain counter to zero
Features:
- Saftey stop to stop "anchor up" two events before reaching zero (can be changed in code with SAFETY_STOP).
- Safety stop if maximum chain lenght is reached (standard 40 meters, can be changed with MAX_CHAIN_LENGTH)
- Watchdog timer to stop power after 1 second inactivity of client (e.g. due to connection problems).
- Watchdog timer to detect blocking chain. Engine stops if no events are detected within 1 second for up/down command.
- Current Chain Counter is stored in nonvolatile memory. ESP can be switched off after anchoring (counter is restored after new start).
- Demo mode to check functionality without having a windlass / chain counter connected to ESP (set ENABLE_DEMO to 1).
A pcb layout is available in the KiCAD folder: "D1MiniChainCounterWLAN.kicad_pcb".
You can order a PCB from Aisler.net: https://aisler.net/p/WJSHXVDM
The current design should work for a Quick or Lofrans anchor chain relay and chain sensor (which looks like a simple reed relay triggerd from a magnet). Connection details for a Quick windlass/counter can be found here: https://www.quickitaly.com/resources/downloads_qne-prod/1/CHC1203_IT-EN-FR_REV001A.pdf
Used I/O pins:
- D1/D2: Output, relais Up/Down
- D6/D7: Input, manual override detection Up/Down (option)
- D5: Input, chain sensor
With these IO pins the boot problem with the relais should be solved. Details see here: https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/ The former version used D4/D5 as relais output istead of safe GPIO4(D1) and GPIO5(D2). D5,D6,D7 are safe for input.
The manual override detection function with D6/D7 is currently missing in the code. Feel free to support/update.
If you have problems with the chanin counter input measuring multiple count signals, it might be necessary to use a library to avoid multiple counts e.g.: https://github.com/mathertel/OneButton
You can easily do your own changes now: I added the full KiCAD details: https://github.com/AK-Homberger/ESP8266_AnchorChainControl_WLAN/tree/main/D1MiniChainCounterWLAN
- Board Link
- U1 D1 Mini Link
- J2 D24V10F5 Link
- R1 Resistor 1 KOhm Link
- R2, R3 Resistor 270 Ohm (*2) Link
- R4, R5 Resistor 10 KOhm (*2) Link
- Q1, Q2, Q3, Q4 Transistor BC337 (*4) Link
- D2, D3 Diode 1N4148 (*2) Link
- D1 Diode 1N4001 Link
- U2 H11-L1 Link
- K1, K2 Relay (*2) Link
- J1, J3, J4 Connector 2-pin (*3) Link
- 06.10.2021 - Version 1.2: Changed IO pins to avoid problem during boot and preparation for correct manual override detection.
- 06.11.2020 - Changed PCB layout to version 1.1. Larger terminal blocks (5.08 mm) and different transistor footprints for easy soldering.
- 02.11.2020 - Version 1.0: Initial version with ESP8266 D1 Mini.