Difference between revisions of "Pi"
(→pi) |
|||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==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/45319/install-newer-node-version-on-pi-3 | |||
http://raspberrypi.stackexchange.com/questions/48056/login-as-root-not-possible | |||
systemctl start mongodb | |||
systemctl enable mongodb | |||
===getting started=== | ===getting started=== | ||
<s> | |||
*get sd formatter https://www.sdcard.org/downloads/formatter_4/eula_windows/index.html | *get sd formatter https://www.sdcard.org/downloads/formatter_4/eula_windows/index.html | ||
*get noobs https://www.raspberrypi.org/downloads/noobs/ | *get noobs https://www.raspberrypi.org/downloads/noobs/ | ||
*run sdformatter | *run sdformatter | ||
*unzip noobs and load files on sdcard | *unzip noobs and load files on sdcard | ||
*connect keyboard and monitor and internet and power up the pi and install raspbian | *connect keyboard and monitor and internet and power up the pi and install raspbian</s> | ||
====setting up python==== | ====setting up python==== | ||
sudo apt-get update | sudo apt-get update | ||
sudo apt-get python-pip | sudo apt-get python-pip | ||
sudo apt-get install python-dev | |||
sudo pip install virtualenv | sudo pip install virtualenv | ||
<s> | |||
create a project directory | create a project directory | ||
cd projdir | cd projdir | ||
virtualenv venv | virtualenv venv | ||
</s> | |||
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=== | ===default=== | ||
user pi | user pi | ||
passwd raspberry | passwd raspberry | ||
===current=== | |||
pi@10.0.1.155 ranj.. | |||
===login loop=== | ===login loop=== | ||
Line 28: | Line 64: | ||
https://www.raspberrypi.org/forums/ucp.php | https://www.raspberrypi.org/forums/ucp.php | ||
==bluetooth 4.0 LE== | ===bluetooth 4.0 LE=== | ||
http://www.ioncannon.net/linux/1570/bluetooth-4-0-le-on-raspberry-pi-with-bluez-5-x/ | http://www.ioncannon.net/linux/1570/bluetooth-4-0-le-on-raspberry-pi-with-bluez-5-x/ | ||
Latest revision as of 12:49, 11 February 2017
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
- get sd formatter https://www.sdcard.org/downloads/formatter_4/eula_windows/index.html
- get noobs https://www.raspberrypi.org/downloads/noobs/
- run sdformatter
- unzip noobs and load files on sdcard
connect keyboard and monitor and internet and power up the pi and install raspbian
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
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
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.
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.