Hi Guys,
Thanks for the help in advance.
I am using Moteino gateway app, with NeDB 1.8.0, I see data getting logged by logUtil.js, but I don't see the same being saved in gateway.db, does it have something to do with NeDB version, I have no clue as to why the nodes are not showing up on the gateway app.
If possible can you please share a sample gateway.db file, so that I make sure there is no other configuration or code issue, other than NeDB setup.
How did you install the Gateway app?
Does it have disk permissions to write to that file?
The gateway.db file only logs the node information, the graph data goes in binary files.
Hello Felix,
Thanks for your ever ready help!
I understand the gateway.db logs the node information but the gateway app is not showing any nodes.
I followed the steps you posted in the gateway app guide.
I'm using a moteinoUSB and I changed the settings to ttyUSB0. I believe I followed through all the steps you mentioned.
I'm able to the information from the nodes via Minicom and also in the log file but the nodes are not coming up on the app.
I'm willing to give you access to my system via "Team Viewer" if you don't mind. That might help you understand what's going on exactly.
I'm not sure I understand how to give it disk permission to write to the file? Is there some settings I'm missing out?
If you right click on that file there will be check box's for the permissions. Did you verify that it is ttyUSB0?
This is what I currently have as permission, however, I'm unable to change any permissions on the gateway.db file.
You will need to root ssh into your Pi to make any changes, cant do that from windows explorer ;)
I suggest you revisit the install guide (https://lowpowerlab.com/guide/gateway/setup-software/) for a fresh install.
Although I didn't say, I primarily was showing him how to check the permissions. I used WinSCP which apparently he didn't.
Sorry sparky - I completely missed that ::)
EnMon - which sketch do you use on the MoteinoUSB?
Is it configured as /dev/ttyUSB0 in settings? Does it run at 19200 baud?
Thanks for the help thus far,
@ Felix So I am trying a new install but basically, I am using the Pigateway code attached. I also changed the settings to tty/USB0 which enabled me view the received data via minicom. The only challenge was the database.db was not updating node information, hence the app is showing count 0 for nodes.
@sparky: I used the WinSCP to check for the permissions like you suggested but I couldn't make changes.
I'll give an update as soon as I'm done with the installation. (I actually decided to format the SD card and install NOOBs afresh.)
#define NODEID 1 //the ID of this node
#define NETWORKID 200 //the network ID of all nodes this node listens/talks to
#define FREQUENCY RF69_915MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
#define ENCRYPTKEY "sampleEncryptKey" //identical 16 characters/bytes on all nodes, not more not less!
#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ACK_TIME 30 // # of ms to wait for an ack packet
//*****************************************************************************************************************************
#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL
#define ATC_RSSI -90 //target RSSI for RFM69_ATC (recommended > -80)
//*****************************************************************************************************************************
// Serial baud rate must match your Pi/host computer serial port baud rate!
#define SERIAL_EN //comment out if you don't want any serial verbose output
#define SERIAL_BAUD 19200
//*****************************************************************************************************************************
#ifdef __AVR_ATmega1284P__
#define LED 15 // Moteino MEGAs have LEDs on D15
#define FLASH_SS 23 // and FLASH SS on D23
#else
#define LED 9 // Moteinos have LEDs on D9
#define FLASH_SS 8 // and FLASH SS on D8
#endif
#ifdef SERIAL_EN
#define DEBUG(input) {Serial.print(input); delay(1);}
#define DEBUGln(input) {Serial.println(input); delay(1);}
#else
#define DEBUG(input);
#define DEBUGln(input);
#endif
#ifdef ENABLE_ATC
RFM69_ATC radio;
#else
RFM69 radio;
#endif
SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit Windbond FlashMEM chip
void setup() {
Serial.begin(SERIAL_BAUD);
delay(10);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
//radio.setHighPower(); //uncomment only for RFM69HW!
#endif
radio.encrypt(ENCRYPTKEY);
#ifdef ENABLE_ATC
radio.enableAutoPower(ATC_RSSI);
#endif
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", radio.getFrequency()/1000000);
DEBUGln(buff);
if (flash.initialize())
{
DEBUGln("SPI Flash Init OK!");
}
else
{
DEBUGln("SPI FlashMEM not found (is chip onboard?)");
}
}
byte ackCount=0;
byte inputLen=0;
char input[64];
byte buff[61];
String inputstr;
void loop() {
inputLen = readSerialLine(input);
inputstr = String(input);
inputstr.toUpperCase();
if (inputLen > 0)
{
if (inputstr.equals("KEY?"))
{
DEBUG("ENCRYPTKEY:");
DEBUG(ENCRYPTKEY);
}
byte targetId = inputstr.toInt(); //extract ID if any
byte colonIndex = inputstr.indexOf(":"); //find position of first colon
if (targetId > 0)
{
inputstr = inputstr.substring(colonIndex+1); //trim "ID:" if any
}
if (targetId > 0 && targetId != NODEID && targetId != RF69_BROADCAST_ADDR && colonIndex>0 && colonIndex<4 && inputstr.length()>0)
{
inputstr.getBytes(buff, 61);
//DEBUGln((char*)buff);
//DEBUGln(targetId);
//DEBUGln(colonIndex);
if (radio.sendWithRetry(targetId, buff, inputstr.length()))
{
DEBUGln("ACK:OK");
}
else
DEBUGln("ACK:NOK");
}
}
if (radio.receiveDone())
{
int rssi = radio.RSSI;
DEBUG('[');DEBUG(radio.SENDERID);DEBUG("] ");
if (radio.DATALEN > 0)
{
for (byte i = 0; i < radio.DATALEN; i++)
DEBUG((char)radio.DATA[i]);
DEBUG(" [RSSI:");DEBUG(rssi);DEBUG("]");
}
CheckForWirelessHEX(radio, flash, false); //non verbose DEBUG
if (radio.ACKRequested())
{
byte theNodeID = radio.SENDERID;
radio.sendACK();
DEBUG("[ACK-sent]");
}
DEBUGln();
Blink(LED,3);
}
}
void Blink(byte PIN, int DELAY_MS)
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
Sketch looks fine.
I can support raspbian, I think you can install that via NOOBs. But I know others were able to install this on other distros.
So I'm done with the installation. I am still experiencing the same situation.
I think screenshots will better explain my case.
I think the gateway.db is fine since that file is created by the app anyway.
I see the input from the Moteino but what I don't see is actual data.
Can you show a portion of the log where you're receiving data?
The highlighted line is data coming from Node 3.
Bingo, your data is unrecognized. That will go in the gateway_nonmatches.db instead.
You will need to define a metric under userMetrics folder as outlined in the example.
Thank you so much Felix and Sparky,
I had difficulty matching the metrics to my data but I have been able to fix it.
My Nodes are showing on the app now. :D :D
Yay!
A screenshot to celebrate? :o
Ofcourse!! :D
Thank you so much.
Sweet, I haven't had any luck upgrading to 8.8, I might try to start from scratch. Unless Felix comes out with a pre-built image..!! 8)
Quote from: sparky on January 24, 2017, 04:53:24 PM
Sweet, I haven't had any luck upgrading to 8.8, I might try to start from scratch. Unless Felix comes out with a pre-built image..!! 8)
Actually I want to get
away from a prebuilt image and would rather maintain a script.
The setup script actually works very well and it's fast, gives you a Gateway-Pi in no time, probably less time than downloading a 1GB image.
I'll have to try again, maybe from a fresh raspbian install??. I was getting an error stating something about not able to find nconf module
Get latest raspbian, then follow instructions on the gateway setup page.
Sorry to say, still no luck
When connecting thru browser all I get is waiting for socket connection.
Connecting to Pi thru WinSCP I was able to get log;
[01-25-17_12:13:13.838] [INFO] LOADING USER METRICS...
[01-25-17_12:13:13.872] [INFO] LOADING USER METRICS MODULE [_example.js]
/home/pi/gateway/gateway.js:55
console.error(error.message);
^
TypeError: Cannot read property 'message' of undefined
at SerialPort.serialCloseHandler (/home/pi/gateway/gateway.js:55:22)
at emitNone (events.js:67:13)
at SerialPort.emit (events.js:166:7)
at SerialPortFactory.SerialPort.disconnected (/home/pi/gateway/node_modules/serialport/serialport.js:438:10)
at /home/pi/gateway/node_modules/serialport/serialport.js:236:18
[01-25-17_07:22:50.756] [INFO] LOADING USER METRICS...
[01-25-17_07:22:50.798] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_07:22:50.891] [ERROR] Cannot open /dev/ttyAMA0
[01-25-17_07:23:14.646] [INFO] LOADING USER METRICS...
[01-25-17_07:23:14.680] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_07:23:14.776] [ERROR] Cannot open /dev/ttyAMA0
[01-25-17_07:39:09.383] [INFO] LOADING USER METRICS...
[01-25-17_07:39:09.417] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_07:47:44.832] [INFO] LOADING USER METRICS...
[01-25-17_07:47:44.868] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_07:51:20.438] [INFO] LOADING USER METRICS...
[01-25-17_07:51:20.474] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_07:55:36.160] [INFO] LOADING USER METRICS...
[01-25-17_07:55:36.196] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-25-17_08:07:37.578] [INFO] LOADING USER METRICS...
[01-25-17_08:07:37.611] [INFO] LOADING USER METRICS MODULE [_example.js]
Looks like your serial connection cannot be opened or something related to the serial.
What's the serial port you use? Did you verify valid data is coming through (or at least a valid connection) via minicom?
Using /dev/ttyUSB0
Have not used minicom
Reloading everything this morning but now it appears possibly something wrong with the link to gatewaysetup.sh??
The following error;
[01-25-17_07:23:14.776] [ERROR] Cannot open /dev/ttyAMA0
was prior to me changing it to USB0
Quote from: sparky on January 26, 2017, 08:04:49 AM
Using /dev/ttyUSB0
Have not used minicom
Reloading everything this morning but now it appears possibly something wrong with the link to gatewaysetup.sh??
The setup guide (https://lowpowerlab.com/guide/gateway/setup-software/) points to this script (https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh), hasn't changed at all, is this what you're using?
Yes, that's the one I'm using Felix. I was finally able to download the script.. but with the same, no success, results
Others use the same script and have no issues. That message is indicative of the serial port not being able to open.
You have to ensure the Pi does not lock it up if its the GPIO serial.
Otherwise if its /dev/ttyUSB0 it should just work once you set it in settings and restart the gateway app.
Felix, I'm not blaming your script, just stating my issues. Thanks
Yup, no problem, just trying to say that ... its working for most people even though there are issues with getting that GPIO ttyAMA0 serial port resolved since Pi3 locks it up with the bluetooth.
If I can help with anything let me know, but I just dont have enough info to really tell whats going on, other than the error which hints at a serial port issue.
What's really weird is every time I reload everything;
1. Format card
2. Load raspbian Jessie lite image
3. run sudo wget https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/gatewaysetup.sh
4. sudo bash gatewaysetup.sh
5. During setup I change time zone and keyboard layout. I also enable SSH in advance options.
it act's a little different... meaning, one time I went to look at the logs, both the gateway/logs and data/db folders were empty, no files. reloaded everything the same way and then they were there.
This last time when I went to browse to my pi it went straight to waiting for socket and it never asked for name/password. I did try to delete cookies but it didn't help. There's not that many steps for it to act so different..
Awww... i see they released a new image, that could have something with it.
I will need to check it sometime to see if the script is producing a fail similar to yours. The script was last tested on their last released may 2016 image.
Did you use the raspbian LITE or the full+PIXEL image (https://www.raspberrypi.org/downloads/raspbian/)?
So maybe I'm not going crazy after all.. ::)
Quote from: sparky on January 26, 2017, 10:05:44 PM
So maybe I'm not going crazy after all.. ::)
Not at all, hang tight, I will try it as soon as I can and report back.
Thank you Felix!
Just in case it helps, I was finally able to catch a couple warnings during setup;
npm WARN package.json... something about SPDX license
and npm WARN depreciated
[email protected]...
Warnings I've seen before. It's red errors that would be a problem. Maybe some packages need updates because of the new image/kernel or other updated packages etc.
Got it..
I did find a site to download earlier versions of Jessie lite if you find it necessary
Thanks
Ok here's the may 2016 image I used to develop the setup script. This should really work.
I uploaded this to my google drive and you can try installing with this and let me know how it goes.
I am not sure when I will have time to get to try the new one so in the meantime you can try this.
Download Raspberry Pi Raspbian Jessie Lite May 27 2016 image (https://drive.google.com/open?id=0B89HtwH5i2d0S01jTFk3aDgxNTA)
Also added this link and an update message about this potential issue on the setup guide (https://lowpowerlab.com/guide/gateway/setup-software/).
BTW did you ever try the PiBakery approach? That has a bundled image also.
Ok, thanks
Although I did download and looked at PiBakery, I haven't tried it. I did not see the bundled image..
Well I first want to thank you for all the time you spent with me on this. I reloaded everything using the Jessie image you provided and it still hangs at waiting for socket.
The gateway.sys.log log shows the same error as before but only after the initial boot. I did change the serial to ttyUSB0 The gateway.db of course shows nothing..
[01-27-17_10:03:20.893] [INFO] LOADING USER METRICS...
[01-27-17_10:03:20.922] [INFO] LOADING USER METRICS MODULE [_example.js]
/home/pi/gateway/gateway.js:55
console.error(error.message);
^
TypeError: Cannot read property 'message' of undefined
at SerialPort.serialCloseHandler (/home/pi/gateway/gateway.js:55:22)
at emitNone (events.js:67:13)
at SerialPort.emit (events.js:166:7)
at SerialPortFactory.SerialPort.disconnected (/home/pi/gateway/node_modules/serialport/serialport.js:438:10)
at /home/pi/gateway/node_modules/serialport/serialport.js:236:18
[01-27-17_10:04:47.706] [INFO] LOADING USER METRICS...
[01-27-17_10:04:47.737] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-27-17_10:04:47.833] [ERROR] Cannot open /dev/ttyAMA0
[01-27-17_10:08:29.170] [INFO] LOADING USER METRICS...
[01-27-17_10:08:29.201] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-27-17_10:10:44.112] [INFO] LOADING USER METRICS...
[01-27-17_10:10:44.144] [INFO] LOADING USER METRICS MODULE [_example.js]
[01-27-17_10:21:33.347] [INFO] AUTHORIZING CONNECTION FROM ::1:48620
[01-27-17_10:21:33.367] [INFO] NEW CONNECTION FROM 10.0.0.6
[01-27-17_10:21:38.010] [INFO] AUTHORIZING CONNECTION FROM ::1:48630
[01-27-17_10:21:38.015] [INFO] NEW CONNECTION FROM 10.0.0.6
[01-27-17_10:21:39.122] [INFO] AUTHORIZING CONNECTION FROM ::1:48640
[01-27-17_10:21:39.127] [INFO] NEW CONNECTION FROM 10.0.0.6
[01-27-17_10:22:22.249] [INFO] AUTHORIZING CONNECTION FROM ::1:48650
[01-27-17_10:22:22.252] [INFO] NEW CONNECTION FROM 10.0.0.6
[01-27-17_10:22:50.701] [INFO] AUTHORIZING CONNECTION FROM ::1:48660
[01-27-17_10:22:50.706] [INFO] NEW CONNECTION FROM 10.0.0.6
[01-27-17_10:24:47.597] [INFO] LOADING USER METRICS...
[01-27-17_10:24:47.629] [INFO] LOADING USER METRICS MODULE [_example.js]
One thing I did notice, if it matters, is near the end of the bootup script where it list "My IP address" it doesn't list my IP but instead has a very long string of numbers and letters instead.
Thanks again..
Makes me wonder, other than the version is different, what is the difference between the pre-built image you have versus the script? The pre-built worked flawlessly..
Well, I'm still here.. have not given up yet!
Have not heard back from you in a few days so I thought I would give you the latest in hopes to get this working.
I believe I got "most" of the settings set correct this time.. (100th time is a charm) After re-loading this last time I tried to browse to the gateway only to see "waiting for socket connection" again. I went into the gateway.db and I was happy to see some traffic from my garage mote. Although Internet Explorer didn't work, I tried Chrome and about fell over when the Dashboard came up.. YaHooo!
So what can I be doing wrong that would prevent Internet Explorer from working?
Thanks
Hey sparky,
If the image worked - it means I really have to make time to see why the script is not loading everything correctly on the new Jessie image. It must be some version of the node packages.
The weird numbers represent local ipv6 addresses, ::1:: is localhost for ipv6, see this: https://en.wikipedia.org/wiki/Localhost
FWIW IE is not even a real browser. Not sure I'll spend a whole lot of time trying to unfix a working solution just to make it unwork on that trash called IE.
But you have a "working" setup now right?
Well, looking closer I will say it's sort of works in Chrome. The drop down menu doesn't show "show hidden" see photo
In IE it doesn't work at all.. just shows "waiting for socket connection"
The image I used was the one you posted a link to above..
I will try to get around to making this work. The given image + existing script does work (the last time I tried) and the versions should keep the setup similar between an older successful try and a try now.
I will try to get around to this soon (can't promise it will be tonight).
It's a free open source project and I try to keep it reasonably bug free and updated as time permits.
Felix,
You have enough on your plate, don't worry about it.. I'm fine using Chrome.
Appreciate all your help!
Ok so IE being retarded as usual does not accept default javascript parameters. The fix is to replace this line:
function metricsValues(metrics, ignorePin=false) {
with this:
function metricsValues(metrics, ignorePin) {
if(ignorePin === undefined) ignorePin = false; //default param
This will be included in next release.
Sorry for the late fix.
Also I can confirm the current gateway setup script works with the latest January 2017 Jessie image.
Thanks for your time Felix, much appreciated!