Skip to content

Latest commit

 

History

History
359 lines (235 loc) · 9.42 KB

README.md

File metadata and controls

359 lines (235 loc) · 9.42 KB

#gsv-6ToWAMP

GSV-6CPU Modul to WAMP

This shows how to hook up a Raspberry Pi2 to a WAMP router and display real-time GSV-6CPU readings in a browser, as well as the configuration of the GSV-6CPU from the browser.

What is an GSV6/GSV6-CPU Modul

GSV6/GSV6-CPU is a measurement amplifier from ME-Messsysteme GmbH

project status

released

Dependencies

All Dependencies are included.

Dependencie License
Autobahn MIT License
Bootstrap MIT License
jQuery MIT License
Smoothie MIT License
Moment.js MIT License
Highstock Do you want to use Highcharts/Highstock for a personal or non-profit project? Then you can use Highchcarts/Hightock for free under the Creative Commons Attribution-NonCommercial 3.0 License

How it works

The serial2ws program will open a serial port connection with your RPi or PC. It will communicate over a specific protocol with the GSV-6CPU-module.

Control

The serial2ws program receives and calls procedures via WAMP.

Sense

The GSV-6CPU-module sends sensor values by sending its protocol-data via serial. The data can contain a measure-frame, an answer-frame or a request-frame. The serial2ws receives those frames, parses each frame and then receives or publishes WAMP events to the different WAMP-topics with the payload consisting of the frames.

How to run

You will need to have the following installed on the RPi to run the project:

  • Python or PyPy (used in this installation tutorial)
  • Twisted
  • AutobahnPython
  • PySerial

acivate I2C and serial port

sudo raspi-config

Go to interfacing options and enable SSH, I2C and Serial.

sudo reboot now

Install

sudo apt-get update
sudo apt-get -y dist-upgrade

Install usbmount, for automount usb-store

sudo apt-get install usbmount

Change usbmount config

sudo nano /etc/usbmount/usbmount.conf

Goto FS_MOUNTOPTIONS="" and change it to

FS_MOUNTOPTIONS="-fstype=vfat,gid=users,dmask=0007,fmask=0117"
Ctrl + O
Ctrl + X
sudo reboot

Checkout from github

cd ~/
git clone https://github.com/flashbac/gsv-6ToWAMP.git

Crossbar.io (WAMP-Router)

sudo apt-get install -y build-essential libssl-dev libffi-dev python-dev libsnappy-dev
sudo pip3 install -U cryptography
sudo pip3 install crossbar

Reinstall numpy

sudo pip3 uninstall numpy
sudo pip3 install numpy

Test crossbar

crossbar version
crossbar upgrade --cbdir /home/pi/gsv-6ToWAMP/.crossbar

twisted

pip install twisted

Autobahn Framework

pip install autobahn

service_identity

pip install service_identity	

Set timezone

cd ~/
echo "TZ='Europe/Berlin';" >> ~/.profile
echo "export TZ" >> ~/.profile
source ~/.profile

Create folder for csv-& log-files

mkdir ~/gsv-6ToWAMP/messungen/
mkdir ~/gsv-6ToWAMP/logs/

Stop and disable ttyS0.service

sudo systemctl stop serial-getty@ttyS0.service
sudo systemctl disable serial-getty@ttyS0.service

Edit /boot/cmdline.txt

sudo nano /boot/cmdline.txt

remove: console=serial0,115200b add behind console=tty1: core_freq=250

Ctrl + O
Ctrl + X

Edit /boot/config.txt

sudo nano /boot/config.txt

add on the bottom

dtoverlay=pi3-miniuart-bt
enable_uart=1
force_turbo=1

Ctrl + O
Ctrl + X

sudo reboot

Run crossbar server and the serial2ws.py script

/usr/bin/python3 /usr/local/bin/crossbar start --cbdir /home/pi/gsv-6ToWAMP/.crossbar
cd ~/gsv-6ToWAMP
/usr/bin/python serial2ws.py --baud=230400 --port=/dev/ttyAMA0
goto http://<ip>:8000

Start crossbar and serial2ws at systemstart

Copy the crossbar-(start)-script and the serial2ws-(start)-script from scripts-folder to /etc/init.d/

cd ~/gsv-6ToWAMP/scripts
sudo cp crossbar /etc/init.d/
sudo cp serial2ws /etc/init.d/

Make the script runnable and add crossbar to rc.d

sudo chmod +x /etc/init.d/crossbar
sudo chmod +x /etc/init.d/serial2ws

from now on, you can start and stop crossbar and serial2ws via the deamon

sudo /etc/init.d/crossbar start
sudo /etc/init.d/crossbar stop

