Page 1 of 1

I need some help

Posted: 27 Jul 2020 21:03
by ECKEROTH
Hi.

I need a little help as I am not a developer.
Purpose is to automatically open/close water valve to my pool
from a liquid sensor input, and to be able to open and close water valve manually to.

Z-Uno Shield:
ADC0: Liquid level sensor DC 5 ~ 24v
PWM1: 3V relay, working manually in APP

In the code i got from configurator I can only control open/close manually - works perfectly but the liquid sensor has no effect on HIGH/LOW on PWM1?
How do I get ADC0 to also automatic open/close PWM1? A delay on switching valve on/off PWM1 is also preferable as I need stable water level in pool before filling.

Please help :mrgreen:

Code: Select all

// Global variables

byte pin3SensorBinaryState;
byte pin13SwitchBinaryState = 0;

// Z-Wave channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, pin3SensorBinaryGetter),
  ZUNO_SWITCH_BINARY(pin13SwitchBinaryGetter, pin13SwitchBinarySetter)
);

void setup() {
  pinMode(3, INPUT);
  pin3SensorBinaryState = !digitalRead(3);

  pinMode(13, OUTPUT);
}

void loop() {
  byte _pin3SensorBinaryState = digitalRead(3);
  if (pin3SensorBinaryState != _pin3SensorBinaryState) {
    pin3SensorBinaryState = _pin3SensorBinaryState;
    zunoSendReport(1);
  }

  digitalWrite(13, pin13SwitchBinaryState ? HIGH : LOW);

  delay(20);
}

// Getters and setters

byte pin3SensorBinaryGetter() {
  return pin3SensorBinaryState;
}

void pin13SwitchBinarySetter(byte value) {
  pin13SwitchBinaryState = value;
}

byte pin13SwitchBinaryGetter() {
  return pin13SwitchBinaryState;
}

Re: I need some help

Posted: 29 Jul 2020 10:01
by PoltoS
Out your logic in the loop(). Compare pin3SensorBinaryState with 0 and set pin13SwitchBinaryState accordingly (don't forget to do another zunoSendReport(2) after that).

For a delay use a separate variable to count before changing the switch state