LowPowerLab Forum

Software support => Pi Gateway => Topic started by: MikesTechBlog on November 21, 2020, 04:44:11 PM

Title: Weird things since upgrading to gateway 9.1 [solved]
Post by: MikesTechBlog on November 21, 2020, 04:44:11 PM
Hello,

I am sure I am doing something wrong but I can't figure it out. First off some background. I have been running the Pi Gateway for a few years now but I haven't been keeping up with upgrades. If memory serves, I was running something before Ver 8.1 but I don't remember exactly. Everything was working  fine with the gateway and the Moteino's were dutifully reporting.

Recently the gateway (running on a Raspi ver. 2...) quit working. So it was obviously time to upgrade. I bought a new Raspi ver 3.1 installed Buster and the latest gateway ver. 9.1

Now funny things are happening.  First, from the terminal inside the gateway, here is what I see:

16:17:11.379 : /dev/ttyUSB0>:#[16][8] A0:57.83   [RX_RSSI:-38] - ACK sent. Pinging node 8 - ACK...nothing
16:17:01.415 : /dev/ttyUSB0>:#[15][54] A0:72.51 A1:75.99   [RX_RSSI:-51] - ACK sent.
16:16:14.763 : /dev/ttyUSB0>:#[14][57] A0:0.00   [RX_RSSI:-56] - ACK sent.
16:16:06.137 : /dev/ttyUSB0>:#[13][10] F:67.43   [RX_RSSI:-40] - ACK sent. Pinging node 10 - ACK...nothing
16:16:04.729 : /dev/ttyUSB0>:#[12][10] START   [RX_RSSI:-31] - ACK sent.

Every time a node reports, it creates a new node with the number in the first set of square brackets after the # sign.
In other words, the bottom line it created a node number  12. Then from the line above that it created a node number 13, etc. Even though the second set of brackets is the actual node number  (hope I am making sense here...)

I am also quite confused as to how to add my custom metrics into the new version. I have looked at the examples and can't seem to figure it out.

I am guessing that my old version was installed in 2105

Here is a snippet from my old metrics.js file:

