MightyHat doesn't like MOTION

Started by bpr, November 24, 2016, 11:36:41 PM

bpr

I have a MightyHat on my RPI3. I used the https://github.com/LowPowerLab/RaspberryPi-Gateway/tree/master/.setup script from 6 days ago to set it up. Very nice! However, I can't get past one problem. It will not register "MOTION" events in the graph nor record them in the .bin file (as evidenced by the empty .CSV file) but does show the "now" event in the dashboard appropriately. Sometimes one MOTION event might get recorded after a reboot but that's about it. Yet, I am able to associate the MOTION message with an alert, which fires at the appropriate time, so they are definitely being received (which is evidenced by the gateway.db as well). I have the same results whether I use Jessie lite or the full jessie. Other metrics such as BME280 temp and humidity work well. I should mention I do mark the MOTION events with "Data log this metric," and I am using the MotionMote.ino example as supplied (except with the appropriate network encryption key changed). So I am flummoxed! Any help will be appreciated.

Felix

Thanks for the feedback, glad you are finding the new setup useful!

Your issue is more having to do with the sketch and software/firmware rather than MightyHat.
Can you confirm you receive MOTION messages in your Gateway app?
The MotionMote.ino sketch will send "MOTION" messages and as long as you have the right gateway sketch on your MightyHat, it should pass those to the Gateway app which, as defined in metrics.js, will pickup MOTION messages and will log them:

motion : { name:'M', regexp:/MOTION/i, value:'MOTION', pin:1, graph:1, logValue:1, graphValSuffix:' detected!', graphOptions:{ legendLbl:'Motion', lines: { show:false, fill:false }, points: { show: true, radius: 5, lineWidth:1 }, grid: { backgroundColor: {colors:['#000', '#03c', '#08c']}}, yaxis: { ticks: 0 }}},

bpr

Thanks for your reply. I can confirm that the gateway is receiving the MOTION messages yet won't graph or store the MOTION messages yet the gateway does store and graph F and H and V messages. The same result obtains whether I'm using the MIGHTYHat or a USB moteino. I tried your prebuilt image and it worked great without this problem on an RPI2 (though not if I ran the scripts on a fresh rpi image), but when I again set everything up on an RPI3 (and making the necessary changes re the bluetooth issue), I again get the same problem of MOTION messages not being stored or graphed despite accurate entries of the messages in the log/terminal in the browser: I really don't want to use the old prebuilt on an ongoing basis for obvious reasons.
I reinstalled a fresh jessie image on the rpi3 a few times with and without PiBakery and used the setup script from github. I again flashed the latest code onto the MightyHat and USB moteino. If there's any additional info I can provide or steps I can take to troubleshoot/work this through, please let me know. It's such a great setup with so many possibilities when it works!
To reiterate, the Moteino Gateway Dashboard, the Node page (and I can set up and hear an audible Alert as well on the Motion), Log/Terminal screens and the gateway.db file all show messages coming in but there's no recording in the graph or .bin files. Here's some output from the Log/Terminal in case it's illuminating:

