MCP23017 watering system

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
benzino
Normal user
Posts: 1
Joined: 11 Nov 2018, 18:19

MCP23017 watering system

#1 Post by benzino » 12 Nov 2018, 18:19

Hi,
I have a question about "good practice" or "rules of thumb" in the following configuration:
  1. Wemos D1 mini
  2. Level Converter
  3. MCP23017
  4. 8-channel relay (active low)
  5. ESPEasy v2.0 (compiled by myself just to hard code parameters to my WIFI network)
Wemos D1 and D2 (SDA/SCL) connected thru level converter to MCP23017 which is powered with 5V to control relay board.
So to controll my watering system the rules looks like this:

Code: Select all

on System#Wake do
event,StopAll
endon

on R1 do
MCPLongPulse,1,0,%eventvalue%
endon

on R2 do
MCPLongPulse,2,0,%eventvalue%
endon

on R3 do
MCPLongPulse,3,0,%eventvalue%
endon

on R4 do
MCPLongPulse,4,0,%eventvalue%
endon

on R5 do
MCPLongPulse,5,0,%eventvalue%
endon

on R6 do
MCPLongPulse,6,0,%eventvalue%
endon

on R7 do
MCPLongPulse,7,0,%eventvalue%
endon

on R8 do
MCPLongPulse,8,0,%eventvalue%
endon

on R9 do
MCPLongPulse,9,0,%eventvalue%
endon

on R10 do
MCPLongPulse,10,0,%eventvalue%
endon

on StopAll do
MCPGPIO,1,1
MCPGPIO,2,1
MCPGPIO,3,1
MCPGPIO,4,1
MCPGPIO,5,1
MCPGPIO,6,1
MCPGPIO,7,1
MCPGPIO,8,1
MCPGPIO,9,1
MCPGPIO,10,1
endon
It works ok, but I have some concerns:
  1. When the system boots I set all relays to "off", but I'm not sure whether I should do this at "System#Wake" or "System#Boot" event? Or it doesn't matter? I can see from console that "System#Wake" is earlier event than "System#Boot". This is a protection in case of during PulseTime there will be power outage and the relay will get to last state after power back (and my garden will became a lake).
  2. Is there any setting/command/compile directive to not "remember" the last state of output pin and set it to default value every time the system boots (i.e. pins which control relay board will be default set to "HIGH" after boot, then I will not need the "StopAll" event at boot)?
  3. I can observe that when one or more relays are ON and I will cut the power and then power it back there is second or two when the relays "clicks" to ON state and then after that time they are turned OFF (by the StopAll event) - How can I mitigate this behaviour? It can be stressful for my water pump.
Here is my

Code: Select all

Config.h

#undef	DEFAULT_NAME
#define DEFAULT_NAME		"ESPEasyTest"			// Enter your device friendly name

#undef	DEFAULT_SSID
#define DEFAULT_SSID		"myiots"			   // Enter your network SSID

#undef	DEFAULT_KEY
#define DEFAULT_KEY			"sypersecret"		// Enter your network WPA key

#undef DEFAULT_CONTROLLER
#define DEFAULT_CONTROLLER   true              // true or false enabled or disabled, set 1st controller defaults
#undef DEFAULT_SERVER
#define DEFAULT_SERVER      "mqtt.lipowa54.local"       // Enter your Server IP address
#undef DEFAULT_PORT
#define DEFAULT_PORT        2883                // Enter your Server port value
#undef DEFAULT_PROTOCOL
#define DEFAULT_PROTOCOL    5

#undef DEFAULT_USE_RULES
#define DEFAULT_USE_RULES                       true   // (true|false) Enable Rules?

#undef DEFAULT_USE_NTP
#define DEFAULT_USE_NTP                         true   // (true|false) Use NTP Server
#undef DEFAULT_NTP_HOST
#define DEFAULT_NTP_HOST                        "ntp.lipowa54.local"              // NTP Server Hostname
#undef DEFAULT_TIME_ZONE
#define DEFAULT_TIME_ZONE                       60               // Time Offset (in minutes)
#undef DEFAULT_USE_DST
#define DEFAULT_USE_DST                         true   // (true|false) Use Daily Time Saving

#undef RULES_TIMER_MAX
#define RULES_TIMER_MAX                     10
#undef SYSTEM_TIMER_MAX
#define SYSTEM_TIMER_MAX    10

:

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests