After installation what I have to do? [solved]

Started by andromeda, May 09, 2015, 05:46:51 PM

Felix


Rick

I completed the Rpi as designed with no significant errors.  The only exception that the chat session worked but the console output in the ssh terminal did not show the debug messages, only the authentication messages.  I completed the Pi Setup Guide with no apparent errors.

I completed the Source Code Setup page with no errors, but I got the same blank gateway home page as the original poster, "Waiting for socket connection". 

I tried running gateway.js again and got the following errors:

pi@raspberrypi ~/moteino $
module.js:340
    throw err;
          ^
Error: Cannot find module 'nedb'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/pi/moteino/gateway.js:64:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
<CR>
[1]+  Exit 8                  node gateway.js


Perhaps gateway.js has not completed?

Another question, what html is being referred to on the Gateway Source Code page http://lowpowerlab.com/gateway/#sourcecode

QuoteOnce that is done, you can get the HTML interface to the garage door, and copy it to your /var/www/default directory you created in the last post (copy these files: index.php, icon.ico).

The referenced link takes me to the Github Pi-Gateway files where I cannot find anything related to garage door.

Rick

Felix

Looks like you're missing the nedb install?

cd ~/moteino
sudo npm install nedb --save


The paragraph you mentioned was copied in error from a previous guide, please ignore it. The link to the files is here.

Rick

You nailed it, Felix.  Thanks!
As I recall, there was an error with the nedb install when I installed socket.io and I fixed it with this from an earlier post in this forum.  After getting through that, I must have skipped nedb and nodemailer.

pi@raspberrypi ~/moteino $ sudo npm install nedb --save
sudo: npm: command not found


Quote from: ssmall on May 05, 2015, 01:51:59 PM
I have same issue.  npm is not set up in my PATH correctly.

Try this:
cd ~/moteino
which npm     // This should give you the path to npm.  In my case it's: /opt/node/bin/npm
sudo /opt/node/bin/npm install nedb --save  // instead of just npm use the path that came back from which:  /opt/node/bin/npm

Felix


Rick

QuoteGreat, so is it all working now?
Not yet, letting the brain cool down for a few minutes, though.

I thought it started working, at least the home page showed connected, but I don't have any nodes running so the page was empty.
Gatewaylog.db shows
{"$$indexCreated":{"fieldName":"n","unique":false,"sparse":false}}
{"$$indexCreated":{"fieldName":"m","unique":false,"sparse":false}}

I did not make any changes and it later quit working.  I am now back to https://192.168.1.12/ showing waiting for a socket connection.

I am learning a lot here and feel I am real close to having this setup working.  Could someone provide a quick checklist of services and dependencies to check and the method of testing?

Also, I have a GarageMote that communicates with the Gateway moteino when connected by serial and Arduino serial monitor.
When connected to the Pi gateway, The GarageMote  flashes like it should, but there is no led activity on the gateway moteino whatsoever.  From the Pi terminal, minicom displays "promiscuous mode", sketch set to false.  Seems at one point I sent a "r" relay check from minicom and got a flash memory dump.  Shouldn't I have seen the same communication I did from Arduino?

Rick

Felix

There are so many moving parts in this setup that it's hard to type a list on every post where something isn't working. The gateway stack setup guide I wrote has all the steps along with explanations of everything and everyone who wants to really understand the hows and whys of all this should go through it at least once.

"Waiting for socket connection.." means your page is loading but your socket is not. It means the gateway.js script might not be running (or something is blocking it which is less likely). The guide has the details of to run that and how to make it run at boot and also how to run it manually and have it not die on you when you logout of SSH. Looking on the page for any js errors might also help explain things (F12 in chrome/firefox etc).
Manually run the script like this and it will persist after logoff:

nohup node gateway.js &


The code for the gateway moteino should be this: https://github.com/LowPowerLab/RFM69/tree/master/Examples/PiGateway
That will forward the packets from the wireless network to your Pi's serial port, and also back to your listening nodes from the gateway UI.

Rick

I guess walking away from it for a while is what I needed!
When I started it up and logged in, I was able to start node with gateway and it worked again.  I will swear I had tried it many times before, but we won't argue with success.

I tried to build my GarageMote and gateway about two years ago and put it away when I could not get it to work.  I have built the Pi from the ground up at least six times now and I have most of the pages almost memorized now.  I am getting closer to the big picture, bus as you say, there is a lot going on here.  Thanks for your comments on gateway.js, it probably was not running.

I now have the two GarageMote moteinos talking to the serial ports but not through the radios.  The gateway side just shows

"Listening at 433 Mhz...
  SPI Flash Init OK. Unique MAC = [D7:63:3C:48:4F:30:8D:2D:]" and does a hex dump when I input a "r" for relay test
.

Since I  have the problem solved related to this thread, I will start a new one if I don't make progress soon.

Thanks for the help!

Felix

Ok great. Regarding the gateway moteino again...

