Distance Sensor not Updating in Vera

So I had an Nano dedicated to a distance sensor in my setup before updating to 1.3 that worked alright. When I updated to 1.3, I decided to combine it into a Nano that included a Motion and DHT sensor.

I updated my sketch to include all components and when I do a serial monitor, I See everything updating as it should for all 3 sensors.

I then connected to the GW on Serial Monitor and again, I see the info from all three sensors getting to it without issue.

Now the problem, The motion and DHT sensor are updating in Vera, however the distance sensor will not show any values.

I did make sure to update to the new files on Vera for the Distance sensor. I see it updating in the vera logs as well. All appears to be in order… what am I missing?

So I am looking into this deeper this morning and noticed in the logs that the device ID that is updating for distance is Device 146. The device ID in the GUI is shooing 214. So this to me explains why I am not seeing any info in the GUI. I tried to manually change the ID and that did some really weird things and caused Vera to reboot and default back to 214.

I see why the reboot happened I think. Device 146 was for my Humidity portion of the DHT (didn’t notice this until it disappeared).

So how do I get these device ID’s to match proper? How are things getting confused like this?

I don’t know for sure wayne, but you could try to delete the node and the three sensor devices and then re-include them to see if that clears it up.

Thanks for responding, and I was thinking like you and just finished this process. I did eprom clear and started from scratch with all the sensors.

They all came back, but distance is still not working and I see now that in the logs that the distance is being sent to the device ID for the temp sensor now (temp sensor is working still).

Is there a way that I can manually change the device ID in the background where the distance is being sent?

Here is from the Vera Logs, you can see that Temp ID is 215, but distance is being sent to 215 as well when it should be 216

03/09/14 9:36:57.333	luup_log:131: Arduino: Set Var: 2;2;1;16;0 __LEAK__ this:24576 start:3678208 to 0x1785000 <0x305ee680>
50	03/09/14 9:36:57.334	luup_log:131: Arduino: Setting variable 'Tripped' to value '0' <0x305ee680>
50	03/09/14 9:36:57.334	luup_log:131: Arduino: urn:micasaverde-com:serviceId:SecuritySensor1,Tripped, 0, 217 <0x305ee680>
50	03/09/14 9:36:57.335	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394379417, 217 <0x305ee680>
06	03/09/14 9:36:57.335	Device_Variable::m_szValue_set device: 217 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394379412 now: 1394379417 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x305ee680>
50	03/09/14 9:36:57.363	luup_log:131: Arduino: Set Var: 2;0;1;13;5 __LEAK__ this:4096 start:3682304 to 0x1786000 <0x305ee680>
50	03/09/14 9:36:57.364	luup_log:131: Arduino: Setting variable 'CurrentDistance' to value '5' <0x305ee680>
50	03/09/14 9:36:57.364	luup_log:131: Arduino: urn:micasaverde-com:serviceId:DistanceSensor1,CurrentDistance, 5, 215 <0x305ee680>
06	03/09/14 9:36:57.365	Device_Variable::m_szValue_set device: 215 service: urn:micasaverde-com:serviceId:DistanceSensor1 variable: CurrentDistance was: 6 now: 5 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x305ee680>
50	03/09/14 9:36:57.365	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394379417, 215 <0x305ee680>
06	03/09/14 9:36:57.366	Device_Variable::m_szValue_set device: 215 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394379406 now: 1394379417 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x305ee680>
50	03/09/14 9:36:57.367	luup_log:131: Arduino: Set Var: 2;0;1;1;28.1 <0x305ee680>
50	03/09/14 9:36:57.367	luup_log:131: Arduino: Setting variable 'CurrentLevel' to value '28.1' <0x305ee680>
50	03/09/14 9:36:57.368	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HumiditySensor1,CurrentLevel, 28.1, 215 <0x305ee680>
06	03/09/14 9:36:57.368	Device_Variable::m_szValue_set device: 215 service: urn:micasaverde-com:serviceId:HumiditySensor1 variable: CurrentLevel was: 28.3 now: 28.1 #hooks: 0 upnp: 0 v:0xe65590/NONE duplicate:0 <0x305ee680>
50	03/09/14 9:36:57.369	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394379417, 215 <0x305ee680>
06	03/09/14 9:36:57.369	Device_Variable::m_szValue_set device: 215 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394379417 now: 1394379417 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x305ee680>

Sorry to pester, but is this something that I am missing in a config somewhere (I would assume that if I am seeing it in the Vera Logs, that setup is proper all the way up to Vera)? To me this seems to be a bug somewhere on the Vera side (maybe with plugin), or I am just not figuring this out. I know enough to troubleshoot this, but don’t know the depths of Vera to fix.

Really would appreciate help on this. My plan is to use this to track vehicle position in the garage (keep me from making a drivethru :))

