I have not received an answer in the Russian part of this forum, I'll try here
The task is a drive the Roger technology entrance gates + control the status of septic tank.
Gate: Binary sensor (open state) + 2 relays for opening / closing
Septic: Binary sensor of fullness sensor
I wrote a sketch:
Code: Select all
// Entrance Gate + Septic state
#define RelayOpen 9
#define RelayClose 10
#define OpenState 17
#define SepticState 18
#define ZUNO_CHANNEL_NUMBER_ONE 1
#define ZUNO_CHANNEL_NUMBER_TWO 2
// Variables
byte LastOpenState;
byte LastSepticState;
byte openswitch = 1;
byte closeswitch = 1;
// Always connect
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);
//Channels setup
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getgate),
ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getseptic),
ZUNO_SWITCH_BINARY(getopenswitch, setopenswitch),
ZUNO_SWITCH_BINARY(getcloseswitch, setcloseswitch)
);
void setup()
{
pinMode(RelayOpen, OUTPUT);
pinMode(RelayClose, OUTPUT);
pinMode(OpenState, INPUT_PULLUP);
pinMode(SepticState, INPUT_PULLUP);
}
void
setopenswitch(byte value)
{digitalWrite(RelayOpen, (value > 0) ? LOW : HIGH);
openswitch = value;}
void
setcloseswitch(byte value)
{digitalWrite(RelayClose, (value > 0) ? LOW : HIGH);
closeswitch = value;}
void loop() {
byte CurrentOpenState = digitalRead(OpenState);
if (CurrentOpenState != LastOpenState)
{LastOpenState = CurrentOpenState;
zunoSendReport(ZUNO_CHANNEL_NUMBER_ONE);}
byte CurrentSepticState = digitalRead(SepticState);
if (CurrentSepticState != LastSepticState)
{LastSepticState = CurrentSepticState;
zunoSendReport(ZUNO_CHANNEL_NUMBER_TWO);}}
byte getgate()
{if (LastOpenState == 0)
{return 0xff;}
else
{return 0;}}
byte getseptic()
{if (LastSepticState == 0)
{return 0xff;}
else
{return 0;}}
byte getopenswitch()
{return openswitch;}
byte getcloseswitch()
{return closeswitch;}
In the HC2 the relays and the gate opening sensor are detected only.
Where is the septic sensor?
Why the gate open sensor triggered when the opening relay is triggered?
So strange.