The code for the gateway moteino should be this (be sure to adjust the settings in the sketch to match the radio hardware): https://github.com/LowPowerLab/RFM69/tree/master/Examples/PiGateway
That will forward the packets from the wireless network to your Pi's serial port, and also back to your listening nodes from the gateway UI.

I assume you know that the radios should all have the same frequency, same network ID, unique node IDs, the gateway should  be ID=1. Then you can expect the nodes to talk to your gateway and listen for commands from it. A simple node activity like garage open/close should pop that node in the UI of your gateway. Then you can select the node type (garage Mote) and you should see the OPEN/CLOSE button.

Rick

Quote from: Felix on June 22, 2015, 12:50:47 PM
A simple node activity like garage open/close should pop that node in the UI of your gateway.

Where should I look if this doesn't happen? I do see some entries in gateway_nonmatches.db

Rick

Felix

If you start gateway.js manually (node gateway.js) it will show any serial activity on the SSH console in that same session, so you can see any serial messages.
Otherwise use minicom or any other serial console to talk directly to your gateway moteino the same way you would do on your PC's arduino serial monitor.

LaneF

I'm stuck at the same place as Rick.  Let me list a few things on where I stand.

     Gateway fires up everytime.  Works great.
     I've loaded the PiGateway from Github (commented in the sketch as garagemote)
           Listening at 433 Mhz...  SPI Flash Init OK. Unique MAC =
     I'm trying the simplest of connections with a Weathershield.
         When I use the monitor from within IDE I can see the 29 character output from the shield
           BAT:4.86v F:7577 H:49 P:25.53 (packet length:29)
     I've confirmed the Gatewayid is 1, Networkid is 100 on both, Baudrate is 115200 on both, the Moteino for the Pi is Node 1, the Weathershield is node 2, and the encryption is the same 16 Char for both sketches, the Frequencies are both set to 433 and I removed the // on the #define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!.  line of both sketches (both nodes are HW's).

I saw Felix's post about "baby steps".  I've gone over everything on the list and topics I can find in the forum... the gateway works... the radios just won't talk on 433Mhz. 
https://lowpowerlab.com/forum/index.php/topic,1112.msg7196.html#msg7196

Any test commands, comments, thoughts, ideas... anything, I'm willing to try.

Thanks -
Have a great night.



Felix

Lane,
It sounds like the 2 Moteinos can communicate, correct?
If so, then skip the next paragraph.
If not: let's take a few steps back. I know you said you walked the "baby steps" but I want to ensure your 2 Moteinos can talk to each other. First load them with the example Gateway and Node sketches (adjust settings as appropriate).

Your real gateway code for the PiGateway is this.
This should pass any received RF packets to the serial port of your Pi, which is then picked up by the gateway.js script that handles the whole interface. Please ensure the settings are adjusted in settings.js as well. You must be sure the serial port on your Pi is accessible by the script and is correctly set in settings.js

Could you open minicom to see if you get the same messages you see in the IDE serial monitor?
That would confirm the RF link and serial port are working, and there's something else going on, reading the data from the serial port. The messages should be newline terminated, that's something the PiGateway.ino sketch does.

LaneF

Felix,

The nodes communicate through IDE if plugged in with a USB cable with the FTDI.

I reloaded the R4 w/flash intended as a Gateway with the Gateway sketch you linked to, and the other R4 intended for the Weathershield with the Node Sketch.  The setups came in right with the Network 100, Nodes 1 & 2 respectfully, Baud 115200.  One had a GatewayID 1, one of the sketches did not, is that an issue?  Using IDE I used the Serial Monitor (pic's attached of both) to see the output of each.

You mentioned the serial port on my Pi.  I used your Raspberry Pi image and haven't changed anything since that.  I did a serial test (stty -F /dev/ttyAMA0) I stumbled across (pic attached), not sure if the results are germane to this issue.

I reviewed the Settings.js file from on the RasPi card, it all seems to be correct.  Mostly email and cell phone settings.  I didn't change the serial at all so it's at default. port : '/dev/ttyAMA0'...
  baud : 115200,

I have Minicom installed on my RasPi (sudo apt-get install minicom) but I'm not sure what you'd like me to do with it, or how to use it.  Using Terminal from Mac I remote into the PI.  I just lack the knowledge with minicom from the command line.

Let me know your thoughts.

Thanks
Lane

LaneF

#29
Here's a close up of the jumpers from the Moteino Node to the RasPi Pins.

Maybe I've got something backwards.  The power works (passed the Blinky test), I traced the Tx and Rx to Rx and Tx so I think those are right. 

Regarding the RasPi serial port, I read this on a Pi site, is this applicable to Moteino's?

QuoteBy default, the serial port on the Raspberry Pi is configured as a console port for communicating with the Linux OS shell. If you want to use the serial port in a software program, you must disable the OS from using this port.

Let me know if you spot something.

Thanks
Lane

P.S.  A couple of the pins on the Moteino look like they don't have solder but the solder sucked through to the backside copper.  I check them for continuity to the header and they all had good tone.