Code: [Select]
 //MyTempNode metrics
 //  Each Analog channel is designated as "Ax" Ex: channel 0 = "A0"
  A0 : { name:'A0', regexp:/A0\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A1 : { name:'A1', regexp:/A1\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A2 : { name:'A2', regexp:/A2\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A3 : { name:'A3', regexp:/A3\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A4 : { name:'A4', regexp:/A4\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A5 : { name:'A5', regexp:/A5\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A6 : { name:'A6', regexp:/A6\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},
  A7 : { name:'A7', regexp:/A7\:(-?\d+\.\d+)/i, value:'', unit:'°', pin:1, graph:1, graphValSuffix:'F', graphOptions:{ legendLbl:'Temperature', lines: { lineWidth:1 } }},

==============

I tried adding this as a separate file placed into the /home/pi/gateway/_Lowpowerlab folder. That didn't work.

Next I tried making a new file based on the watermeter file and the weathermote file. Here is what I did in that file:

Code: [Select]
exports.metrics = {
  //My temperatures
  A0 : { name:'A0', regexp:/A0\:([\d\.]+)/i, value:'', unit:'Deg.', graph:1,  graphOptions : { legendLbl:'Degrees', lines: { lineWidth:1 }, colors:['#09c'], tickDecimals: 1} },
  A1 : { name:'A1', regexp:/A1\:([\d\.]+)/i, value:'', unit:'Deg.', graph:1,  graphOptions : { legendLbl:'Degrees', lines: { lineWidth:1 }, colors:['#09c'], tickDecimals: 1} },
  A2 : { name:'A2', regexp:/A2\:([\d\.]+)/i, value:'', unit:'Deg.', graph:1,  graphOptions : { legendLbl:'Degrees', lines: { lineWidth:1 }, colors:['#09c'], tickDecimals: 1} },
  A3 : { name:'A3', regexp:/A3\:([\d\.]+)/i, value:'', unit:'Deg.', graph:1,  graphOptions : { legendLbl:'Degrees', lines: { lineWidth:1 }, colors:['#09c'], tickDecimals: 1} },
  A4 : { name:'A4', regexp:/A4\:([\d\.]+)/i, value:'', unit:'Deg.', graph:1,  graphOptions : { legendLbl:'Degrees', lines: { lineWidth:1 }, colors:['#09c'], tickDecimals: 1} },
}

exports.events = {

}

exports.motes = {
  WeatherMote: {
    label  : 'Weather Sensor',
    icon   : 'icon_weather.png',
    settings: { lowVoltageValue: '' }, //blank will make it inherit from global settings.json lowVoltageValue, a specific value overrides the general setting, user can always choose his own setting in the UI
  },
}
================

Any help would be greatly appreciated.

-- Mike
Title: Re: Weird things since upgrading to gateway 9.1
Post by: Felix on November 24, 2020, 09:29:05 AM
Hi Mike!
I would start from scratch with a new install. There is now 9.2 by the way. Install that version or latest available head code.
Once that install runs, look at how things have reorganized in folders.
Add your metrics and restart and see where it breaks. The metrics syntax has not changed much so it should all work. Keep your own metrics separate from the default ones.
Also you will want to update the PiGateway sketch and then double check the baud matches to the sketch.
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on November 26, 2020, 11:11:29 AM
Thanks Felix. I will do this next week (its Thanksgiving..) I will report back my results.
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on December 06, 2020, 06:53:56 PM
OK finally getting back to this. I did a fresh install of Buster Lite, sudo apt-get update / upgrade. I then downloaded and ran the setup script. Now the gateway doesn't start at all.

I was able to capture the output of the install, and it seems to be missing these directorys:
/home/pi/gateway//.setup
/home/pi/gateway/.git:

Here is a ls -al of my ~/gateway directory:

pi@webserver:~/gateway $ ls -al
total 24
drwxr-xr-x 5 pi   pi   4096 Dec  6 18:29 .
drwxr-xr-x 4 pi   pi   4096 Dec  6 18:29 ..
drwxr-xr-x 4 pi   pi   4096 Dec  6 18:29 data
drwxr-xr-x 2 pi   pi   4096 Dec  6 18:30 logs
-rw-r--r-- 1 pi   pi     27 Dec  6 18:29 package-lock.json
drwxr-xr-x 3 root root 4096 Dec  6 18:29 www
pi@webserver:~/gateway $

=========================

I was able to capture the output of the setup script. Below is what appears to be the pertinent output.

Code: [Select]
************* STEP: Setup Gateway app & dependencies *************
/home/pi/gateway/.git: Permission denied
fatal: not a git repository (or any of the parent directories): .git
#    Installing Latest Stable (v9.2.0).                #
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/gateway/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/gateway/package.json'
npm WARN gateway No description
npm WARN gateway No repository field.
npm WARN gateway No README data
npm WARN gateway No license field.

Thanks in advance for your help!
Title: Re: Weird things since upgrading to gateway 9.1
Post by: Felix on December 07, 2020, 09:56:17 AM
Did you execute the setup commands exactly as described here (https://lowpowerlab.com/guide/gateway/setup-software/)?
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on December 08, 2020, 12:25:55 AM
Yes I did.
I am going to try again just in case I missed something. I will report back
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on December 08, 2020, 11:48:18 AM
OK I just finished with a "ground zero" reinstall. I must have done something wrong the previous time, as I now have the gateway running.

However I am now back to my original problem. That is every time a Moteino sends data to the gateway it creates a new node. The baud rate is correct, as I installed minicom and shut down the gateway and I am getting data. But something strange is happening, and I suspect that it is from the Motenio that is attached to the Raspi.

Here is why, for general debugging I have a Moteino connected to another (unrelated..) Raspberry pi that runs in promiscuous mode. Here is what I get when monitoring it, which are the RF packets:

[55] 51.63   [RX_RSSI:-92]
[166] START   [RX_RSSI:-47]
[166] START   [RX_RSSI:-46]
[1] ACK TEST   [RX_RSSI:-47]
[166] BAT:3.38v F:6497 H:81   [RX_RSSI:-69]
[55] 51.63   [RX_RSSI:-71]
[55] 51.63   [RX_RSSI:-92]

All this seems correct and is what is being sent via RF to the gateway.

So now I shutdown the gateway and run minicom and watch the raw data come from the Moteino connected to /dev/ttyUSB0 and I get this:

RFM69_ATC Enabled (Auto Transmission Control)
#[1][54] A0:77.15 A1:75.99   [RX_RSSI:-46] - ACK sent. Pinging node 54 - ACK...g
#[2][166] START   [RX_RSSI:-32] - ACK sent.
#[3][166] BAT:3.40v F:6485 H:81   [RX_RSSI:-31] - ACK sent.
#[4][166] START   [RX_RSSI:-32] - ACK sent. Pinging node 166 - ACK...nothing
#[5][166] BAT:3.38v F:6510 H:83   [RX_RSSI:-31] - ACK sent.
#[6][166] START   [RX_RSSI:-30] - ACK sent.
#[7][166] BAT:3.37v F:6521 H:85   [RX_RSSI:-29] - ACK sent. Pinging node 166 - g
#[8][166] START   [RX_RSSI:-32] - ACK sent.
#[9][166] BAT:3.38v F:6549 H:88   [RX_RSSI:-31] - ACK sent.

The Moteinio I am using that is connected to the pi is a Moteino-R5-USB I am guessing the code was compiled around 2016.

I welcome your suggestions - Thanks for your time.

-- Mike
Title: Re: Weird things since upgrading to gateway 9.1
Post by: Felix on December 08, 2020, 12:44:25 PM
Guessing works sometimes but not in electronics  :'(
What firmware is on the gateway Moteino?
Does the BAUD in the GUI match that of that firmware?
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on December 09, 2020, 09:11:44 AM
Yes the baud in the gui matches that of the firmware. Seems to me that if it didn't I would get garbage. But I get readable text.

The baud rate is 115200 - which worked fine on the very old version of the gateway that was on a Pi ver.2

Here is the code running on the Moteino attached to the gateway.

.....
Title: Re: Weird things since upgrading to gateway 9.1
Post by: Felix on December 09, 2020, 09:34:12 AM
I cant read pages of pasted code, sorry, no point pasting it here.
Instead I created known working sketches which I put in the Examples. For your purposes here's the correct sketch to start with: https://github.com/LowPowerLab/RFM69/blob/master/Examples/PiGateway_Basic/PiGateway_Basic.ino
Title: Re: Weird things since upgrading to gateway 9.1
Post by: MikesTechBlog on December 09, 2020, 05:51:56 PM
Got it working - per your suggestion, I installed the sketch in the link you provided. That was the fix.

Thank you. I appreciate your patience.

-- Mike
Title: Re: Weird things since upgrading to gateway 9.1 [solved]
Post by: Felix on December 10, 2020, 09:46:08 AM
Awesome, thanks for the update. Marked as [solved]  ;)
I would only ask 1 more favor - if you need to paste code and logs, please use a code block for more readability, in general the idea is to make it easy to parse through a lot of text quickly, it makes my life easier trying to help with the correct understanding of what's going on.