6:51:06 PM : {"_id":19,"updated":1480128667321,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128667321,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:51:05 PM : {"_id":88,"updated":1480128667154,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128667154,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128667154,"pin":0,"graph":1}}}
6:50:55 PM : {"_id":19,"updated":1480128657277,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128657277,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:46 PM : {"_id":88,"updated":1480128647875,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128647875,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128647875,"pin":0,"graph":1}}}
6:50:45 PM : {"_id":19,"updated":1480128647279,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128647279,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:38 PM : {"_id":88,"updated":1480128639491,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128639491,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128639491,"pin":0,"graph":1}}}
6:50:36 PM : {"_id":19,"updated":1480128637330,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128637330,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:32 PM : {"_id":78,"updated":1480128634150,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.66,"unit":"°","updated":1480128634150,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128634150,"pin":1,"graph":1}}}
6:50:26 PM : {"_id":78,"updated":1480128627504,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.66,"unit":"°","updated":1480128627504,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128627504,"pin":1,"graph":1}}}
6:50:26 PM : {"_id":19,"updated":1480128627331,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128627331,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:20 PM : {"_id":88,"updated":1480128621529,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128621529,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128621529,"pin":0,"graph":1}}}
6:50:16 PM : {"_id":19,"updated":1480128617287,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128617287,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:06 PM : {"_id":19,"updated":1480128607335,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128607335,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:50:03 PM : {"_id":88,"updated":1480128604394,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128604394,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128604394,"pin":0,"graph":1}}}
6:49:56 PM : {"_id":19,"updated":1480128597293,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128597293,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:48 PM : {"_id":88,"updated":1480128589917,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128589917,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128589917,"pin":0,"graph":1}}}
6:49:46 PM : {"_id":19,"updated":1480128587299,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128587299,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:36 PM : {"_id":19,"updated":1480128577296,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128577296,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:34 PM : {"_id":88,"updated":1480128575578,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128575578,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128575578,"pin":0,"graph":1}}}
6:49:31 PM : {"_id":78,"updated":1480128573085,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.66,"unit":"°","updated":1480128573085,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128573085,"pin":1,"graph":1}}}
6:49:26 PM : {"_id":19,"updated":1480128567302,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128567302,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:25 PM : {"_id":78,"updated":1480128566483,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.68,"unit":"°","updated":1480128566483,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128566483,"pin":1,"graph":1}}}
6:49:16 PM : {"_id":19,"updated":1480128557302,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128557302,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:13 PM : {"_id":88,"updated":1480128555186,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128555186,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128555186,"pin":0,"graph":1}}}
6:49:06 PM : {"_id":19,"updated":1480128547351,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128547351,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:49:01 PM : {"_id":88,"updated":1480128543015,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128543015,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128543015,"pin":0,"graph":1}}}
6:48:56 PM : {"_id":19,"updated":1480128537306,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128537306,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:47 PM : {"_id":88,"updated":1480128528797,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128528797,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128528797,"pin":0,"graph":1}}}
6:48:46 PM : {"_id":19,"updated":1480128527309,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128527309,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:36 PM : {"_id":19,"updated":1480128517310,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128517310,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:35 PM : {"_id":88,"updated":1480128516908,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128516908,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128516908,"pin":0,"graph":1}}}
6:48:30 PM : {"_id":78,"updated":1480128512018,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.66,"unit":"°","updated":1480128512018,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128512018,"pin":1,"graph":1}}}
6:48:26 PM : {"_id":19,"updated":1480128507321,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128507321,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:24 PM : {"_id":78,"updated":1480128505416,"type":"WeatherMote","label":"Weather Sensor","descr":"78","metrics":{"F":{"label":"F","value":70.68,"unit":"°","updated":1480128505416,"pin":1,"graph":1},"H":{"label":"H","value":64,"unit":"%","updated":1480128505416,"pin":1,"graph":1}}}
6:48:22 PM : {"_id":88,"updated":1480128503633,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128501703,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128503633,"pin":0,"graph":1}}}
6:48:20 PM : {"_id":88,"updated":1480128501703,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128501703,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128501703,"pin":0,"graph":1}}}
6:48:16 PM : {"_id":19,"updated":1480128497364,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128497364,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:06 PM : {"_id":19,"updated":1480128487319,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128487319,"pin":1,"graph":1}},"events":{"motionAlert":1}}
6:48:02 PM : {"_id":88,"updated":1480128483769,"type":"MotionMote","label":"Motion Sensor","descr":"88","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128483769,"pin":1,"graph":1},"V":{"label":"V","value":4.15,"unit":"v","updated":1480128483769,"pin":0,"graph":1}}}
6:47:56 PM : {"_id":19,"updated":1480128477370,"type":"MotionMote","label":"Motion Sensor","descr":"19","metrics":{"M":{"label":"M","value":"MOTION","updated":1480128477370,"pin":1,"graph":1}},

bpr

#3
I think I found the source of my problem. It's this line in logUtils.js:

      if (value != lastValue || (timestamp-lastTime>3600)) //only write new value if different than last value or 1 hour has passed (should be a setting?)

Since MOTION always has the same value it won't get recorded to .bin or graphed until the next occurrence is one hour later. Once I changed 3600 to 1, recording the data and graphing works (but only at 1 minute intervals).
Would like higher resolution than 1 minute, not for constant use (huge datafile) but it could be useful. But I'm happy now!

Edit: I guess it's not minutes we're talking about but seconds (I always get that wrong) , so I'll probably change 3600 to 20 or 30 seconds

Felix

Quote from: bpr on November 25, 2016, 11:12:42 PM
I think I found the source of my problem. It's this line in logUtils.js:

      if (value != lastValue || (timestamp-lastTime>3600)) //only write new value if different than last value or 1 hour has passed (should be a setting?)

Since MOTION always has the same value it won't get recorded to .bin or graphed until the next occurrence is one hour later.
That's correct, this only refers to logging. The value should still show in the node, just not get logged unless 1 hour passed. Yes perhaps should be a setting. I may alter this behavior for nodes like MOTION.