Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. derrij
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by derrij

    • RE: MDRemote not working in Stable Release 3.8153

      On version 4.9700 Still, does not work.

      PKG_HASH:=2772d9f64cc552d02a8c44f5e076b58f13b39d69

      IRSensor1
      IRSensor2

      posted in Domoticz
      derrij
      derrij
    • RE: Problem with IRSensor and Domoticz

      MDRemote Unsolved
      MDRemote Problem
      please someone look for the problem.
      thank you.

      posted in Domoticz
      derrij
      derrij
    • MDRemote not working in Stable Release 3.8153

      Type: Light/Switch, MDRemote not working any more in Stable Release 3.8153

      On Stable Release 3.5877 was working fine.

      Error sending switch command, check device/hardware !
      

      in logs

      2017-04-17 16:03:45.166 Error: MySensors: Light command received for unknown node_id: 433433433
      
      posted in Domoticz
      derrij
      derrij
    • RE: [SOLVED] MDRemote stop working in last beta

      I am sorry, but the problem still exists.

      Error sending switch command, check device/hardware !
      

      on
      PKG_SOURCE_URL:=https://github.com/domoticz/domoticz.git
      PKG_SOURCE_VERSION:=5d708b35d3f6f16d749574f7bf75b2242d47790c

      and even on last beta

      PKG_SOURCE_URL:=https://github.com/domoticz/domoticz.git
      PKG_SOURCE_VERSION:=b4b59b0762a1715d4ecf574ebae060f6a77b9fae

      posted in Domoticz
      derrij
      derrij
    • RE: [SOLVED] MDRemote stop working in last beta

      Now everything is alright with latest build.

      PKG_SOURCE_URL:=https://github.com/domoticz/domoticz.git
      PKG_SOURCE_VERSION:=5d708b35d3f6f16d749574f7bf75b2242d47790c

      posted in Domoticz
      derrij
      derrij
    • RE: [SOLVED] MDRemote stop working in last beta

      @gohan yes

      posted in Domoticz
      derrij
      derrij
    • [SOLVED] MDRemote stop working in last beta

      Hi. I am using IR receiver/sender, but after upgrading to last beta it stop working.

      Type: Light/Switch, MDRemote not working any more in beta PKG_SOURCE_VERSION:=1a234df617dc0a09518a4157249b8800fc39330d

      Error sending switch command, check device/hardware !
      

      in logs

      2017-04-17 16:03:45.166 Error: MySensors: Light command received for unknown node_id: 433433433
      
      posted in Domoticz
      derrij
      derrij
    • RE: Connect Serial Gateway to Openwrt routers TX RX pins

      I tried set rate in domoticz and by stty -F /dev/ttyS0 9600 clocal cread cs8 -cstopb -parenb
      but after a time it come back to rate what set in

      cat /proc/cmdline
      console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=squashfs
      

      it looks like i need to recompile firmware.

      posted in Hardware
      derrij
      derrij
    • RE: Connect Serial Gateway to Openwrt routers TX RX pins

      I tried 57600. Right now i tried on Padavan firmware on Xiaomi router 3.
      And i can't compile firmware with lower than 57600

      But I start domoticz with -verbose 0 -loglevel 0, and it working better. Need to test more.

      posted in Hardware
      derrij
      derrij
    • RE: Connect Serial Gateway to Openwrt routers TX RX pins

      it works, but now i see it unstable. a lot of garbage received

      2;5;1;0;35;184.367
      ;0.13;1;1;013;6;1;0;16;1
      ;4;1;0;24;121056
      2;4;1;0;35;121.056```
      posted in Hardware
      derrij
      derrij
    • RE: 💬 Building a WiFi Gateway using ESP8266

      why esp8266 gateway shows only debug info?
      when i comment //#define MY_DEBUG
      where is no any serial output.

      posted in Announcements
      derrij
      derrij
    • RE: Connect Serial Gateway to Openwrt routers TX RX pins

      MySensors and Domoticz are the best!
      I did not think it would be so easy.
      I did not have to make changes to the router's firmware.
      All i need set speed in serial gateway

      #define MY_BAUD_RATE 115200
      

      On router make

      ln -s /dev/ttyS0 /dev/ttyUSB1
      
      
      posted in Hardware
      derrij
      derrij
    • RE: Connect Serial Gateway to Openwrt routers TX RX pins

      found some thing - How to terminate console on serial port (UART)
      am i on right direction?

      posted in Hardware
      derrij
      derrij
    • Connect Serial Gateway to Openwrt routers TX RX pins

      It is possible to connect Serial Gateway to router's TX RX pins?

      Will be nice not using router's usb port, and leave it for someone else.
      Would like to use MySensors wit Domoticz installed on router.
      Right now WiFi Gateway used.

      posted in Hardware
      derrij
      derrij
    • RE: One Arduino, two water pulse sensors

      try this. working fine for me.

      	//#include <EEPROM.h>
      
      	//
      	// Use this sensor to measure volume and flow of your house watermeter.
      	// You need to set the correct pulsefactor of your meter (pulses per m3).
      	// The sensor starts by fetching current volume reading from gateway (VAR 1).
      	// Reports both volume and flow back to gateway.
      	//
      
      	#include <SPI.h>
      	#include <MySensor.h>
      
      	#define RADIO_ID 2
      
      	#define CHILD_ID_HUM 0
      	#define CHILD_ID_TEMP 1
      	unsigned long HUM_TEMP_SEND_FREQUENCY = 30;     // Minimum time between send (in seconds). We don't want to spam the gateway.
      	#define WATER_LEAK_SENSOR_DIGITAL_PIN 6
      	#define HUMIDITY_SENSOR_DIGITAL_PIN 5
      	#define HOT_WATER_SENSOR_DIGITAL_PIN 4
      	#define COLD_WATER_SENSOR_DIGITAL_PIN 3
      	#define PULSE_FACTOR 1000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      	#define CHILD_ID_HOT_WATER 5
      	#define CHILD_ID_COLD_WATER 4                    // Id of the sensor child
      	#define CHILD_ID_WATER_LEAK 2
      	unsigned long SEND_FREQUENCY = 20;              // Minimum time between send (in seconds). We don't want to spam the gateway.
      
      
      
      	MySensor gw;
      
      	double ppl = ((double)PULSE_FACTOR) / 1000;      // Pulses per liter
      
      	volatile unsigned long pulseCountHot = 0;
      	volatile unsigned long pulseCountCold = 0;
      	volatile unsigned long lastBlinkHot = 0;
      	volatile unsigned long lastBlinkCold = 0;
      	volatile double flowHot = 0;
      	volatile double flowCold = 0;
      	unsigned long oldPulseCountHot = 0;
      	unsigned long oldPulseCountCold = 0;
      	unsigned long newBlinkHot = 0;
      	unsigned long newBlinkCold = 0;
      	double oldflowHot = 0;
      	double oldflowCold = 0;
      	double oldtripped = 0;
      	double volumeHot;
      	double volumeCold;
      	double oldvolumeHot;
      	double oldvolumeCold;
      	unsigned long lastSendHot;
      	unsigned long lastSendCold;
      	unsigned long lastSendHumTemp;
      	unsigned long lastPulseHot;
      	unsigned long lastPulseCold;
      	unsigned long currentTimeHot;
      	unsigned long currentTimeCold;
      	unsigned long currentHumTemp;
      	boolean pcReceivedHot = false;
      	boolean pcReceivedCold = false;
      
      
      	int lastSensorStateHot = 1;   // the previous reading from the input pin
      	int sensorStateHot;             // the current reading from the input pin
      	long lastDebounceTimeHot = 0;  // the last time the output pin was toggled
      	long debounceDelayHot = 50;    // the debounce time; increase if the output flickers
      
      	int lastSensorStateCold = 1;   // the previous reading from the input pin
      	int sensorStateCold;             // the current reading from the input pin
      	long lastDebounceTimeCold = 0;  // the last time the output pin was toggled
      	long debounceDelayCold = 50;    // the debounce time; increase if the output flickers
      
      	boolean metric;
      	MyMessage flowMsgHot(CHILD_ID_HOT_WATER, V_FLOW);
      	MyMessage volumeMsgHot(CHILD_ID_HOT_WATER, V_VOLUME);
      	MyMessage pcMsgHot(CHILD_ID_HOT_WATER, V_VAR1);
      
      	MyMessage flowMsgCold(CHILD_ID_COLD_WATER, V_FLOW);
      	MyMessage volumeMsgCold(CHILD_ID_COLD_WATER, V_VOLUME);
      	MyMessage pcMsgCold(CHILD_ID_COLD_WATER, V_VAR1);
      
      	MyMessage msg(CHILD_ID_WATER_LEAK, V_TRIPPED);
      	void setup() {
      
      	  gw.begin(incomingMessage, RADIO_ID);
      	  delay(40);
      	  // Send the sketch version information to the gateway and Controller
      	  gw.sendSketchInfo("Water Meter", "1.0");
      		delay(40);
      	  // Register this device as Waterflow sensor
      	  gw.present(CHILD_ID_COLD_WATER, S_WATER);
      		delay(40);
      	  gw.present(CHILD_ID_HOT_WATER, S_WATER);
      		delay(40);
      	  gw.present(CHILD_ID_WATER_LEAK, S_MOTION);
      		delay(40);
      	  // Fetch last known pulse count value from gw
      
      
      	  lastSendCold  = millis();
      	  lastSendHot = millis();
      
      	  pinMode(COLD_WATER_SENSOR_DIGITAL_PIN, INPUT);
      	  pinMode(HOT_WATER_SENSOR_DIGITAL_PIN, INPUT);
      	  gw.request(CHILD_ID_COLD_WATER, V_VAR1);
      	   
      	  gw.request(CHILD_ID_HOT_WATER, V_VAR1);
      	}
      
      	void incomingMessage(const MyMessage &message) {
      
      	  if (message.type == V_VAR1 && message.sensor == 4) {
      		pulseCountCold = oldPulseCountCold = message.getLong();
      		Serial.print("Received last pulse count from gw for sensor:");
      		Serial.print(message.sensor);
      		Serial.print(" pulseCountCold ");
      		Serial.println(pulseCountCold);
      		pcReceivedCold = true;
      	  }
      	  else if (message.type == V_VAR1 && message.sensor == 5) {
      		pulseCountHot = oldPulseCountHot = message.getLong();
      		Serial.print("Received last pulse count from gw for sensor:");
      		Serial.print(message.sensor);
      		Serial.print(" pulseCountHot ");
      		Serial.println(pulseCountHot);
      		pcReceivedHot = true;
      	  }
      	}
      
      	void loop() {
      	  gw.process();
      	  int readingCold = digitalRead(COLD_WATER_SENSOR_DIGITAL_PIN);
      	  // If the switch changed, due to noise or pressing:
      	  if (readingCold != lastSensorStateCold) {
      		// reset the debouncing timer
      		lastDebounceTimeCold = millis();
      	  }
      	  if ((millis() - lastDebounceTimeCold) > debounceDelayCold) {
      		// whatever the reading is at, it's been there for longer
      		// than the debounce delay, so take it as the actual current state:
      
      		// if the button state has changed:
      		if (readingCold != sensorStateCold) {
      		  sensorStateCold = readingCold;
      
      		  // only toggle the LED if the new button state is HIGH
      		  if (sensorStateCold == 0) {
      			pulseCountCold++;
      
      			unsigned long newBlinkCold = micros();
      			unsigned long intervalCold = newBlinkCold - lastBlinkCold;
      			lastPulseCold = millis();
      
      			flowCold = (60000000.0 / intervalCold) / ppl;
      			lastBlinkCold = newBlinkCold;
      
      			Serial.print("flowCold");
      			Serial.println(flowCold);
      		  }
      		}
      
      	  }
      
      	  int readingHot = digitalRead(HOT_WATER_SENSOR_DIGITAL_PIN);
      	  // If the switch changed, due to noise or pressing:
      	  if (readingHot != lastSensorStateHot) {
      		// reset the debouncing timer
      		lastDebounceTimeHot = millis();
      	  }
      	  if ((millis() - lastDebounceTimeHot) > debounceDelayHot) {
      		// whatever the reading is at, it's been there for longer
      		// than the debounce delay, so take it as the actual current state:
      
      		// if the button state has changed:
      		if (readingHot != sensorStateHot) {
      		  sensorStateHot = readingHot;
      
      		  // only toggle the LED if the new button state is HIGH
      		  if (sensorStateHot == 0) {
      			pulseCountHot++;
      
      			unsigned long newBlinkHot = micros();
      			unsigned long intervalHot = newBlinkHot - lastBlinkHot;
      			lastPulseHot = millis();
      
      			flowHot = (60000000.0 / intervalHot) / ppl;
      			lastBlinkHot = newBlinkHot;
      
      			Serial.print("flowHot");
      			Serial.println(flowHot);
      		  }
      		}
      
      	  }
      
      	  currentTimeCold = millis();
      	  currentTimeHot = millis();
      	  // No Pulse count in 2min reset flow
      	  if (currentTimeCold - lastPulseCold > 120000) {
      		flowCold = 0;
      		if (flowCold != oldflowCold) {
      		  gw.send(flowMsgCold.set(flowCold, 2));                   // Send flow value to gw
      		  oldflowCold = flowCold;
      		  Serial.println("flowCold Reset");
      		}
      	  }
      	  // No Pulse count in 2min reset flow
      	  if (currentTimeHot - lastPulseHot > 120000) {
      		flowHot = 0;
      		if (flowHot != oldflowHot) {
      		  gw.send(flowMsgHot.set(flowHot, 2));                   // Send flow value to gw
      		  oldflowHot = flowHot;
      		  Serial.println("flowHot Reset");
      		}
      
      	  }
      	  // Only send values at a maximum frequency
      	  if ((currentTimeCold - lastSendCold > 1000 * SEND_FREQUENCY) || (currentTimeHot - lastSendHot > 1000 * SEND_FREQUENCY)) {
      
      		// Pulse count has changed
      		if (pulseCountCold != oldPulseCountCold) {
      		  gw.send(pcMsgCold.set(pulseCountCold));                  // Send  volumevalue to gw VAR1
      
      		  // gw.sendVariable(CHILD_ID_COLD_WATER, V_VAR1, pulseCountCold);                  // Send  volumevalue to gw VAR1
      		  double volumeCold = ((double)pulseCountCold / ((double)PULSE_FACTOR));
      		  oldPulseCountCold = pulseCountCold;
      		  Serial.print("PulseCold count:");
      		  Serial.println(pulseCountCold);
      		  if (volumeCold != oldvolumeCold) {
      			gw.send(volumeMsgCold.set(volumeCold, 3));
      			// gw.sendVariable(CHILD_ID_COLD_WATER, V_VOLUME, volumeCold, 3);               // Send volume value to gw
      			Serial.print("m3Cold:");
      			Serial.println(volumeCold, 3);
      			oldvolumeCold = volumeCold;
      		  }
      		  if (flowCold != oldflowCold) {
      			gw.send(flowMsgCold.set(flowCold, 2));
      			//gw.sendVariable(CHILD_ID_COLD_WATER, V_FLOW, flowCold, 2);                   // Send flow value to gw
      
      			Serial.print("l/min Cold:");
      			Serial.println(flowCold);
      			oldflowCold = flowCold;
      		  }
      		  lastSendCold = currentTimeCold;
      		}
      
      		// Pulse count has changed
      		if (pulseCountHot != oldPulseCountHot) {
      		  gw.send(pcMsgHot.set(pulseCountHot));                  // Send  volumevalue to gw VAR1
      
      		  //gw.sendVariable(CHILD_ID_HOT_WATER, V_VAR1, pulseCountHot);                  // Send  volumevalue to gw VAR1
      		  double volumeHot = ((double)pulseCountHot / ((double)PULSE_FACTOR));
      		  oldPulseCountHot = pulseCountHot;
      		  Serial.print("PulseHot count:");
      		  Serial.println(pulseCountHot);
      		  if (volumeHot != oldvolumeHot) {
      			gw.send(volumeMsgHot.set(volumeHot, 3));
      			//gw.sendVariable(CHILD_ID_HOT_WATER, V_VOLUME, volumeHot, 3);               // Send volume value to gw
      			Serial.print("m3Hot:");
      			Serial.println(volumeHot, 3);
      			oldvolumeHot = volumeHot;
      		  }
      		  if (flowHot != oldflowHot) {
      			gw.send(flowMsgHot.set(flowHot, 2));
      			//gw.sendVariable(CHILD_ID_HOT_WATER, V_FLOW, flowHot, 2);                   // Send flow value to gw
      
      			Serial.print("l/min Hot:");
      			Serial.println(flowHot);
      			oldflowHot = flowHot;
      		  }
      		  lastSendHot = currentTimeHot;
      		}
      
      
      
      	  }
      
      
      	  lastSensorStateCold = readingCold;
      	  lastSensorStateHot = readingHot;
      
      
      	  boolean tripped = digitalRead(WATER_LEAK_SENSOR_DIGITAL_PIN) == LOW;
      	  if (tripped != oldtripped) {
      		Serial.println(tripped);
      		gw.send(msg.set(tripped?"1":"0")); // Send tripped value to gw
      
      		//gw.sendVariable(CHILD_ID_WATER_LEAK, V_TRIPPED, tripped?"1":"0");  // Send tripped value to gw
      		oldtripped = tripped;
      	  }
      
      
      
      	}
      

      or this, can't remember which is final one

      	#include <SPI.h>
      	#include <MySensor.h>
      
      	#define RADIO_ID 2
      
      	#define WATER_LEAK_SENSOR_DIGITAL_PIN 6
      	#define HOT_WATER_SENSOR_DIGITAL_PIN 4
      	#define COLD_WATER_SENSOR_DIGITAL_PIN 3
      	#define PULSE_FACTOR 1000                       // Nummber of blinks per m3 of your meter (One rotation/liter)
      	#define CHILD_ID_HOT_WATER 5
      	#define CHILD_ID_COLD_WATER 4                   // Id of the sensor child
      	#define CHILD_ID_WATER_LEAK 2
      	unsigned long SEND_FREQUENCY = 20;              // Minimum time between send (in seconds). We don't want to spam the gateway.
      
      	MySensor gw;
      
      	double ppl = ((double)PULSE_FACTOR) / 1000;      // Pulses per liter
      
      	volatile unsigned long pulseCountHot = 0;
      	volatile unsigned long pulseCountCold = 0;
      	volatile unsigned long lastBlinkHot = 0;
      	volatile unsigned long lastBlinkCold = 0;
      	volatile double flowHot = 0;
      	volatile double flowCold = 0;
      	unsigned long oldPulseCountHot = 0;
      	unsigned long oldPulseCountCold = 0;
      	unsigned long newBlinkHot = 0;
      	unsigned long newBlinkCold = 0;
      	double oldflowHot = 0;
      	double oldflowCold = 0;
      	double oldtripped = 0;
      	double volumeHot;
      	double volumeCold;
      	double oldvolumeHot;
      	double oldvolumeCold;
      	unsigned long lastSendHot;
      	unsigned long lastSendCold;
      	unsigned long lastPulseHot;
      	unsigned long lastPulseCold;
      	unsigned long currentTimeHot;
      	unsigned long currentTimeCold;
      	boolean pcReceivedHot = false;
      	boolean pcReceivedCold = false;
      	int readingCold;
      	int readingHot;
      
      	int lastSensorStateHot = 1;   // the previous reading from the input pin
      	int sensorStateHot;             // the current reading from the input pin
      	long lastDebounceTimeHot = 0;  // the last time the output pin was toggled
      	long debounceDelayHot = 50;    // the debounce time; increase if the output flickers
      
      	int lastSensorStateCold = 1;   // the previous reading from the input pin
      	int sensorStateCold;             // the current reading from the input pin
      	long lastDebounceTimeCold = 0;  // the last time the output pin was toggled
      	long debounceDelayCold = 50;    // the debounce time; increase if the output flickers
      
      	boolean metric;
      	MyMessage flowMsgHot(CHILD_ID_HOT_WATER, V_FLOW);
      	MyMessage volumeMsgHot(CHILD_ID_HOT_WATER, V_VOLUME);
      	MyMessage pcMsgHot(CHILD_ID_HOT_WATER, V_VAR1);
      
      	MyMessage flowMsgCold(CHILD_ID_COLD_WATER, V_FLOW);
      	MyMessage volumeMsgCold(CHILD_ID_COLD_WATER, V_VOLUME);
      	MyMessage pcMsgCold(CHILD_ID_COLD_WATER, V_VAR1);
      
      	MyMessage msg(CHILD_ID_WATER_LEAK, V_TRIPPED);
      	void setup() {
      
      	  gw.begin(incomingMessage, RADIO_ID);
      		delay(90);
      	  // Send the sketch version information to the gateway and Controller
      	  gw.sendSketchInfo("Water Meter", "1.0");
      		delay(90);
      	  // Register this device as Waterflow sensor
      	  gw.present(CHILD_ID_COLD_WATER, S_WATER);
      		delay(90);
      	  gw.present(CHILD_ID_HOT_WATER, S_WATER);
      		delay(90);
      	  gw.present(CHILD_ID_WATER_LEAK, S_MOTION);
      		delay(90);
      	  // Fetch last known pulse count value from gw
      	  gw.request(CHILD_ID_COLD_WATER, V_VAR1);
      	 
      	  gw.request(CHILD_ID_HOT_WATER, V_VAR1);
      		
      	  lastSendCold  = millis();
      	  lastSendHot = millis();
      
      	  pinMode(COLD_WATER_SENSOR_DIGITAL_PIN, INPUT);
      	  pinMode(HOT_WATER_SENSOR_DIGITAL_PIN, INPUT);
      
      	}
      
      	void incomingMessage(const MyMessage &message) {
      
      	  if (message.type == V_VAR1 && message.sensor == 4 && pcReceivedCold == false) {
      		pulseCountCold = oldPulseCountCold = message.getLong();
      		Serial.print("Received last pulse count from gw for sensor:");
      		Serial.print(message.sensor);
      		Serial.print(" pulseCountCold ");
      		Serial.println(pulseCountCold);
      		pcReceivedCold = true;
      		delay(100);
      		gw.request(CHILD_ID_HOT_WATER, V_VAR1);
      	  }
      	  else if (message.type == V_VAR1 && message.sensor == 5 && pcReceivedHot == false) {
      		pulseCountHot = oldPulseCountHot = message.getLong();
      		Serial.print("Received last pulse count from gw for sensor:");
      		Serial.print(message.sensor);
      		Serial.print(" pulseCountHot ");
      		Serial.println(pulseCountHot);
      		pcReceivedHot = true;
      		delay(100);
      		gw.request(CHILD_ID_COLD_WATER, V_VAR1);
      	  }
      	}
      
      	void loop() {
      	  gw.process();
      
      	  currentTimeCold = millis();
      	  bool sendTimeCold = currentTimeCold - lastSendCold > 1000 * SEND_FREQUENCY;
      	 
      	  if (pcReceivedCold)  {
      	  
      	  readingCold = digitalRead(COLD_WATER_SENSOR_DIGITAL_PIN);
      	  // If the switch changed, due to noise or pressing:
      	  if (readingCold != lastSensorStateCold) {
      		// reset the debouncing timer
      		lastDebounceTimeCold = millis();
      	  }
      	  if ((millis() - lastDebounceTimeCold) > debounceDelayCold) {
      		// whatever the reading is at, it's been there for longer
      		// than the debounce delay, so take it as the actual current state:
      
      		// if the button state has changed:
      		if (readingCold != sensorStateCold) {
      		  sensorStateCold = readingCold;
      
      		  // only toggle the LED if the new button state is HIGH
      		  if (sensorStateCold == 0) {
      			pulseCountCold++;
      		Serial.print(" pulseCountCold ");
      		Serial.println(pulseCountCold);
      			unsigned long newBlinkCold = micros();
      			unsigned long intervalCold = newBlinkCold - lastBlinkCold;
      			lastPulseCold = millis();
      
      			flowCold = (60000000.0 / intervalCold) / ppl;
      			lastBlinkCold = newBlinkCold;
      
      			Serial.print("flowCold");
      			Serial.println(flowCold);
      		  }
      		}
      
      	  }
      	  }else if (sendTimeCold) {
      	   // No count received. Try requesting it again
      		gw.request(CHILD_ID_COLD_WATER, V_VAR1);
      	  }
      	  
      	  currentTimeHot = millis();  
      	  bool sendTimeHot = currentTimeHot - lastSendHot > 1000 * SEND_FREQUENCY;
      	  
      	if (pcReceivedHot)  {
      	  readingHot = digitalRead(HOT_WATER_SENSOR_DIGITAL_PIN);
      	  // If the switch changed, due to noise or pressing:
      	  if (readingHot != lastSensorStateHot) {
      		// reset the debouncing timer
      		lastDebounceTimeHot = millis();
      	  }
      	  if ((millis() - lastDebounceTimeHot) > debounceDelayHot) {
      		// whatever the reading is at, it's been there for longer
      		// than the debounce delay, so take it as the actual current state:
      
      		// if the button state has changed:
      		if (readingHot != sensorStateHot) {
      		  sensorStateHot = readingHot;
      
      		  // only toggle the LED if the new button state is HIGH
      		  if (sensorStateHot == 0) {
      			pulseCountHot++;
      		Serial.print(" pulseCountHot ");
      		Serial.println(pulseCountHot);
      			unsigned long newBlinkHot = micros();
      			unsigned long intervalHot = newBlinkHot - lastBlinkHot;
      			lastPulseHot = millis();
      
      			flowHot = (60000000.0 / intervalHot) / ppl;
      			lastBlinkHot = newBlinkHot;
      
      			Serial.print("flowHot");
      			Serial.println(flowHot);
      		  }
      		}
      
      	  }
      	  }else if (currentTimeHot) {
      	   // No count received. Try requesting it again
      		gw.request(CHILD_ID_HOT_WATER, V_VAR1);
      	  }
      	  
      		// Only send values at a maximum frequency
      	  if (pcReceivedCold && sendTimeCold)  {
      
      		// No Pulse count in 2min reset flow
      	  if (currentTimeCold - lastPulseCold > 120000) {
      		flowCold = 0;
      		if (flowCold != oldflowCold) {
      		  gw.send(flowMsgCold.set(flowCold, 2));                   // Send flow value to gw
      		  oldflowCold = flowCold;
      		  Serial.println("flowCold Reset");
      		}
      	  }
      		// Pulse count has changed
      		if (pulseCountCold != oldPulseCountCold) {
      		  gw.send(pcMsgCold.set(pulseCountCold));                  // Send  volumevalue to gw VAR1
      		  double volumeCold = ((double)pulseCountCold / ((double)PULSE_FACTOR));
      		  oldPulseCountCold = pulseCountCold;
      		  Serial.print("PulseCold count:");
      		  Serial.println(pulseCountCold);
      		  if (volumeCold != oldvolumeCold) {
      			gw.send(volumeMsgCold.set(volumeCold, 3));
      			Serial.print("m3Cold:");
      			Serial.println(volumeCold, 3);
      			oldvolumeCold = volumeCold;
      		  }
      		  if (flowCold != oldflowCold) {
      			gw.send(flowMsgCold.set(flowCold, 2));
      			Serial.print("l/min Cold:");
      			Serial.println(flowCold);
      			oldflowCold = flowCold;
      		  }
      		  lastSendCold = currentTimeCold;
      		}  
      	  }
      		
      	if  (pcReceivedHot && sendTimeHot) {	
      
      	  // No Pulse count in 2min reset flow
      	  if (currentTimeHot - lastPulseHot > 120000) {
      		flowHot = 0;
      		if (flowHot != oldflowHot) {
      		  gw.send(flowMsgHot.set(flowHot, 2));                   // Send flow value to gw
      		  oldflowHot = flowHot;
      		  Serial.println("flowHot Reset");
      		}
      	  }
      		// Pulse count has changed
      		if (pulseCountHot != oldPulseCountHot) {
      		  gw.send(pcMsgHot.set(pulseCountHot));                  // Send  volumevalue to gw VAR1
      		  double volumeHot = ((double)pulseCountHot / ((double)PULSE_FACTOR));
      		  oldPulseCountHot = pulseCountHot;
      		  Serial.print("PulseHot count:");
      		  Serial.println(pulseCountHot);
      		  if (volumeHot != oldvolumeHot) {
      			gw.send(volumeMsgHot.set(volumeHot, 3));
      			Serial.print("m3Hot:");
      			Serial.println(volumeHot, 3);
      			oldvolumeHot = volumeHot;
      		  }
      		  if (flowHot != oldflowHot) {
      			gw.send(flowMsgHot.set(flowHot, 2));
      			Serial.print("l/min Hot:");
      			Serial.println(flowHot);
      			oldflowHot = flowHot;
      		  }
      		  lastSendHot = currentTimeHot;
      		}
      
      	  }
      
      	  lastSensorStateCold = readingCold;
      	  lastSensorStateHot = readingHot;
      
      	  boolean tripped = digitalRead(WATER_LEAK_SENSOR_DIGITAL_PIN) == LOW;
      	  if (tripped != oldtripped) {
      		Serial.println(tripped);
      		gw.send(msg.set(tripped?"1":"0")); 
      		oldtripped = tripped;
      	  }
      
      
      
      	}
      posted in Troubleshooting
      derrij
      derrij
    • RE: IR remote control

      @hek is still it works in 1.4.
      after pressing one of light-switch buttons (on vera) next received IR code leads what sending are looped
      and only next light-switch buttons press stops it loop

      Vera

      			50      03/15/15 13:36:06.195   luup_log:27: Arduino: Set variable: 10;1;1;1;2;1 <0x3073c680>
      			50      03/15/15 13:36:21.179   luup_log:27: Arduino: Sending: 10;1;1;1;2;0 <0x2afdc000>
      			50      03/15/15 13:36:21.216   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:21.310   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.509   luup_log:27: Arduino: Set variable: 10;1;1;0;24;0410a857 <0x3073c680>
      			50      03/15/15 13:36:37.783   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.787   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.791   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.795   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.877   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:37.965   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.054   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.140   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.226   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.312   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.409   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.485   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.573   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.659   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.800   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.832   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:38.920   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.009   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.094   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.181   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.267   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.353   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.439   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.523   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.614   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.700   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.786   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.872   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:39.979   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.783   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.788   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.793   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.798   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.802   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.810   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.814   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.818   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.832   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.836   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:40.913   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.001   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.087   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.176   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.262   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.348   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.434   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.521   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.607   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.693   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.785   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.867   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:41.954   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.034   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.126   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.212   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.301   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.387   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.475   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.561   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.647   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.734   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.820   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.908   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:42.994   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:43.081   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:43.167   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      			50      03/15/15 13:36:43.253   luup_log:27: Arduino: Set variable: 10;1;1;1;2;0 <0x3073c680>
      

      Arduino

      			read: 0-0-10 s=1,c=1,t=2,pt=0,l=1:1
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:1
      			read: 0-0-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			Decoded NEC(1): Value:410A857 (32 bits)
      			Raw samples(68): Gap:38608
      			  Head: m8750  s4450
      			0:m500 s600	1:m500 s600		 2:m450 s600	3:m500 s600		 
      			4:m450 s650	5:m450 s1700		 6:m500 s600	7:m450 s600		 
      			8:m500 s600	9:m450 s600		 10:m500 s600	11:m450 s1750		 
      			12:m450 s600	13:m500 s600		 14:m450 s600	15:m500 s600		 
      
      			16:m450 s1700	17:m500 s600		 18:m500 s1700	19:m500 s550		 
      			20:m500 s1700	21:m500 s600		 22:m450 s600	23:m500 s600		 
      			24:m450 s600	25:m500 s1700		 26:m500 s600	27:m450 s1700		 
      			28:m500 s600	29:m500 s1700		 30:m450 s1700	31:m500 s1700		 
      
      			32:m500
      			Extent=59300
      			Mark  min:450	 max:500
      			Space min:550	 max:1750
      
      			send: 10-10-0-0 s=1,c=1,t=24,pt=0,l=8,st=ok:0410a857
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      			send: 10-10-0-0 s=1,c=1,t=2,pt=0,l=1,st=ok:0
      			read: 0-1-10 s=1,c=1,t=2,pt=0,l=1:0
      posted in Hardware
      derrij
      derrij
    • RE: Send message for another node.

      one from Node 10 to 13 with msgOn.setDestination(13);
      and redirect message through 13 to gateway
      am i understood right?

      posted in General Discussion
      derrij
      derrij
    • RE: Send message for another node.

      not good enough explained first time.

      I got Arduino SceneCtrl 13:3 and i can control it from this node.
      13;3;1;0;19;3
      13;3;1;0;20;3
      And I want send the same command to the gateway
      13;3;1;0;19;3
      13;3;1;0;20;3
      but from Node 10

      posted in General Discussion
      derrij
      derrij
    • Send message for another node.

      From sensor with ID 3 want to send message for scene controller ID 10.
      Can't see if it possible?
      May be possible add this way ?
      MyMessage msgOn(CHILD_ID_SCENE, V_SCENE_ON, NODE_ID);

      posted in General Discussion
      derrij
      derrij
    • RE: Momert 5848-9 bathroom scale (reading from lcd)

      Vera Plugin ScaleSensor
      ScaleSensor.zip

      posted in Hardware
      derrij
      derrij
    • RE: Momert 5848-9 bathroom scale (reading from lcd)

      @ServiceXp said:

      Wild!
      How will you use this? (Its not apparent to me this late at night )

      Every morning, when you stepped on scale, your weight will be sended to Vera, and stored at Datamine Graphing and Logging Plugin.

      posted in Hardware
      derrij
      derrij
    • Momert 5848-9 bathroom scale (reading from lcd)

      Thanks to http://quo.vadis.stojkovic.ch/hacking-a-weighing-scale/ and http://troels.leegaard.org/misc/grundtal20047/ I hacked Momert 5848-9 bathroom scale http://momert.eu/index.php/en/products?page=shop.product_details&flypage=flypage.tpl&category_id=16&product_id=158

      Pin arrangement the same as on IKEA Grundtal scales http://troels.leegaard.org/misc/grundtal20047/grundtal20047.pdf

      Putting 3V to each lcd pin you can figure out what is each pin for. I used 13 lcd pins from 16. https://www.youtube.com/watch?v=yGe3wtwzqf0

      Some photos 20141008_133123.jpg 20141012_150321.jpg 20141012_150915.jpg

      CODE:
      #include <Sleep_n0m1.h>
      #include <SPI.h>
      #include <EEPROM.h>
      #include <RF24.h>
      #include <Sensor.h>

      	#define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      	#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      	#define DI_ID 1                              // Id of the sensor child
      	#define SA_ID 2                              // Id of the sensor child
      	#define VI_ID 3                              // Id of the sensor child
      	#define ALL_ID 4                              // Id of the sensor child
      
      
      	#define DEBUG 1
      
      	int pa,pb,pc,pd;
      	int           lcdA=0,lcdB=0,lcdC=0,lcdD=0;
      	bool          lcd1,lcd2,lcd3,lcd4,lcd5,lcd6,lcd7,lcd8,lcd9;
      	unsigned int  SAn, SBn, SCn, SDn;
      	unsigned int  SA[9], SB[9], SC[9], SD[9];
      	bool          A[9], B[9], C[9], D[9];
      	double weight;                     
      	double oldweight=0;
      
      
      	Sensor gw;
      	Sleep sleep;
      
      	//calculate weight
      	int getDigit(int d)
      	{
      		// d=0,1,2,3
      		int i = 2*d+0;
      		int j = 2*d+1;
      		
      		if ( A[i] &&  A[j] && !B[i] &&  B[j] &&  C[i] &&  C[j] &&  D[i]) return 0; //ok
      		if (!A[i] && !A[j] && !B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 1; //ok
      		if (!A[i] &&  A[j] &&  B[i] &&  B[j] &&  C[i] && !C[j] &&  D[i]) return 2; //ok
      		if (!A[i] &&  A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] &&  D[i]) return 3; //ok
      		if ( A[i] && !A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 4; //ok
      		if ( A[i] &&  A[j] &&  B[i] && !B[j] && !C[i] &&  C[j] &&  D[i]) return 5; //ok
      		if ( A[i] &&  A[j] &&  B[i] && !B[j] &&  C[i] &&  C[j] &&  D[i]) return 6; //ok
      		if (!A[i] &&  A[j] && !B[i] &&  B[j] && !C[i] &&  C[j] && !D[i]) return 7; //ok
      		if ( A[i] &&  A[j] &&  B[i] &&  B[j] &&  C[i] &&  C[j] &&  D[i]) return 8; //ok
      		if ( A[i] &&  A[j] &&  B[i] &&  B[j] && !C[i] &&  C[j] &&  D[i]) return 9; //ok
      		return 0;
      	}
      
      
      	void setup()  
      	{  
      	  gw.begin();
      
      	  // Send the sketch version information to the gateway and Controller
      	  gw.sendSketchInfo("Weight Meter", "1.0");
      
      	  pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      	  // Register all sensors to gw (they will be created as child devices)
      	  gw.sendSensorPresentation(DI_ID, S_WEIGHT);       
      	  gw.sendSensorPresentation(SA_ID, S_WEIGHT); 
      	  gw.sendSensorPresentation(VI_ID, S_WEIGHT); 
      	  gw.sendSensorPresentation(ALL_ID, S_WEIGHT); 
      	}
      
      	void loop()     
      	{     
      
      	  getweightnow();
      
      	 
      	  #if DEBUG
      	  Serial.println("Sleeping.");
      	  #endif
      	  delay(400); //delay to allow serial to fully print before sleep
      	  gw.powerDown();
      	  sleep.pwrDownMode(); //set sleep mode
      	  sleep.sleepInterrupt(INTERRUPT,CHANGE);
      	}
      
      	void getweightnow() {
      	  
      			lcdA = analogRead(A0);
      			lcdB = analogRead(A1);
      			lcdC = analogRead(A2);
      			lcdD = analogRead(A3);
      		// waiting for display (interruption will continue from here)
      		#if DEBUG
      		   Serial.println("Stepped on scale");
      		#endif
      	  
      		// make sure that LCD is active
      	 
      	  
      		// starts measuring
      		#if DEBUG
      			 Serial.println("Mesuring");
      		#endif
      
      		SAn = SBn = SCn = SDn = 0;
      		for (int i=0; i<9; i++)
      			SA[i] = SB[i] = SC[i] = SD[i] = 0;
      		int i=0;
      	  //run while backplanes are active  
      	  while ((lcdA!=0 || lcdB!=0 || lcdC!=0 || lcdD!=0)) {
      			lcdA  = analogRead(A0);
      			lcdB  = analogRead(A1);
      			lcdC  = analogRead(A2);
      			lcdD  = analogRead(A3);
      			 
      			lcd1  = digitalRead(A4);
      			lcd2  = digitalRead(A5);
      			lcd3  = digitalRead(2);
      			lcd4  = digitalRead(3);
      			lcd5  = digitalRead(4);
      			lcd6  = digitalRead(5);
      			lcd7  = digitalRead(6);
      			lcd8  = digitalRead(7);
      			lcd9  = digitalRead(8);
      
      			// decode A, B, C and D signals to -1, 0, 1
      			pa = 0;
      			if (lcdA < 300) pa=-1; else if (lcdA > 600) pa=1;
      			pb = 0;
      			if (lcdB < 300) pb=-1; else if (lcdB > 600) pb=1;
      			pc = 0;
      			if (lcdC < 300) pc=-1; else if (lcdC > 600) pc=1;
      			pd = 0;
      			if (lcdD < 300) pd=-1; else if (lcdD > 600) pd=1;
      			lcdA = pa; lcdB = pb; lcdC = pc; lcdD = pd;
      	  
      			if (lcdA!=0 && lcdB==0 && lcdC==0 && lcdD==0 || 
      				lcdA==0 && lcdB!=0 && lcdC==0 && lcdD==0 || 
      				lcdA==0 && lcdB==0 && lcdC!=0 && lcdD==0 || 
      				lcdA==0 && lcdB==0 && lcdC==0 && lcdD!=0)
      			{
      				if (lcdA==1 || lcdB==1 || lcdC==1 || lcdD==1)
      				{
      					lcd1 = 1-lcd1;
      					lcd2 = 1-lcd2;
      					lcd3 = 1-lcd3;
      					lcd4 = 1-lcd4;
      					lcd5 = 1-lcd5;
      					lcd6 = 1-lcd6;
      					lcd7 = 1-lcd7;
      					lcd8 = 1-lcd8;
      					lcd9 = 1-lcd9;
      				}
      	  
      				if (lcdA != 0)
      				{
      					SA[0] += lcd1;
      					SA[1] += lcd2;
      					SA[2] += lcd3;
      					SA[3] += lcd4;
      					SA[4] += lcd5;
      					SA[5] += lcd6;
      					SA[6] += lcd7;
      					SA[7] += lcd8;
      					SA[8] += lcd9;
      					SAn++;
      				}
      				if (lcdB != 0)
      				{
      					SB[0] += lcd1;
      					SB[1] += lcd2;
      					SB[2] += lcd3;
      					SB[3] += lcd4;
      					SB[4] += lcd5;
      					SB[5] += lcd6;
      					SB[6] += lcd7;
      					SB[7] += lcd8;
      					SB[8] += lcd9;
      					SBn++;
      				}
      				if (lcdC!=0)
      				{
      					SC[0] += lcd1;
      					SC[1] += lcd2;
      					SC[2] += lcd3;
      					SC[3] += lcd4;
      					SC[4] += lcd5;
      					SC[5] += lcd6;
      					SC[6] += lcd7;
      					SC[7] += lcd8;
      					SC[8] += lcd9;
      					SCn++;
      				}
      				if (lcdD!=0)
      				{
      					SD[0] += lcd1;
      					SD[1] += lcd2;
      					SD[2] += lcd3;
      					SD[3] += lcd4;
      					SD[4] += lcd5;
      					SD[5] += lcd6;
      					SD[6] += lcd7;
      					SD[7] += lcd8;
      					SD[8] += lcd9;
      					SDn++;
      				}           
      	  
      				i++;
      			}
      	  
      		
      
      	  if (lcdA==-1 && lcdB==-1 && lcdC==-1  && lcdD==-1 && lcd9==0 && (SA[0]+SA[1]+SA[2]+SA[3]+SA[4]+SA[5]+SA[6]+SA[7]+SA[8]>0)) {
      
      	  
      		// measuring is done
      		#if DEBUG
      			   Serial.println("Done");
      		#endif
      	  
      		// finding the average of signals values during measuring period
      		// not 100% correct, but the fastest way I could think of
      		for (int i=0;i<9;i++)
      		{
      			A[i] = (1.0 * SA[i] / SAn >0.5);
      			B[i] = (1.0 * SB[i] / SBn >0.5);
      			C[i] = (1.0 * SC[i] / SCn >0.5);
      			D[i] = (1.0 * SD[i] / SDn >0.5);
      		}
      
      		// decoding
      		float weight = 100.0*getDigit(0) + 10.0*getDigit(1) + 1.0*getDigit(2) + 0.1*getDigit(3);
      	   
      		#if DEBUG
      		  Serial.print("Weight is: ");
      		  Serial.println(weight);
      		#endif
      		  if (weight != oldweight) {
      			gw.sendVariable(DI_ID, V_WEIGHT, weight,3);               // Send volume value to gw
      		#if DEBUG
      		  Serial.println("Sent");
      		#endif
      			oldweight = weight;
      		  } 
      	break;
      		
      		} //end of if
      	} //end of while  
      
      	}
      

      And now is the question S_WEIGHT sensor-type are working on MySensors Arduino Library (v1.3) and VERA Lite as controller. Or do i need *Sensor1.json *Sensor1.xml files for it working? Because when i included scales node to Vera and restarted Luup, after that all nodes stoped working. Only restoring VERA from backup are helped.

      posted in Hardware
      derrij
      derrij
    • RE: rboard - Cheap relay/radio/arduino board ~$10

      it is possible to add hardware button to the setup and control the relay.

      posted in Hardware
      derrij
      derrij