Skip to content

Latest commit

 

History

History

valves-manipulator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Description

ESP8266-based box for remote manipulating of Gidrolock water valves.
Later was added wired water lakage sensor (branded as Equation and sold by Leroymerlin) and connection to water meters

Flashing

Run ./upload.sh
Note that nodemcu-tool utility (last tested with v3.2.1) should be installed in advance with npm install nodemcu-tool -g

johnny@mbp2015:~/Desktop/Projects/interstellar/valves-manipulator$ ./upload.sh
file size 8924
Checking init.lua OK
Total: 0 warnings / 0 errors in 1 file
[config]      ~ Project based configuration loaded
[NodeMCU-Tool]~ Connected
[device]      ~ Arch: esp8266 | Version: 3.0.0 | ChipID: 0xc1217d | FlashID: 0x1640e0
[NodeMCU-Tool]~ Uploading "init.lua" >> "init.lua"...
[connector]   ~ Transfer-Mode: hex
[NodeMCU-Tool]~ File Transfer complete!
[NodeMCU-Tool]~ disconnecting
OK! successfully uploded and verified size

UART console

sudo screen /dev/tty.wchusbserial1420 115200 exit with Ctrl + A then Ctrl + D

Pin values

VALVE_PIN 0 - valves open; 1 - valves closed
WATER_SENSOR_PIN 0 - leakage detected; 1 - no leakage

RCA for the error on attempt to attach interrupt handler for the pins with IO index >= 13:

#define GPIO_PIN_NUM 13
#define NUM_GPIO              GPIO_PIN_NUM
static inline int platform_gpio_exists( unsigned pin ) { return pin < NUM_GPIO; }
luaL_argcheck(L, platform_gpio_exists(pin) && pin>0, 1, "Invalid interrupt pin");

GPIO to IO index

local HOT_METER_PIN = 11; -- GPIO9
local HOT_METER_PIN = 12; -- GPIO10
local HOT_METER_PIN = 13; -- GPIO8
local HOT_METER_PIN = 14; -- GPIO6
local HOT_METER_PIN = 9; -- GPIO11

Set intial meter values via MQTT

send H28147 to /VALVE/STATE/METERS_SET send C32684 to /VALVE/STATE/METERS_SET

Flashing nodemcu

  • press "Flash Nodemcu" button on board
  • power board
  • run ./flash-nodemcu.sh

also instructions on how to write nodemcu firmware to esp8266 could be found at [../mhz19-box-new/README.md]

TODOs

  • (-) fix potential overflow for tmr.time()

  • (-) make STATUS_UPDATE_INTERVAL value configurable

  • (-) saveMeterStateToFiles only if last value has been changed

  • (-) implement blink codes

  • (-) avoid hadcoding connection settings for mqtt server and wifi

  • (-) add to schematics and update pcb for 10k pull resistor for "wired water leakage sennsor"

  • (-) software or hardware debouncing (hysteresis) for "wired water leakage sennsor" handler to avoid iimediate sending "ceased alarm" message

  • (-) document mqtt api (published topics, subscribed to topics)

  • (-) add version file and ability to get it via mqtt

  • (-) implement startup page to setup mtqtt and wifi settings

  • (-) add gidrolock valves pins information on silk layer

  • (-) implement a safe way to solder AC wires

  • (-) add jumper to be able to disconnect meanwell psu and connect external power (to DC line +15v)

  • (-) Add build-in СР340С chip + reset circuit

  • (-) hardware buttons for manual valves management

  • (-) Use pre-compiled files / LFS

  • (+) add box unique identifier

  • (+) fix issue with absence of reconnection to mqtt server

  • (+) Add "Reset" button instead of "Flash LUA"

  • (+) Use sjson in lua sketch

  • (+) add more powerfull 3.3v reg (LM1117DT 3.3 корпус TO-252 [https://www.chipdip.ru/product/lm1117dt-3.3-nopb])

  • (+) change valves transistor to smd version (BC337 to BC817)

  • (+) Get current state

  • (+) Connect Equation wired water leakage sensor

  • (+) Memoise last valve state and use it on boot

  • (+) Ping server

Test Cases

  • TODO

Parts list

Socket types - SP13, GX16, GX12 MIL-STD 5015 [https://aliexpress.ru/item/32620267150.html]

Final

Potential sockets

Glands

Buttons

Cases

PSUs