Difference between revisions of "Pi and pine"

From Wiki2
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
=pi2 pi3 pine64=
=pi2 pi3 pine64=
In general you can't edit root owned files with WinSCP unless you are root. The only way to be root is to be able to login as root from  
====device ip addresses====
To find out the ip adresses assigned to a device use the zenmap windows program and put in the command
nmap -sP 10.0.1.0/24
 
====hosts====
To change the host from ubuntu to pi3
 
sudo nano /etc/hostname
 
then reboot
 
windowsstartmenu->search->hosts opens the notepad to edit the /Windows/System32/drivers/etc/hosts file
 
Now you and update the ip for pi2 pine64 and whatever else there and refer to the devices as root@pi2 and ssh root@pine64 in ssh and winSCP
 
(found the start menu windowsstartmenu->allprograms->rightclick->open and rightclick->new->shortcut and put in "notepad.exe /Windows/System32/drivers/etc/hosts", named it hosts and the rightclicked on hosts ->advanced->runasAdminiistrator)
 
====id.rsa certs for winSCP and ssh====
<s>In general you can't edit root owned files with WinSCP unless you are root. The only way to be root is to be able to login as root from  
  sudo nano /etc/ssh/sshd_config
  sudo nano /etc/ssh/sshd_config
by changing
by changing
Line 6: Line 24:
to
to
  PermitRootLogin yes
  PermitRootLogin yes
restart sshd service using:
/etc/init.d/ssh restart
:ref: http://raspberrypi.stackexchange.com/questions/48056/login-as-root-not-possible</s>
But that is not really smart, you should keep your id_rsa.pub certificate from your laptop in the server users ./ssh/authorized_keys file


and then switch back to
PermitRootLogin without-password
restart sshd service using:
/etc/init.d/ssh restart
{{:ubuntu 16.04}}
{{:ubuntu 16.04}}
{{:pine64}}
{{:pine64}}
{{:pi}}
{{:pi}}

Latest revision as of 00:42, 28 January 2017

pi2 pi3 pine64

device ip addresses

To find out the ip adresses assigned to a device use the zenmap windows program and put in the command

nmap -sP 10.0.1.0/24

hosts

To change the host from ubuntu to pi3

sudo nano /etc/hostname

then reboot

windowsstartmenu->search->hosts opens the notepad to edit the /Windows/System32/drivers/etc/hosts file

Now you and update the ip for pi2 pine64 and whatever else there and refer to the devices as root@pi2 and ssh root@pine64 in ssh and winSCP

(found the start menu windowsstartmenu->allprograms->rightclick->open and rightclick->new->shortcut and put in "notepad.exe /Windows/System32/drivers/etc/hosts", named it hosts and the rightclicked on hosts ->advanced->runasAdminiistrator)

id.rsa certs for winSCP and ssh

In general you can't edit root owned files with WinSCP unless you are root. The only way to be root is to be able to login as root from

sudo nano /etc/ssh/sshd_config

by changing

PermitRootLogin without-password

to

PermitRootLogin yes

restart sshd service using:

/etc/init.d/ssh restart
ref: http://raspberrypi.stackexchange.com/questions/48056/login-as-root-not-possible

But that is not really smart, you should keep your id_rsa.pub certificate from your laptop in the server users ./ssh/authorized_keys file

and then switch back to

PermitRootLogin without-password

restart sshd service using:

/etc/init.d/ssh restart

ubuntu 16.04

back to pi and pine

manual install to ubuntu

  1. wget
  2. create binaries
  3. add user
  4. change owner/permissions strip extra shit
  5. copy binaries to /usr/bin
  6. create a log directory
  7. set its owner/premisions
  8. create a /etc/mongodb.conf
  9. create systemd seervice entry
  10. sudo service mongodb start/status/stop
  11. create symlinks to executable directories
  12. create symlink to buried conf files

pine64

backto pi and pine

pi

back to pi and pine

keep shit in c://iot/pi user ubuntu paswd Pinj

