beielipi/REAME.md

3.9 KiB

RASPBERRY PI ALS ZENTRALRECHNER FUER BIENENSTOCKUEBERWACHUNG

Hardware

  • Raspberry Pi Zero W
  • 3G/4G Stick Huawei E3533

INSTALLATION

Grundinstallation

Image: 2018-04-18-raspbian-stretch-lite.zip von https://www.raspberrypi.org/downloads/raspbian/

Installation auf SD:
# unzip -p 2018-04-18-raspbian-stretch-lite.zip |dd of=/dev/sdXXX bs=4M conv=fsync

# raspi-config
- Change User Password: meielis-b...
- Hostname: beielipi
- enable predicatble network interface names
- locale: en_US.utf8 (auch Default)
- locale: de_CH.utf8
- Timezone: Europe/Zurich
- Change Wifi Country: CH
- Keyboard: Generic 105-key (Intl), German (Switzerland)
- Enable SSH Server
- WLAN einrichten (siehe "per WLAN")
- reboot

# apt-get update
# apt-get upgrade

Software installieren:
# apt-get install gammu python-gammu
# apt-get install python-serial
# apt-get install python-yaml
# apt-get install minicom
# apt-get install ppp
# apt-get install python-pexpect
# apt-get install hostapd
# apt-get install ntpdate
# apt-get install dnsmasq
# apt-get install python-bottle
# apt-get install python-pip
# apt-get install libglib2.0-dev

# pip install bluepy

Zugang ermöglichen

per WLAN

# cat /etc/wpa_supplicant/wpa_supplicant.conf
country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
  ssid="haerdoepfu27" psk="XXXXXXXXXXXX"
}

Boot Config anpassen

in /boot/config.txt

dtparam=audio=off

Strom sparen

/etc/rc.local einfuegen:
# Disable HDMI to save power
# Joerg Lehmann, 2.4.2018
/usr/bin/tvservice -o

exit 0

Einrichten GSM

/etc/usb_modeswitch.d/12d1:157d:
#Huawei E3533
TargetVendor=0x12d1
TargetProduct=0x1436
MessageContent="55534243123456780000000000000011063000000000010000000000000000"
NoMBIMCheck=1

/etc/usb_modeswitch.conf:
DisableMBIMGlobal=1
SetStorageDelay=8

Workaround fuer USB disconnects:

/etc/cron.d/reset_usb:
#  Reset USB if device names disappear
* * * * * root [ ! -c /dev/ttyUSB0 ] && /usr/local/bin/usb_off_on.sh 2>/dev/null

/usr/local/bin/usb_off_on.sh:
#!/bin/bash
# Joerg
echo "$(date) - ${0} - reset USB because device disappeared" >> /var/log/usb_off_on.log
echo 0 > /sys/devices/platform/soc/20980000.usb/buspower
sleep 5
echo 1 > /sys/devices/platform/soc/20980000.usb/buspower



Quick Tutorial Gammu:
https://wammu.eu/docs/manual/quick/index.html


Folgender Init-String muss gesendet werden (sonst werden die empfangenen SMS nicht abfragbar sein):
AT+CPMS="SM";+CNMI=2,0,0,2,1

Wir fuegen den String in /etc/chatscripts/gprs ein:

# +CPIN provides the SIM card PIN
#OK		"AT+CPIN=1234"

# Einstellungen wegen SMS-Empfang
OK              AT+CPMS="SM";+CNMI=2,0,0,2,1

Test SMS-Versand:

gammu sendsms TEXT 0765006123 -text "Halooo von beielipi"

Installation Applikation

User/Gruppe erstellen:
# groupadd -g 2000 beieli
# useradd -m -g beieli beieli -s /bin/bash
# usermod -a -G dialout beieli

Passwoerter anpassen:
# passwd pi    => meielis-...

# Aus Git uebernehmen:
(auf anderem Rechner):
$ git clone https://git.nbit.ch/joerg/beielipi.git
$ cd beielipi
$ tar cvf /var/tmp/beielipi-git-files.tar .

# cd /home/beieli && tar xvf /var/tmp/beielipi-git-files.tar
# rm -rf /home/beieli/.git
# chown -R beieli:beieli /home/beieli
# chown -R root:root /home/beieli/root-bin
# chown -R root:root /home/beieli/web-root
# su - beieli
beieli@beielipi:~ $ mkdir config_backups data send_sms_queue tmp web-csv
beieli@beielipi:~ $ exit 
# cd /home/beieli/install-files
# for i in $(find . -type f); do echo cp $i /$i ; done
# for i in $(find . -type f); do cp $i /$i ; done

# systemctl enable beielimon
# systemctl enable btmon
# systemctl enable smsmon
# systemctl disable hostapd
# systemctl disable fakedns
# systemctl disable dnsmasq


/etc/fstab anpassen:
tmpfs /home/beieli/bt-readings tmpfs nodev,nosuid,uid=1001,gid=2000,size=4M 0 0

# mkdir /home/beieli/bt-readings

Reboot:
# init 6