Skip to content

Santak IPV-2012C UPS, DS18B20 one-wire temperature, ZTE MF823 hostless modem + A5-V11 (MiFi) router and U-blox7 USB GPS monitoring with Grafana and Python on a Raspberry Pi 2 inside a motorhome



Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Santak IPV-2012C UPS, DS18B20 one-wire temperature, ZTE MF823 hostless modem + A5-V11 (MiFi) router and U-blox7 USB GPS monitoring with Grafana and Python on a Raspberry Pi 2 inside a motorhome.


I've built InfluxDB and Grafanates thanks to a number of existing guides.

# install InfluxDB
sudo dpkg -i influxdb_0.13.0~209dd00_armhf.deb
sudo service influxdb start
sudo update-rc.d influxdb defaults 95 10

Install pre-built Node.js for Raspberry Pi using the handy Adafruit guide.

# install Grafana
sudo dpkg -i grafana_3.0.2-1463058303_armhf.deb
sudo service grafana-server start
sudo update-rc.d grafana-server defaults 95 10


This repository contains configuration specific to my environment, with five DS18B20 sensors in total. To personalise it:

  1. run pip install -r requirement.txt
  2. update DS18B201 sensor list and database name in
  3. create database (e.g. grafana) for your metrics by running influx -execute 'CREATE DATABASE grafana;'
  4. optionally create retention policy otherwise default (store forever) RP applies

Temperature Dashboard

temperature dashboard

  1. add w1_therm.conf to /etc/supervisor/conf.d/ and reload supervisor process
  2. go to http://localhost:3000, add a new datasource and configure other options
  3. import temp.json dashboard and modify it to suit your needs or build your own from scratch (change URLs to suit your environment)

UPS/Inverter Dashboard

power dashboard

  1. ensure Network UPS Tools is correctly configured to work with the UPS (use blazer_ser driver)
  2. edit and adjust the default upsname (mine is upsoem) or pass from the command line using --ups parameter
  3. add ups.conf to /etc/supervisor/conf.d/ and reload supervisor process
  4. import ups.json dashboard and modify it to suit your needs or build your own from scratch (change URLs to suit your environment)

It may be nesessary to modify UDEV rules and change the default dialout group assigned by kernel to the USB serial device to nut as follows:

printf "KERNEL==\"ttyUSB0\", GROUP=\"nut\"\n" > /etc/udev/rules.d/99_nut-serialups.rules 

Traffic Dashboard

  1. install sflowtool using this or this guide
  2. add traffic.conf to /etc/supervisor/conf.d/ and reload supervisor process
  3. import traffic.json dashboard and modify it to suit your needs or build your own from scratch

Mobile Broadband Dashboard

mobile dashboard

  1. update host variable in to match your ZTE MF823 modem IP address
  2. add mobilebroadband.conf to /etc/supervisor/conf.d/, change DNS details and reload supervisor process
  3. install nginx or Caddyserver and configure it as a reverse proxy for both Grafana and ZTE web GUIs (the later is required to set the Referer header)
  4. import mobilebroadband.json dashboard and modify it to suit your needs or build your own from scratch (change URLs to suit your environment)