Again, the arduino I am using has DHT and Motion Sensors that work without issue, and the distance appears to be working without issue until it gets to vera. The info from the distance sensor is being sent to the wrong device and I can’t figure out how to resolve this. I did remove the whole entire node and rebuild it from scratch with the same results (this time with different device ID’s then previous). It just seems to want to use the same device ID as the DHT and I can’t seem to figure this out.

Wayne,

That is strange - I suggest that you post your sketch here so people can take a look at the code…

Thanks,
Bruce

Also, what is the altId (Advanced tab) of the distance sensor in vera?

Sorry for the delay. Here is what I have done.
-Cleared Eprom (verified that serial monitor showed no activity)
-Uninstalled Arduino Software from PC completely and reinstalled
-Uploaded the Sketch
-It created all the devices
Motion Device ID 225
Temp Device ID 228
Humidity Device ID 227
Distance Device ID 226

Alt ID for Distance Sensor is 7;3 and Humidity is 7;0

Again all sensors appear to be working and sending the data, except that the data for the Distance Sensor is going to the humidity device in Vera.

Here are the current Logs from the last poll (You can see distance is 3 Inches sent to Device 227 which is the humidity Device):

03/12/14 14:18:14.104	luup_log:131: Arduino: Incoming internal command discarded <0x2fbec680>
04	03/12/14 14:18:14.106	<Job ID="19" Name="pollnode #75 0 cmds" Device="100" Created="2014-03-12 14:18:14" Started="2014-03-12 14:18:14" Completed="2014-03-12 14:18:14" Duration="0.3539000" Runtime="0.869000" Status="Aborted" LastNote="" Node="75" NodeType="ZWaveController" NodeDescription="Master Scene Switch"/> <0x2b791680>
50	03/12/14 14:18:14.114	luup_log:131: Arduino: Presentation: 7;0;0;7;1.2+ <0x2fbec680>
50	03/12/14 14:18:14.115	luup_log:131: Arduino: Presentation: 7;1;0;6;1.2+ <0x2fbec680>
50	03/12/14 14:18:14.116	luup_log:131: Arduino: Presentation: 7;2;0;1;1.2+ <0x2fbec680>
50	03/12/14 14:18:14.117	luup_log:131: Arduino: Presentation: 7;3;0;15;1.2+ <0x2fbec680>
50	03/12/14 14:18:14.118	luup_log:131: Arduino: Sending: 7;255;4;13;I <0x2fbec680>
50	03/12/14 14:18:14.174	luup_log:131: Arduino: Set Var: 7;2;1;16;1 <0x2fbec680>
50	03/12/14 14:18:14.174	luup_log:131: Arduino: Setting variable 'Tripped' to value '1' <0x2fbec680>
50	03/12/14 14:18:14.174	luup_log:131: Arduino: urn:micasaverde-com:serviceId:SecuritySensor1,Tripped, 1, 225 <0x2fbec680>
50	03/12/14 14:18:14.175	luup_log:131: Arduino: urn:micasaverde-com:serviceId:SecuritySensor1,LastTrip, 1394655494, 225 <0x2fbec680>
06	03/12/14 14:18:14.175	Device_Variable::m_szValue_set device: 225 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: LastTrip was: 1394655464 now: 1394655494 #hooks: 0 upnp: 0 v:0xe0eaa0/NONE duplicate:0 <0x2fbec680>
50	03/12/14 14:18:14.177	luup_log:131: Arduino: Set Var: 7;0;1;13;3 <0x2fbec680>
50	03/12/14 14:18:14.177	luup_log:131: Arduino: Setting variable 'CurrentDistance' to value '3' <0x2fbec680>
50	03/12/14 14:18:14.177	luup_log:131: Arduino: urn:micasaverde-com:serviceId:DistanceSensor1,CurrentDistance, 3, 227 <0x2fbec680>
50	03/12/14 14:18:14.178	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394655494, 227 <0x2fbec680>
06	03/12/14 14:18:14.178	Device_Variable::m_szValue_set device: 227 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394655464 now: 1394655494 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fbec680>
50	03/12/14 14:18:14.179	luup_log:131: Arduino: Set Var: 7;1;1;0;57.0 <0x2fbec680>
50	03/12/14 14:18:14.180	luup_log:131: Arduino: Setting variable 'CurrentTemperature' to value '57.0' <0x2fbec680>
50	03/12/14 14:18:14.180	luup_log:131: Arduino: urn:upnp-org:serviceId:TemperatureSensor1,CurrentTemperature, 57.0, 228 <0x2fbec680>
50	03/12/14 14:18:14.181	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394655494, 228 <0x2fbec680>
06	03/12/14 14:18:14.181	Device_Variable::m_szValue_set device: 228 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394655464 now: 1394655494 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2fbec680>
50	03/12/14 14:18:14.182	luup_log:131: Arduino: Set Var: 7;0;1;1;24.2 <0x2fbec680>
50	03/12/14 14:18:14.183	luup_log:131: Arduino: Setting variable 'CurrentLevel' to value '24.2' <0x2fbec680>
50	03/12/14 14:18:14.183	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HumiditySensor1,CurrentLevel, 24.2, 227 <0x2fbec680>
06	03/12/14 14:18:14.183	Device_Variable::m_szValue_set device: 227 service: urn:micasaverde-com:serviceId:HumiditySensor1 variable: CurrentLevel was: 24.9 now: 24.2 #hooks: 0 upnp: 0 v:0xe2d780/NONE duplicate:0 <0x2fbec680>
50	03/12/14 14:18:14.184	luup_log:131: Arduino: urn:micasaverde-com:serviceId:HaDevice1,LastUpdate, 1394655494, 227 <0x2fbec680>
06	03/12/14 14:18:14.185	Device_Variable::m_szValue_set device: 227 service: urn:micasaverde-com:serviceId:HaDevice1 variable: LastUpdate was: 1394655494 now: 1394655494 #hooks: 0 upnp: 0 v:

