263 lines
6.5 KiB
Markdown
263 lines
6.5 KiB
Markdown
## RASPBERRY PI ALS ZENTRALRECHNER FUER BIENENSTOCKUEBERWACHUNG
|
|
|
|
# Hardware Variante A
|
|
- Raspberry Pi Zero W
|
|
- 3G Stick Huawei E3531
|
|
|
|
|
|
# Hardware Variante B (Kurt Jakob)
|
|
- Raspberry Pi 3 Model B
|
|
- Itead Raspberry Pi GSM/GPRS Board (SIM800)
|
|
- ModMyPi Itead GSM Board Gehäuse
|
|
|
|
|
|
## INSTALLATION
|
|
|
|
Image: 2017-09-07-raspbian-stretch-lite.zip
|
|
|
|
Installation auf SD:
|
|
# unzip -p 2017-09-07-raspbian-stretch-lite.zip |dd of=/dev/sdXXX bs=4M conv=fsync
|
|
|
|
# raspi-config
|
|
- Change User Password: meielis-...
|
|
- Hostname: beielipi
|
|
- locale: en_US.utf8 (auch Default)
|
|
- locale: de_CH.utf8
|
|
- Timezone: Europe/Zurich
|
|
- Change Wifi Country: CH
|
|
- Keyboard: Generic 105-key (Intl), German (Switzerland)
|
|
|
|
# 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"
|
|
}
|
|
|
|
# apt-get update
|
|
# apt-get upgrade
|
|
|
|
Software installieren:
|
|
# apt-get install gammu gammu-smsd 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
|
|
|
|
|
|
### Variante A
|
|
Einrichten GSM:
|
|
|
|
/etc/usb_modeswitch.d/12d1:1f01:
|
|
# Huawei E353 (3.se)
|
|
|
|
DefaultVendor=0x12d1
|
|
DefaultProduct=0x1f01
|
|
TargetVendor=0x12d1
|
|
TargetProduct=0x1f01
|
|
|
|
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
|
|
NoDriverLoading=1
|
|
|
|
|
|
/root/.gammurc:
|
|
; Configuration file generated by gammu-detect.
|
|
; Please check The Gammu Manual for more information.
|
|
|
|
[gammu]
|
|
device = /dev/ttyUSB0
|
|
name = Phone on USB serial port HUAWEI HUAWEI_Mobile
|
|
connection = at
|
|
|
|
[gammu1]
|
|
device = /dev/ttyUSB1
|
|
name = Phone on USB serial port HUAWEI HUAWEI_Mobile
|
|
connection = at
|
|
|
|
[gammu2]
|
|
device = /dev/ttyUSB2
|
|
name = Phone on USB serial port HUAWEI HUAWEI_Mobile
|
|
connection = at
|
|
|
|
|
|
Quick Tutorial Gammu:
|
|
https://wammu.eu/docs/manual/quick/index.html
|
|
|
|
Test SMS-Versand:
|
|
gammu sendsms TEXT 0765006123 -text "Halooo von beielipi"
|
|
|
|
|
|
|
|
### Variante B
|
|
|
|
Wie Raspberry Zero, jedoch folgende Besonderheiten:
|
|
|
|
# systemctl disable hciuart.service
|
|
|
|
root@beielipi:/etc/cron.d# more gsm_poweron
|
|
@reboot root /usr/local/bin/gsm_poweron.py
|
|
|
|
|
|
root@beielipi:~# cat /usr/local/bin/gsm_poweron.py
|
|
#!/usr/bin/python
|
|
#
|
|
# GSM-Modul anschalten, falls ein keine Antwort gibt...
|
|
#
|
|
import time
|
|
import RPi.GPIO as GPIO
|
|
import serial
|
|
|
|
def PowerOn():
|
|
# RPi.GPIO Layout verwenden (wie Pin-Nummern)
|
|
GPIO.setmode(GPIO.BOARD)
|
|
|
|
# Pin 11 (GPIO 17) auf Output setzen
|
|
GPIO.setup(11, GPIO.OUT)
|
|
|
|
# Druecken simulieren
|
|
GPIO.output(11, GPIO.HIGH)
|
|
|
|
# Pause, mindestens eine Sekunde gemaess https://www.itead.cc/wiki/RPI_SIM800_GSM/GPRS_ADD-ON_V2.0
|
|
time.sleep(1.5)
|
|
|
|
# Weg vom Taster...
|
|
GPIO.output(11, GPIO.LOW)
|
|
|
|
# Cleanup
|
|
GPIO.cleanup()
|
|
|
|
with serial.Serial('/dev/ttyAMA0', 115200, timeout=2) as ser:
|
|
ser.write(b'AT\n')
|
|
line = ser.readline()
|
|
line = ser.readline()
|
|
print "Feedback: %s" % (line)
|
|
if line.strip() != "OK":
|
|
print "Modem reagiert nicht, evtl. abgeschaltet... wir schalten es ein..."
|
|
PowerOn()
|
|
ser.close() # close port
|
|
===
|
|
|
|
root@beielipi:~# cat /boot/config.txt
|
|
...
|
|
# Wegen GSM Modul
|
|
dtoverlay=pi3-miniuart-bt
|
|
#dtoverlay=pi3-disable-bt
|
|
enable_uart=1
|
|
===
|
|
|
|
root@beielipi:~# cat /boot/cmdline.txt
|
|
dwc_otg.lpm_enable=0 root=PARTUUID=61612258-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
|
|
===
|
|
|
|
|
|
root@beielipi:~# cat /root/.gammurc
|
|
; Diese Konfigurationsdatei wurde von gammu-detect erstellt.
|
|
; Bitte lesen Sie das Gammu-Benutzerhandbuch für weitere Informationen.
|
|
|
|
[gammu]
|
|
device = /dev/ttyAMA0
|
|
name = Telefon an serielle USB-Schnittstelle Silicon_Labs CP2102_USB_to_UART_Bri
|
|
dge_Controller angeschlossen
|
|
connection = at
|
|
pin = 8296
|
|
|
|
===
|
|
|
|
|
|
SMS senden:
|
|
|
|
$ gammu-smsd-inject TEXT 0765006123 -text "Hallo Velo"
|
|
|
|
|
|
|
|
root@beielipi:/tmp# cat /etc/gammu-smsdrc
|
|
# Configuration file for Gammu SMS Daemon
|
|
|
|
# Gammu library configuration, see gammurc(5)
|
|
[gammu]
|
|
# Please configure this!
|
|
port = /dev/ttyAMA0
|
|
connection = at
|
|
# Debugging
|
|
#logformat = textall
|
|
logformat = errorsdate
|
|
pin = 8296
|
|
|
|
# SMSD configuration, see gammu-smsdrc(5)
|
|
[smsd]
|
|
service = files
|
|
#logfile = syslog
|
|
# Increase for debugging information
|
|
debuglevel = 0
|
|
PIN = 8296
|
|
RunOnReceive = /usr/local/bin/run_on_receive.sh
|
|
|
|
# Paths where messages are stored
|
|
inboxpath = /var/spool/gammu/inbox/
|
|
outboxpath = /var/spool/gammu/outbox/
|
|
sentsmspath = /var/spool/gammu/sent/
|
|
errorsmspath = /var/spool/gammu/error/
|
|
===
|
|
|
|
|
|
## Blabla
|
|
|
|
User/Gruppe erstellen:
|
|
# groupadd -g 2000 beieli
|
|
# useradd -m -g beieli beieli -s /bin/bash
|
|
# usermod -a -G gammu beieli
|
|
# usermod -a -G dialout beieli
|
|
|
|
Passwoerter anpassen:
|
|
# passwd pi => meielis-...
|
|
|
|
|
|
|
|
|
|
root@beielipi:~# rpi-update
|
|
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
|
|
*** Performing self-update
|
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
|
Dload Upload Total Spent Left Speed
|
|
100 13403 100 13403 0 0 25182 0 --:--:-- --:--:-- --:--:-- 25193
|
|
*** Relaunching after update
|
|
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
|
|
*** We're running for the first time
|
|
*** Backing up files (this will take a few minutes)
|
|
*** Backing up firmware
|
|
*** Backing up modules 4.9.41+
|
|
#############################################################
|
|
This update bumps to rpi-4.9.y linux tree
|
|
Be aware there could be compatibility issues with some drivers
|
|
Discussion here:
|
|
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=167934
|
|
##############################################################
|
|
*** Downloading specific firmware revision (this will take a few minutes)
|
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
|
Dload Upload Total Spent Left Speed
|
|
100 168 0 168 0 0 25 0 --:--:-- 0:00:06 --:--:-- 35
|
|
100 54.1M 100 54.1M 0 0 989k 0 0:00:56 0:00:56 --:--:-- 1153k
|
|
*** Updating firmware
|
|
*** Updating kernel modules
|
|
*** depmod 4.9.50-v7+
|
|
*** depmod 4.9.50+
|
|
*** Updating VideoCore libraries
|
|
*** Using HardFP libraries
|
|
*** Updating SDK
|
|
*** Running ldconfig
|
|
*** Storing current firmware revision
|
|
*** Deleting downloaded files
|
|
*** Syncing changes to disk
|
|
*** If no errors appeared, your firmware was successfully updated to a31db890da1e5135fe666909d562bdc6113c14d6
|
|
*** A reboot is needed to activate the new firmware
|
|
root@beielipi:~#
|
|
root@beielipi:~# init 6
|
|
Connection to 192.168.0.34 closed by remote host.
|
|
Connection to 192.168.0.34 closed.
|
|
|
|
|