pi@localhost ~ $ cat /etc/nginx/sites-enabled/grafana
server {

	listen 80;
	server_name <your_host_name>;

	location / {
		proxy_pass http://localhost:3000/;

	location /public/ {
		alias /usr/share/grafana/public/;

	location /goform/ {
		proxy_set_header Referer http://<your_ZTE-MF823_modem_IP>/;
		proxy_pass http://<your_ZTE-MF823_modem_IP>:80/goform/;

The ZTE MF823 has a REST API apart from the web GUI, which we are using to communicate with the modem from within the Grafana dashboard. The full list of commands isn't published, but looking at the modem's web interface with Chrome Developer Tools, the following commands were evident.

# connect mobile network (HTTP GET)

# disconnect mobile network (HTTP GET)

# modem state (HTTP GET)

# ConnectionMode (dial mode auto|manual)

# enable roaming

# disable roaming

# enable auto-dial

# disable auto-dial

# upgrade_result

# current_upgrade_state

# sms_data_total

# sms_capacity_info

# sms_parameter_info

# pbm_init_flag

# pbm_capacity_info&pbm_location=pbm_sim

# mem__data_total

# m_ssid_enable

# pbm_capacity_info&pbm_location=pbm_native

# sim_imsi

# wifi_coverage

# current_network_mode

# APN_config0

# lan_ipaddr

# DMZEnable

# PortMapEnable

# IPPortFilterEnable

All the API requests require the Referer: http://<your_ZTE-MF823_modem_IP>/ request header present. No additional headers are required.

Satellite Internet Dashboard

mobile dashboard

  1. update host variable in to match the Newtec S3P (NTC2252) modem ipaddr
  2. add satinternet.conf to /etc/supervisor/conf.d/ and reload supervisor process
  3. install nginx or Caddyserver and configure it as a reverse proxy for Newtec Sat3Play web GUI
  4. import satinternet.json dashboard and modify it to suit your needs or build your own from scratch (change URLs to suit your environment)

GPS Dashboard

GPS dashboard

  1. install gpsd (docs) using this or this guide or better still, install latest from source.
  2. add geo.conf to /etc/supervisor/conf.d/ and reload supervisor process
  3. import gps.json dashboard and modify it to suit your needs or build your own from scratch

To synchronise time using GPS receiver and NTP using SHared Memory driver (type 28), read the following concise article Connecting u-blox NEO-6M GPS to Raspberry Pi. I had a lot of problems with the GPSd v3.06 in the Raspbian Wheezy repository, so I upgraded to Jessie, built GPSd v3.16 from source and installed systemd services. The /etc/default/gpsd file looks like this:

# Default settings for gpsd.

Usign type 28 (SHM), ntp.conf looks like this:

# using SHaredMemory (SHM) driver
server minpoll 4 maxpoll 4 iburst prefer
fudge time1 +0.080 flag1 1 refid GPSD stratum 1

I've also tried using driver type 20 for NTP, however I couldn't get NTP and GPSD to play together nicely in the mode, so I reverted to SHM. With type 20 ntp.conf looks like this:

# GPS receiver time source via /dev/gsp0, no SHaredMemory (SHM) driver
server mode 16 minpoll 4 maxpoll 4 prefer # set /dev/gps0 9600 baud
fudge flag1 0 # disable PPS as it isn't present with cheap USB GPS(s)

The /etc/udev/rules.d/99-gpsd.rules makes sure the device has the right permissions and the symbolic link persists on restart:

KERNEL=="ttyACM[0-9]*", GROUP="dialout", MODE="0666"
KERNEL=="ttyACM0", SYMLINK+="gps0"

To reload udev rules without rebooting, run sudo udevadm control --reload-rules.

Checking time sync. results:

# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
*SHM(0)          .GPSD.           1 l    3   16  377    0.000   -1.577   1.830

My time seems to be off by about 80ms, which I correct with time1 +0.080 option. The resulting accuracy means the clock is off by less than +/- 10ms, which is good enough for my purposes of keeping the time roughly in sync with the world.

# ntpdate -d
delay 0.07957, dispersion 0.00102
offset -0.004779

19 May 10:23:48 ntpdate[2993]: adjust time server offset -0.004779 sec

To set initial datetime from GSP, add the following to /etc/rc.local to run once per boot:

# set initial datetime from GPS
influx -database beastcraft \
  --format csv \
  -execute 'SELECT last("value") FROM "time";' | \
  tail -1 | awk -F',' '{print $3}' | \
  xargs date +%Y-%m-%dT%H:%M:%S.000Z -s

FortiWifi Interface Monitor

A FortiWifi firewall can be configured as a wireless bridge as follows[n1]:

config system global
    set wireless-mode client

A side effect of doing this, is that the resulting wifi internal interface is always up, regardless of whether or not it is connected to the upstream wireless network. This means that if a backup interface is to be used (e.g. Mobile Broadband), the wifi interface default route will never be released and the backup one will never kick in. A less elegant solution is to use FortiOS link-monitor function in conjunction with a custom script running somewhere nearby to manipulate network routes depending on interface availability.

For example, if a wifi interface is used as a primary network link and a wan2 interface is used for backup, the following link-monitor configuration is set on the device:

config system link-monitor
    edit "wan2"
        set srcintf "wan2"
        set server "" ""
    edit "wifi"
        set srcintf "wifi"
        set server "" ""

Status check is performed for running diag sys link-monitor status wifi command and inspecting the output:

Link Monitor: wifi Status: alive Create time: Fri Mar 18 14:55:41 2016
Source interface: wifi (18)
Interval: 5, Timeout 1
Fail times: 0/5
Send times: 0
        Source IP(
        Route:>, gwy(
    protocol: ping, state: alive
              Latency(recent/average): 20.55/23.82 ms Jitter: 267.41
              Recovery times(0/5)
              Continuous sending times after the first recovery time 0
              Packet sent: 172173  Packet received: 167884
        Source IP(
        Route:>, gwy(
    protocol: ping, state: alive
              Latency(recent/average): 20.41/29.20 ms Jitter: 266.55
              Recovery times(1/5)
              Continuous sending times after the first recovery time 1
              Packet sent: 172161  Packet received: 169386

To automate this, I've written a simple Python script, which can be run on a nearby Linux host, to poll the firewall every few seconds and check the interface status. Should the primary interface go down, the script modifies the default route to send traffic to the backup interface:

usage: [-h] --host HOST [--port PORT] [--user USER] --iface IFACE
                  --backup BACKUP --gwip GWIP

FortiGate interface monitor

optional arguments:
  -h, --help       show this help message and exit
  --host HOST      FortiGate appliance hostname or IP
  --port PORT      SSH port of the FortiGate appliance
  --user USER      FortiGate admin username
  --iface IFACE    FortiGate interface to monitor (e.g. wifi)
  --backup BACKUP  FortiGate interface to fail-over to (e.g. wan2)
  --gwip GWIP      Backup interface gateway ipaddr



[n1] FortiWifi Client mode (wireless bridge)


Santak IPV-2012C UPS, DS18B20 one-wire temperature, ZTE MF823 hostless modem + A5-V11 (MiFi) router and U-blox7 USB GPS monitoring with Grafana and Python on a Raspberry Pi 2 inside a motorhome







No releases published


No packages published