Here is my sketch (i know it is probably messy, I am still learning)

#include <Sleep_n0m1.h>
#include <SPI.h>
#include <EEPROM.h>  
#include <RF24.h>
#include <Sensor.h>  
#include <DHT.h>
#include <NewPing.h>

// Set RADIO_ID to something unique in your sensor network (1-254)
// or set to AUTO if you want gw to assign a RADIO_ID for you.
#define RADIO_ID AUTO
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 5 //Default 3
#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 CHILD_ID 2   // Id of the sensor child Default
#define TRIGGER_PIN  6  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     7  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 30 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
unsigned long SLEEP_TIME = 5; // Sleep time between reads (in seconds)


//unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)

Sensor gw (9,10);
DHT dht;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
Sleep sleep;

float lastTemp;
float lastHum;
boolean metric = true;
int lastDist;

void setup()  
{ 
  Serial.begin(BAUD_RATE);  // Used to type in characters
  gw.begin(RADIO_ID);
  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
  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(CHILD_ID_HUM, S_HUM);
  gw.sendSensorPresentation(CHILD_ID_TEMP, S_TEMP);
  gw.sendSensorPresentation(CHILD_ID, S_MOTION);
  gw.sendSensorPresentation(3, S_DISTANCE);
  
  metric = gw.isMetricSystem();
  
}

void loop()      
{     
    // Read digital motion value
  gw.powerUp();
  boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
        
  Serial.println(tripped);
  gw.sendVariable(CHILD_ID, V_TRIPPED, tripped?"1":"0");  // Send tripped value to gw 
  
  //Distance
  int dist = metric?sonar.ping_cm():sonar.ping_in();
  Serial.print("Ping: ");
  Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
  Serial.println(metric?" cm":" in");


  if (dist != lastDist) {
      gw.sendVariable(0, V_DISTANCE, dist);
      lastDist = dist;
  }
  //DHT Sensor
  //delay(dht.getMinimumSamplingPeriod());

  float temperature = dht.getTemperature();
  if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
  } else if (temperature != lastTemp) {
    lastTemp = temperature;
    if (!metric) {
      temperature = dht.toFahrenheit(temperature);
    }
    gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperature, 1);
      Serial.print("T: ");
      Serial.println(temperature);
  }
  
  float humidity = dht.getHumidity();
  if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
  } else if (humidity != lastHum) {
      lastHum = humidity;
      gw.sendVariable(CHILD_ID_HUM, V_HUM, humidity, 1);
      Serial.print("H: ");
      Serial.println(humidity);
  }

  // Power down the radio.  Note that the radio will get powered back up
  // on the next write() call.
  delay(200); //delay to allow serial to fully print before sleep
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepInterrupt(INTERRUPT,CHANGE);
  //sleep.sleepDelay(SLEEP_TIME * 1000); //sleep for: sleepTime 
}

if (dist != lastDist) {
gw.sendVariable(3, V_DISTANCE, dist);
lastDist = dist;
}

that would make sense… let me try that and let the thread know.

Thanks for the quick response.

You are my new best friend Hek.

That did the trick. Thanks again. This stuff I enjoy a lot, but has a steep learning curve for someone that doesn’t really know how to code very well.

[quote=“waynehead99, post:11, topic:180057”]You are my new best friend Hek.

That did the trick. Thanks again. This stuff I enjoy a lot, but has a steep learning curve for someone that doesn’t really know how to code very well.[/quote]

Glad it helped!

Hehe… but you must have a very tragic life if a geek you’ve never met is your new best friend :wink: