new som help regarding compilation of Z-UNO

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Gbajolet
Posts: 10
Joined: 29 Apr 2020 13:14

new som help regarding compilation of Z-UNO

Post by Gbajolet »

Hello Everybody,

I got several issues with the attached program:

1)

I tried to compile this program with some hall detector, switches and sensors.

When I Added a second sensor "ZON1" I received the Following message:

Custom_sdcpp_.c:428:876:error:use of undeclared identifier 'getterZON1'

To obtain this sensor, I copy and Paste the same one whose name is "ZAG", before no problem, I red and red again the code, and I didn't find my mistake.

2) When I intergrate the Zuno on my Z-Wave network, the channels 1 to 5 are OK, but the channel 6 never came,it is why I would like to add a second one similar to check.

3)I used some interrupt on the program with a hall detector as sensor, I would like to stop and restart the interrupt during some calculation, I didn't find the way on the reference documentation. Is it possible or not?

Thank you by advance for your support

PS: my software is 2.1.5 and my Domotic box is EEDOMUS

Code: Select all


/*
  
  Measure the liquid/water flow rate using this code.
  Connect Vcc and Gnd of sensor to arduino, and the
  signal line to arduino digital pin 2.
  programme validé par GB le 26/4/2020 avec coefficient adapté

*/
// pin number, where the two relays are connected
#define RELAY1_PIN     8
#define RELAY2_PIN     7
// zone d'arrosage pin number
// 6 pin - button(ZAG) of Z-Uno board
#define ZAG_PIN     6 //ZAG = Zone d'arrosage general
#define ZON1_PIN     5 //ZAG = Zone d'arrosage general

// 13 pin - user LED of Z-Uno board
#define LED_PIN     13

// channel number
#define ZUNO_CHANNEL_NUMBER_ONE   1
#define ZUNO_CHANNEL_NUMBER_TWO   2
#define ZUNO_CHANNEL_NUMBER_THREE   3
#define ZUNO_CHANNEL_NUMBER_FOUR   4
#define ZUNO_CHANNEL_NUMBER_FIVE   5
#define ZUNO_CHANNEL_NUMBER_SIX   6
#define ZUNO_CHANNEL_NUMBER_SEVEN 7


byte statusLed    = 13;
byte sensorPin       = 17;
// variable to store current relay state 1
byte lastSetValue1;
// variable to store current relay state 2
byte lastSetValue2;
// variable to store current zone state
byte lastZAGState;
// variable to store current zone state
byte lastZON1State;


ZUNO_SETUP_ISR_INT0(onPulse);//Interrupt initialisation


// The hall-effect flow sensor outputs approximately 1.1825 pulses per second per
// litre/minute of flow.
float calibrationFactor = 1.1825;
volatile byte pulseCount;
float flowRate;
unsigned int flowLitres;
unsigned long totalLitres;
unsigned long oldTime;

ZUNO_SETUP_CHANNELS(
  //Channel 1
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, 4, SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, 2, getterVol1),
  //Channel 2
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, 4, SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, 2, getterVol2),
  //Channel 3
  ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_GENERAL_PURPOSE_VALUE, 4, SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, 2, getterDeb1),
  //Channel 4
  ZUNO_SWITCH_BINARY(getterRelay1, setterRelay1),
  //Channel 5
  ZUNO_SWITCH_BINARY(getterRelay2, setterRelay2),
  // Channel 6
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getterZAG),
  // Channel 7
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_GENERAL_PURPOSE, getterZON1)
);


void setup()
{


  // Initialize a serial connection for reporting values to the host
  Serial.begin();

  pinMode(LED_PIN, OUTPUT); // set LED pin as output
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);
  pinMode(RELAY1_PIN, OUTPUT);// set up relay pin as output
  pinMode(RELAY2_PIN, OUTPUT);// set up relay pin as output
  pinMode(ZAG_PIN, INPUT_PULLUP); // set button pin as input
  pinMode(ZON1_PIN, INPUT_PULLUP); // set button pin as input

  pulseCount        = 0;
  flowRate          = 0.0;
  flowLitres   = 0;
  totalLitres  = 0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 17 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)

  zunoExtIntMode(ZUNO_EXT_INT0, FALLING);
}

/**
   Main program loop
*/
void loop()
{

  if ((millis() - oldTime) > 1000)   // Only process counters once per second
  {
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;

    oldTime = millis();

    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    // il y a un facteur 100 qui traine donc flowMillilitre sera exprimé en litre
    flowLitres = (flowRate / 60) * 100;

    // Add the liters passed in this second to the cumulative total
    totalLitres += flowLitres;


    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;

    zunoSendReport(1); // send report over the Z-Wave to the controller
    zunoSendReport(2); // send report over the Z-Wave to the controller
    zunoSendReport(3); // send report over the Z-Wave to the controller

  }

  // sample current ZAG state
  byte currentZAGState = digitalRead(ZAG_PIN);

  if (currentZAGState != lastZAGState) { // if state changes
    lastZAGState = currentZAGState; // save new state

    zunoSendReport(6); // send report over the Z-Wave to the controller

    if (currentZAGState == LOW) { // if button is pressed
      digitalWrite(LED_PIN, HIGH);  // turn the LED on
    } else {                        // if button is released
      digitalWrite(LED_PIN, LOW);   // turn the LED off
    }
  }

  // sample current ZON1 state
  byte currentZON1State = digitalRead(ZON1_PIN);

  if (currentZON1State != lastZON1State) { // if state changes
    lastZON1State = currentZON1State; // save new state

    zunoSendReport(7); // send report over the Z-Wave to the controller

    if (currentZON1State == LOW) { // if button is pressed
      digitalWrite(LED_PIN, HIGH);  // turn the LED on
    } else {                        // if button is released
      digitalWrite(LED_PIN, LOW);   // turn the LED off
    }
  }
}

/*
  Insterrupt Service Routine
*/
void onPulse()
{
  // Increment the pulse counter
  pulseCount++;
}
dword getterVol1() {
  return flowLitres;
}
dword getterVol2() {
  return totalLitres;
}
dword getterDeb1() {
  return flowRate;
}
byte getterRelay1() {
  return lastSetValue1;
}
void setterRelay1(byte newValue1) {
  // newValue1 is a variable, holding a "value"
  // which came from the controller or other Z-Wave device
  if (newValue1 > 0) { // if greater then zero
    digitalWrite(RELAY1_PIN, HIGH); //turn relay1 on
  } else {            // if equals zero
    digitalWrite(RELAY1_PIN, LOW);  //turn relay1 off
  }

  // save the new value in a variable
  lastSetValue1 = newValue1;
}
byte getterRelay2() {
  return lastSetValue2;
}
void setterRelay2(byte newValue2) {
  // newValue2 is a variable, holding a "value"
  // which came from the controller or other Z-Wave device
  if (newValue2 > 0) { // if greater then zero
    digitalWrite(RELAY2_PIN, HIGH); //turn relay2 on
  } else {            // if equals zero
    digitalWrite(RELAY2_PIN, LOW);  //turn relay2 off
  }

  // save the new value in a variable
  lastSetValue2 = newValue2;
}
byte getterZAG() {
  if (lastZAGState == 0) { // si l'arrosge est ON
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if arrosage is released
    return 0;                 // return "Idle" state to the controller
  }
  byte getterZON1() {
    if (lastZON1State == 0) { // si l'arrosge est ON
      return 0xff;              // return "Triggered" state to the controller
    } else {                    // if arrosage is released
      return 0;                 // return "Idle" state to the controller
    }

  }

User avatar
PoltoS
Posts: 5611
Joined: 26 Jan 2011 19:36

Re: new som help regarding compilation of Z-UNO

Post by PoltoS »

Missing } at the end if getterZAG()

Gbajolet
Posts: 10
Joined: 29 Apr 2020 13:14

Re: new som help regarding compilation of Z-UNO

Post by Gbajolet »

Dear Polto,

thank you very much, after hours I didn’t see this stupid error !!and for the interrupt, (question 3) do you have some solution?
Best regards
Gilles

User avatar
PoltoS
Posts: 5611
Joined: 26 Jan 2011 19:36

Re: new som help regarding compilation of Z-UNO

Post by PoltoS »

Use
noInterrupts();
interrupts();

Gbajolet
Posts: 10
Joined: 29 Apr 2020 13:14

Re: new som help regarding compilation of Z-UNO

Post by Gbajolet »

Hello,

Thank you very much, I didn’t find this on the documentation.

Regards

Gilles

Post Reply