sudo /etc/init.d/serial2ws start
sudo /etc/init.d/serial2ws stop

autostart for crossbar and serial2ws I use the rc.local for them. open /etc/rc.local

sudo nano /etc/rc.local

edit like this

service networking restart

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/etc/init.d/crossbar start
/etc/init.d/serial2ws start

Ehternet configuration (OPTIONAL)

if you have no connection (cabel) at eth0, it is better to disable dhcp on eth0. It will be speedup your systemstart und avoid some network glitches. set up your desired network options in /etc/network/interfaces

iface eth0 inet static
  address 192.168.2.10
  netmask 255.255.255.0

optinal and a gateway

  gateway 192.168.2.1

or disable eth0 at all with follwing line in /etc/network/interfaces

iface eth0 inet manual

Establish the RPi as a Wifi Accespoint with hostapd Source

Verify that your wifi-adapter is on the compatible list and make sure, that you are connected via eth0 (by cable)

sudo apt-get install firmware-ralink hostapd wireless-tools dnsmasq iw

But be careful that your adapter is compatible with hostapd. Previously I use an EW-7811Un with Realtek RTL8188CUS Chipset and this one will not work out of the box with hostapd. For the Raspberry Pi you can use a pachted binary from the binary folder or build a patched Version Now I using an Adapter with Ralink RT5370 chipset. This Adapter is compatible to hostapd and works with the default hostapd driver (nl80211). If you have also an compatible adapter too, you can skip the next steps and go further to the dns configuration.

Use pre-compiled patched hostapd from Binary-Folder

Copy hostapd-binary from git-binary Folder

cd /usr/sbin
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo cp gsv-6ToWAMP/binary/hostapd hostapd
sudo chown root:root hostapd
sudo chmod 755 hostapd

Build hostapd-rtl8188 (patched Version)

First of all you have to clone the repo

cd ~
git clone https://github.com/lostincynicism/hostapd-rtl8188

then install dependencies

sudo apt-get install libnl-3-dev libnl-genl-3-dev

build hostapd-rtl8188

cd hostapd-rtl8188/hostapd
make

copy hostapd-binary

cd /usr/sbin
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo cp hostapd-rtl8188/hostapd/hostapd hostapd
sudo chown root:root hostapd
sudo chmod 755 hostapd

Configuration of the Accespoint

Configure DHCP-Server for wireless-interface

create a backup from the orginal dnsmasq-config-file

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

Open dnsmasq-config-File with the following command

sudo nano /etc/dnsmasq.conf

Configure DHCP. Edit the file /etc/dnsmasq.conf and configure it like this

interface=wlan0
no-dhcp-interface=eth0
dhcp-range=interface:wlan0,192.168.9.2,192.168.9.30,infinite

save dnsmasq.conf changes and exit nano with

Ctrl + O
Ctrl + X

Configure wireless-interface

You will need to give the Pi a static IP address on the wireless interface with the following command

sudo ifconfig wlan0 192.168.9.1

To automatically set this up on boot, edit the file /etc/network/interfaces, open it by typing the following command

sudo nano /etc/network/interfaces

and replace the line "iface wlan0 inet dhcp" to (If the line "iface wlan0 inet dhcp" is not present, add the above lines to the bottom of the file.)

iface wlan0 inet static
  address 192.168.9.1
  netmask 255.255.255.0
  broadcast 192.168.9.255

Change the lines (they probably will not all be next to each other)

allow-hotplug wlan0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet dhcp

to

#allow-hotplug wlan0
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface wlan0 inet manual

and add one the file end follwing lines:

# restart hostapd and dnsmasq
	up service hostapd restart
	up service dnsmasq restart

Configure hostapd

Configure HostAPD. Create a WPA-secured network. To create a WPA-secured network, open the file hostapd.conf

sudo nano /etc/hostapd/hostapd.conf

and add the following lines and change the ssid-, channel- and wpa_passphrase-line to values of your choice. It seems to be necessary that the passphrase starts with a capital letter.

interface=wlan0
driver=nl80211
ssid=ME_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=My_Passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

open /etc/default/hostapd

sudo nano /etc/default/hostapd

and change

#DAEMON_CONF=""

to

DAEMON_CONF="/etc/hostapd/hostapd.conf"

exit with

Ctrl + O
Ctrl + X

Now run the following commands to start the access point

service networking restart

Your Pi should now be hosting a wireless hotspot. Test it.

last step reboot

sudo reboot

sometimes after reboot (and hostapd start) the pi doesnt assigne a IP address to wlan0. You can solve it by chage file /etc/default/ifplugd and change it like this Source:

sudo nano /etc/default/ifplugd

and change to

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"