in winscp new sessions window edit advanced advanced shell shell sudo-s from dropdown

http://yannickloriot.com/2016/04/install-mongodb-and-node-js-on-a-raspberry-pi/

installed node with the 16.04 instructions using nvm

http://raspberrypi.stackexchange.com/questions/48056/login-as-root-not-possible

systemctl start mongodb
systemctl enable mongodb

getting started

setting up python

sudo apt-get update
sudo apt-get python-pip
sudo apt-get install python-dev
sudo pip install virtualenv

create a project directory

cd projdir
virtualenv venv

running in a virtualenv doesn't work because pi doesn't have access to /dev/mem which is used by GPIO

so all the following commmands need sudo

install flask

pip install Flask

install gevent

pip install gevent 
pip install RPi.GPIO
pip install -U flask-cors
sudo python cascada2.py

default

user pi passwd raspberry

current

pi@10.0.1.155 ranj..

login loop

-bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file or directory

http://raspberrypi.stackexchange.com/questions/36467/how-to-repair-login-loop-bash-error

https://www.raspberrypi.org/forums/viewtopic.php?uid=159601&f=28&t=120846&start=0

https://www.raspberrypi.org/forums/ucp.php

bluetooth 4.0 LE

http://www.ioncannon.net/linux/1570/bluetooth-4-0-le-on-raspberry-pi-with-bluez-5-x/

http://www.elinux.org/RPi_Bluetooth_LE

python

jupyter on python3

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-jupyter-notebook-to-run-ipython-on-ubuntu-16-04


is installed in omen www/environments/jup

tim@omen:/d/fs/www/environments$ pyvenv jup
tim@omen:/d/fs/www$ cd environments/
tim@omen:/d/fs/www/environments$ . jup/bin/activate
(jup) tim@omen:/d/fs/www/environments$ jupyter notebook

(jup) tim@omen:/d/fs/www/environments/jup/bin$ deactivate

accessing object properties

status ={}
status['pond'] = {'spot': 'center', 'state': 'off', 'tleft': 0, 'nexton': 9}
status['pond']['tleft']= 16

parsing u'5'

basic tutorial

https://thenewcircle.com/static/bookshelf/python_fundamentals_tutorial/advanced_types_containers.html

running app forever - supervisorctl

cascada

port = 8087
/home/pi/mypi/cascada/server/cascada.py

cascada2

port = 8088
/home/pi/mypi/cascada/server/cascada2.py

<markdown>

sudo`supervisorctl` reads configuration from `/etc/supervisor/conf.d` and runs whatever files if finds there.

a typical `conf` ile looks like:

   [program:cascada2]
   command=/usr/bin/python /home/pi/mypi/cascada/server/cascada2.py
   directory=/home/pi/mypi/cascada/server
   autostart=true
   autorestart=true
   startretries=3
   stderr_logfile=/var/log/cascada/cascada2.err.log
   stdout_logfile=/var/log/cascada/cascada2.out.log
   user=root
   environment=SECRET_PASSPHRASE='this is secret',SECRET_TWO='another secret'

you may have to `>supervisor reload` then `ctrl c` the `sudo supervisorctl` to get a new program running forever

</markdown>

pi@raspberrypi ~ $ sudo supervisorctl
cascada                          RUNNING    pid 2273, uptime 7 days, 3:17:36


tail -f /var/log/cascada/cascada.out.log
tail -f /var/log/cascada/cascada.err.log

after changing cascada.py

pi@raspberrypi ~ $ sudo supervisorctl
cascada                          RUNNING    pid 2273, uptime 7 days, 3:17:36
supervisor> stop cascada

exit w ctrl C

sudo lsof -i :8087
sudo kill -9 21118 (kill whatever port lsof returns)
pi@raspberrypi ~ $ sudo supervisorctl
cascada                          STOPPED    Jul 16 04:34 PM
supervisor> start cascada
cascada: started
supervisor>

exit w ctrl C ??

  • nohup python app.py &
  • use screen
  • run supervisord(link) on system startup and control all through it (pythonic way :))

nohup means: do not terminate this process even when the stty is cut off.

& at the end means: run this command as a background task.

forever with supervisord

SSE - Server Side Events

http://flask.pocoo.org/snippets/116/

https://github.com/stevenewey/ssedemo


for node

https://www.npmjs.com/package/simple-sse (has room,haven't tried)

https://tomkersten.com/articles/server-sent-events-with-node/

http://www.futureinsights.com/home/real-time-the-easy-way-with-eventsource-angularjs-and-nodejs.html

SocketIO

http://stackoverflow.com/questions/17641602/how-to-emit-to-room-in-socket-io

flask socketio

https://flask-socketio.readthedocs.org/en/latest/

ibeacon

http://www.jaredwolff.com/blog/get-started-with-bluetooth-low-energy/ decribes gattr tool as well

xyfindit

00:eb:19:00:b7:b9,07775dd0111b11e491910800200c9a66,6400,47033,-59,-68

android

https://github.com/alt236/Bluetooth-LE-Library---Android

distance

http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing

http://en.wikipedia.org/wiki/DBm

The iBeacon output power is measured (calibrated) at a distance of 1 meter. Let's suppose that this is -59 dBm (just an example). The iBeacon will include this number as part of its LE advertisment.

The listening device (iPhone, etc), will measure the RSSI of the device. Let's suppose, for example, that this is, say, -72 dBm.

Since these numbers are in dBm, the ratio of the power is actually the difference in dB. So:

ratio_dB = txCalibratedPower - RSSI To convert that into a linear ratio, we use the standard formula for dB:

ratio_linear = 10 ^ (ratio_dB / 10) If we assume conservation of energy, then the signal strength must fall off as 1/r^2. So:

power = power_at_1_meter / r^2. Solving for r, we get:

r = sqrt(ratio_linear) In Javascript, the code would look like this:

function getRange(txCalibratedPower, rssi) {

   var ratio_db = txCalibratedPower - rssi;
   var ratio_linear = Math.pow(10, ratio_db / 10);
   var r = Math.sqrt(ratio_linear);
   return r;

} Note, that, if you're inside a steel building, then perhaps there will be internal reflections that make the signal decay slower than 1/r^2. If the signal passes through a human body (water) then the signal will be attenuated. It's very likely that the antenna doesn't have equal gain in all directions. Metal objects in the room may create strange interference patterns. Etc, etc... YMMV.

shareeditflag edited Feb 7 '14 at 2:19

answered Feb 7 '14 at 1:24

Mark Fassler 43135

http://stackoverflow.com/questions/15687332/bluetooth-le-rssi-for-proximity-detection-ios

estimote

Hi Wojtek,

Yep I got them and they are an exciting technology. But I must live in a 2.4 ghz jungle. That and the interesting variability you get between dog lying down, standing up and walking around can alter their signal markedly. Add to that the changes to the signal as I move about the house with my phone and you have a real puzzle.

I have better luck fixing by fixing my bluetooth receiver(s) and not detecting the beacons from mobile devices.

So I have set up raspberry pi's at key points in the yard to track the beacons. Using the libraries Bluez and Bluepy. I am able to estimate distance using the dB difference between the RSSI and the dB at 1 meter to get a power ratio that varies with the square of the distance. It is still cranky but once I put a few pi's in the yard I'll have boatloads of data to play around with.

It will be interesting to try out some filters, maybe put the data through a Hidden Markov Model or train up a neural network.

I have got some other beacons from other manufacturers and they all have similar variability. What would keep my concentration on Estimotes would be a bit of information on the Unknown Services that show up on scans. In particular, you advertise your beacons as standing out with capabilities like the accelerometer on board. How do I read that?

Meanwhile, the pi's are running a little restful API and some socket.io to communicate with my mobile devices and laptops. I'll have a mobile friendly responsive design HTML5/javascript app running soon. If I was doing dedicated I'd start on Android before IOS.

Thanks for your offer of help. Good luck with your product. The potential is enormous.