2023-01-19

Using rootful podman-compose on Centos9

In the last weeks I updated my home server from Centos8 to Centos 9 stream. As part of this I also switched from docker to podman. This was no problem for single container but in case of multiple container working together - aka are composed - it wont work as expected. 

E.g in a setup of two container in a pod - app and db - the app can't resolve (and reach) the db. 

After multiple trial and error setups, crawling, reading through the web - filter out obsolete tips etc. I switch to "netavark" - (see https://github.com/containers/podman-compose/issues/455), be aware that the mentioned command podman system reset --force will remove all volumes (Yes, I did have a backup.)

In the end - all does not help ... I was about to give up. But then I found a hint how to look in the dns config of the container:

$ more /run/containers/networks/aardvark-dns/gogs_default
10.89.0.1
9951847ba473d97b6bf1e834b490 10.89.0.4 gogs_db,db,9951847ba473
6b06aee614d7584d32f3912e3b2c 10.89.0.5 gogs_app,app,6b06aee614d7

Ok, this mean the aardvark-dns is configured right. Next I look in the logs:

$ journalctl -t aardvark-dns
21:06:57 s...de aardvark-dns[1998]: Received SIGHUP will refresh servers: 1
21:06:57 s...de aardvark-dns[1998]: Unable to start server unable to start CoreDns server: \
                                    Address already in use (os error 98)
Looks like the aardvark-dns is in conflict with my name server runing on the same maschine.
$ ps 1998
 PID TIME COMMAND
1998 0:00 /usr/libexec/podman/aardvark-dns --config /run/containers/networks/aardvark-dns -p 53 run
Interesting - it is running on port 53 - like bind.

Finally I found out how to configure the port aardvark is using: it is a further entry in the file where I already switch to netavark.

$ more /etc/containers/containers.conf
[network]

# Explicitly use netavark. 
# See https://github.com/containers/podman-compose/issues/455
network_backend = "netavark"

dns_bind_port = 5533
Restart ... it runs.

2021-10-17

Update: Display TTN-Gateway status

After migrating my TTN gateway to the new The Things Stack Community Edition (see previous blog post) my script to display the gateway status stopped working. The reason behind was, that the new stack does not provide the noc api which was used in the script.

After searching in the TTN forum I found the thread New API for gateway mapping, status and info. Using this API I just need to change one line in my script and now it works again.

-  cmd = "curl -s http://noc.thethingsnetwork.org:8085/api/v2/gateways/eui-b827ebfffe06902a | jq -r '.timestamp'"
+  cmd = "curl -s https://mapper.packetbroker.net/api/v2/gateways/netID=000013,tenantID=ttn,id=eui-b827ebfffe06902a | jq -r '.updatedAt'"
The updated script is available in the github repo.

Migrate TTN-Gateway to The Things Stack Community Edition (aka V3)

 I just migrate my TTN-gateway to the new The Things Stack Community Edition (aka V3). 

I followed the instructions I found in the thread on GitHub.

  1. Create a new gateway on the things network (link)
  2. Change the server url in your local_conf.json to eu1.cloud.thethings.network
  3. Restart the gateway
Unfortunately the new stack does not provide a NOC api - so my script to output the gateway status to a OLED stop working. I will invest into this next.

2020-10-12

Photovoltaic dashboard with Grafana

I have a SolarEdge Inverter which is monitored by a energy meter (SolarEdge SE-MTR-3Y-400V-A). The energy meter gets measurements from the inverter and measures voltage and current at the house entry point.



SolarEdge provide a monitoring service and a mobile app to monitor the system. An example is shown here:


To be able to monitor and evaluate the measurements by myself I use the following applications:
  • mbmd - to read the measurements from the inverter and energy meter
  • nodered - to calculate some derived values 
  • mqtt - to "transport" the measurements between the apps
  • telegraf - to write the measurements into influxdb
  • influxdb - to store the measurements
  • grafana - to display the measurements



The result looks like this (a snapshot is available here):



Configuration 

mbmd

The mbmd reads the measurements from the inverter and (via the inverter) from the energy meter.
pi@racknode:/etc $ more mbmd.yaml
# REST api, use 127.0.0.1 to restrict to localhost
api: 0.0.0.0:8080

# mqtt config
mqtt:
  broker: my.mqtt.server:1883
  topic: mbmd
#  user:
#  password:
  clientid: mbmd
  qos: 0
  homie: ""
  # homie: homie


# adapters are referenced by device
adapters:
- device: inverter.ip.addr:1502

# list of devices
devices:
- name: inverter
  type: SE
  id: 1
  subdevice: 0 # use subdevice to access SunSpec subdevices
- name: powermeter
  type: SE
  id: 1
  subdevice: 1 # use subdevice to access SunSpec subdevices

Node-Red

To calculate the "self consumption" and split the measured power in Import/Export I create a Node-Red flow:


Here is the corresponding flow code.

Telegraf

The telegraf is configured to transfer the mqtt messages to the influxdb. 

The config is available here.

Grafana



A snapshot of the dashboard is available here and also the dashboard.json is available.


2020-10-03

HP MFP M754DN Fix "Scan to Network" error

My multifunction printer HP MFP M754DN has the ability to scan to a network folder. The target folder is provided by a samba server running CentOS8. It works with out problem but stops to be able to access the network folder some weeks ago. 

Testing the connection on the webgui results in the message: "Cannot connect to the network folder. Ensure the shared folder name is correct."


To fix it I have added the following lines in the smb.conf file on the samba server.
server min protocol = NT1    
min protocol = NT1
A further analysis of my last update activities showed that this was related to the update of the samba package from samba-4.10.4-101.el8_1.x86_64 to samba-4.11.2-13.el8.x86_64. 
According to Samba 4.11 WhatsNew the "SMB1 is disabled by default" now - and the HP printer unfortunately uses only SMB1. With the mentioned settings you enabled the SMB1 protocol again.

2020-04-19

A 3d printable case for a ZigBee Gateway

I create a 3D model of a case for the ZigBee board.

 

In the cap is a cutout to place a neodymium magnet.


STL files are uploaded to my Thingivers account (link).

2020-03-20

Using Cucumber with Gradle with tags

I want to run Cucumber from Gradle with the possibility to specify tags. Here is a build.gradle to do this:


  • gradle cucumber - will run all cucumber scenarios but not these tagged with @Ignore
  • gradle cucumber -P tags=@Smoketest - will run all smoketests but again will ignore these with the tag @Ignore.

2020-01-03

TTN-Gateway in a box

During the last days I worked on the installation of my TTN-Gateway into a case. This is the result:






Beside the LoraWAN hardware I have installed an OLED display and 3 sensors (1x Si7021, 2x DS18B20). The OLED display is connected via I2C, the sensors via 1-wire and I2C.

The sensor data is read by Python3 Script and published with MQTT. The OLED is also controlled by a Python3 script. Both scripts run as systemd-service.

The software is available on github.

Little helper: mwc = more-without-comment

While configuring my linux nodes I found my alias mwc very helpful:

I used it to show the relevant (= uncommented and non-empty) lines in typical linux config files.

2019-12-29

Raspi + RAK831 + converter board - make standard i2c bus available

The RAK831 converter board connects the standard i2c pins of the Raspi with the RAK831 board (RASPI.PIN3 -> RAK.PIN7, RASPI.PIN5 -> RAK.PIN9) (see picture). The RAK831 documentation states the line(s ?) are used to enable the RFSW1012 (see page 15) but does not uses it as i2c bus. The consequence is that the standard i2c bus cannot be used.



On the other hand when looking how to connect the RAK831 direct with a Raspi (e.g. here) the RAK pins 7 and 9 are not used.

This means the i2c bus can be revitalize by removing the 0R bridges R11 and R6 on the converter board.






2019-12-11

Updated inadyn-mt package for CentOS 8

I have updated my inadyn-mt rpm/srpm package for CentOS 8. It is based on inadyn-mt v02.28.10.
I follow again the steps I described here, but started with the current source rpm inadyn-mt-2.28.10-4.fc31.src.rpm

2019-12-03

Setting up a Zigbee2mqtt gateway

Here are the steps I performed to setup a Zigbee2mqtt gateway using a CC2530+CC2591 board and a RaspberryPI 3.
  • My RaspberryPI 3 is running
    pi@racknode:~ $ uname -a
    Linux racknode 4.19.42-v7+ #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux
    pi@racknode:~ $ hostnamectl
       Static hostname: racknode
             Icon name: computer
            Machine ID: confidential
               Boot ID: confidential
      Operating System: Raspbian GNU/Linux 9 (stretch)
                Kernel: Linux 4.19.42-v7+
          Architecture: arm
  • My Zigbee board:


The steps can be structured in three groups:

  1. Flash the Z-Stack coordinator firmware on the Zigbee board
  2. Install zigbee2mqtt to run on the Raspberry Pi
  3. Setup a daemon to run zigbee2mqtt

Flash the Z-Stack coordinator firmware on the Zigbee board

  • Connect the Zigbee board with the Raspberry (Note: this is the connection schema for flashing the firmware, while normal operation another connection schema is used.)

    Name   Raspi     CC2530+CC2591*   
    3,3V/VCC Pin01P12 Pin02
    GND Pin39P12 Pin01
    RESET Pin35P12 Pin03
    DC Pin36P14 Pin04
    DD Pin38P14 Pin05
    *) P12 - 12pin connector, P14 - 14 pin connector




  • Install the wiringPI library
    sudo apt-get install wiringpi
  • Install git
    pi@racknode:~ $ sudo apt-get install git
    
  • Clone the flasher repo
    git clone https://github.com/jmichault/flash_cc2531.git
  • Test the connection
    pi@racknode:~/flash_cc2531 $ ./cc_chipid
      ID = a524.
  • Get the firmware - as mentioned above I need the CC2530+CC2591 version. See https://github.com/Koenkk/Z-Stack-firmware/tree/master/coordinator/Z-Stack_Home_1.2/bin/default for the correct version.
    pi@racknode:~/flash_cc2531 $ wget https://github.com/Koenkk/Z-Stack-firmware/raw/master/
    coordinator/Z-Stack_Home_1.2/bin/default/CC2530_CC2591_DEFAULT_20190608.zip
  • Extract the archive
    pi@racknode:~/flash_cc2531 $ unzip CC2530_CC2591_DEFAULT_20190608.zip
    Archive:  CC2530_CC2591_DEFAULT_20190608.zip
      inflating: CC2530ZNP-Prod.hex
      inflating: CC2530ZNP-Prod.bin
    pi@racknode:~/flash_cc2531 $
  • Erase the CC2531 CC2530
    pi@racknode:~/flash_cc2531 $ ./cc_erase
      ID = a524.
      erase result = 00a6.
    pi@racknode:~/flash_cc2531 $
  • Write the new firmware (takes about 2-3 minutes)
    pi@racknode:~/flash_cc2531 $ ./cc_write CC2530ZNP-Prod.hex
      ID = a524.
      reading line 15490.
      file loaded (15497 lines read).
    writing page 128/128.
    verifying page 128/128.
     flash OK.
    pi@racknode:~/flash_cc2531 $ cd ..
    pi@racknode:~ $

Install zigbee2mqtt to run on the Raspberry Pi

Steps based on
My steps were
  • Connect the Zigbee board with the Raspberry for operation mode

    Name   Raspi     CC2530+CC2591*   
    3,3V/VCCPin01P12 Pin02
    GND Pin39P12 Pin01
    TX (R→Z)Pin08P12 Pin07
    RX (R←Z) Pin10P12 Pin08
    *) P12 - 12pin connector




  • Enable UART and disable UART use for Bluetooth by adding following lines to /boot/config.txt
    pi@racknode:~ $ sudo vi /boot/config.txt
    
    enable_uart=1
    dtoverlay=pi3-disable-bt
    
  • Disable modem system
    sudo systemctl disable hciuart
  • Remove the serial console entry from /boot/cmdline.txt
    Before
    pi@racknode:~ $ cat /boot/cmdline.txt
    dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=...
    
    After
    pi@racknode:~ $ cat /boot/cmdline.txt
    dwc_otg.lpm_enable=0 console=tty1 root=...
    
  • Reboot the Raspberry
  • Installing the node.js 10.0 repo and install node.js
    pi@racknode:~ $ sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
    ... and install node.js
    pi@racknode:~ $ sudo apt-get install -y nodejs
  • Clone the zigbee2mqtt repo
    pi@racknode:~ $ sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
    ... and change own to pi
    pi@racknode:~ $ sudo chown -R pi:pi /opt/zigbee2mqtt
  • Install the dependencies
    pi@racknode:~ $ cd /opt/zigbee2mqtt
    pi@racknode:/opt/zigbee2mqtt $ npm ci
    prebuild-install WARN install No prebuilt binaries found (target=10.17.0 runtime=node arch=arm libc= platform=linux) make: Entering directory '/opt/zigbee2mqtt/node_modules/zigbee-herdsman/ node_modules/@serialport/bindings/build' CXX(target) Release/obj.target/bindings/src/serialport.o CXX(target) Release/obj.target/bindings/src/serialport_unix.o CXX(target) Release/obj.target/bindings/src/poller.o CXX(target) Release/obj.target/bindings/src/serialport_linux.o SOLINK_MODULE(target) Release/obj.target/bindings.node COPY Release/bindings.node make: Leaving directory '/opt/zigbee2mqtt/node_modules/zigbee-herdsman/ node_modules/@serialport/bindings/build' > serialport@8.0.1 postinstall /opt/zigbee2mqtt/node_modules/zigbee-herdsman/ node_modules/serialport > node thank-you.js Thank you for using serialport! If you rely on this package, please consider supporting our open collective: > https://opencollective.com/serialport/donate npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/ zigbee-herdsman/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/ fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"}) added 1356 packages from 856 contributors and audited 877179 packages in 220.282s found 3 high severity vulnerabilities run `npm audit fix` to fix them, or `npm audit` for details
  • Fix the mentioned issues
    pi@racknode:/opt/zigbee2mqtt $ npm audit fix
    npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || ↵
    >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but ↵
    none is installed. You must install peer dependencies yourself.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/↵
    zigbee-herdsman/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: ↵
    wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: ↵
    wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
    
    updated 2 packages in 52.752s
    fixed 3 of 3 vulnerabilities in 877319 scanned packages
    pi@racknode:/opt/zigbee2mqtt $
    
  • Enter your configuration in /opt/zigbee2mqtt/data/configuration.yaml
    vi data/configuration.yaml
    Enter your settings 
    # MQTT settings
    mqtt:
      # MQTT base topic for zigbee2mqtt MQTT messages
      base_topic: zigbee2mqtt
      # MQTT server URL
      server: 'mqtt://localhost'
      # MQTT server authentication, uncomment if required:
      # user: my_user
      # password: my_password
    # CC2590 is connected to serial line
    serial:
      port: /dev/ttyAMA0
    advanced:
      baudrate: 115200
      rtscts: false 
    
  • Start zigbee2mqtt
    pi@racknode:/opt/zigbee2mqtt $ npm start
    
    > zigbee2mqtt@1.7.1 start /opt/zigbee2mqtt
    > node index.js
    
    Logging to directory: '/opt/zigbee2mqtt/data/log/2019-11-30.16-53-43'
    Starting zigbee2mqtt version 1.7.1 (commit #b459c35)
    Starting zigbee-herdsman...
    zigbee-herdsman started
    Coordinator firmware version: '{"type":"zStack12","meta":{"transportrev":2,↵
    "product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}}'
    Currently 0 devices are joined:
    `permit_join` set to  `true` in configuration.yaml.
    Allowing new devices to join.
    Set `permit_join` to `false` once you joined all devices.
    Zigbee: allowing new devices to join.
    Connecting to MQTT server at mqtt://xxx.xxx.xxx
    Connected to MQTT server
    MQTT publish: topic 'zigbee/bridge/state', payload 'online'
    MQTT publish: topic 'zigbee/bridge/config', payload '{"version":"1.7.1",↵
    "commit":"b459c35","coordinator":{"type":"zStack12","meta":{"transportrev":2,↵
    "product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}},↵
    "log_level":"info","permit_join":true}'

Setup a daemon to run zigbee2mqtt

based on zigbee2mqtt - 5. (Optional) Running as a daemon with systemctl
  • Create a zigbee2mqtt service
    sudo vi /etc/systemd/system/zigbee2mqtt.service
    enter
    [Unit]
    Description=zigbee2mqtt
    After=network.target
    
    [Service]
    ExecStart=/usr/bin/npm start
    WorkingDirectory=/opt/zigbee2mqtt
    StandardOutput=inherit
    StandardError=inherit
    Restart=always
    User=pi
    
    [Install]
    WantedBy=multi-user.target
    
  • Verify that it works
    pi@racknode:/opt/zigbee2mqtt $ sudo systemctl start zigbee2mqtt
    pi@racknode:/opt/zigbee2mqtt $ sudo systemctl status zigbee2mqtt
    ● zigbee2mqtt.service - zigbee2mqtt
       Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; disabled; ↵
       vendor preset: enabled)
  •    Active: active (running) since Tue 2019-12-03 08:35:46 CET; 7s ago
     Main PID: 626 (npm)
        Tasks: 23 (limit: 4915)
       CGroup: /system.slice/zigbee2mqtt.service
               ├─626 npm
               ├─643 sh -c node index.js
               └─644 node index.js
    
    Dec 03 08:35:46 racknode systemd[1]: Started zigbee2mqtt.
    Dec 03 08:35:50 racknode npm[626]: > zigbee2mqtt@1.7.1 start /opt/zigbee2mqtt
    Dec 03 08:35:50 racknode npm[626]: > node index.js
    Dec 03 08:35:53 racknode npm[626]: [..] Logging to directory: '/opt/zigb
    Dec 03 08:35:53 racknode npm[626]: [..] Starting zigbee2mqtt version 1.7
    Dec 03 08:35:53 racknode npm[626]: [..] Starting zigbee-herdsman...
  • Configure the autostart of the service
    pi@racknode:/opt/zigbee2mqtt $ sudo systemctl enable zigbee2mqtt.service
    Created symlink /etc/systemd/system/multi-user.target.wants/zigbee2mqtt.service ↵
    → /etc/systemd/system/zigbee2mqtt.service.
  • Reboot the Raspberry to verify your setup
    pi@racknode:/opt/zigbee2mqtt $ sudo reboot
    Connection to racknode closed by remote host.
    Connection to racknode closed.
    
    $ ssh pi@racknode
    Linux racknode 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l
    
    The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    Last login: Tue Dec  3 08:42:26 2019 from 10.0.0.171
    pi@racknode:~ $ sudo journalctl -u zigbee2mqtt.service -f
    -- Logs begin at Thu 2016-11-03 18:16:43 CET. --
    [..] Started zigbee2mqtt.
    [..] > zigbee2mqtt@1.7.1 start /opt/zigbee2mqtt
    [..] > node index.js
    [..] Logging to directory: '/opt/zigbee2mqtt/data/log/2019-12-03.08-44-14'
    [..] Starting zigbee2mqtt version 1.7.1 (commit #b459c35)
    [..] Starting zigbee-herdsman...
    [..] zigbee-herdsman started
    [..] Coordinator firmware version: '{"type":"zStack12","meta":{"transportrev":2,↵
         "product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}}'
    [..] Currently 1 devices are joined:
    [..] 0x00158d00029acb06 (0x00158d00029acb06): MFKZQ01LM - Xiaomi Mi/Aqara smart ↵
         home cube (EndDevice)
    [..] `permit_join` set to  `true` in configuration.yaml.
    [..] Allowing new devices to join.
    [..] Set `permit_join` to `false` once you joined all devices.
    [..] Zigbee: allowing new devices to join.
    [..] Connecting to MQTT server at mqtt://mqtt.thomo.de
    [..] Connected to MQTT server
    [..] MQTT publish: topic 'zigbee/bridge/state', payload 'online'
    [..] MQTT publish: topic 'zigbee/0x00158d00029acb06', payload '{"battery":31,↵
         "voltage":2825,"linkquality":18,"angle":10.55,"side":3}'
    [..] MQTT publish: topic 'zigbee/bridge/config', payload '{"version":"1.7.1",↵
         "commit":"b459c35","coordinator":{"type":"zStack12","meta":{"transportrev":2,↵
         "product":0,"majorrel":2,"minorrel":6,"maintrel":3,"revision":20190608}},↵
         "log_level":"info","permit_join":true}'
    ^C
    pi@racknode:~ $

Links

  • https://www.zigbee2mqtt.io/

Update

2020-02-15: Fix error in flash connection table and picture.

2019-10-08

Setup TTN Gateway using Raspi3 with RAK831 and converter board

Finally I was able to put my TTN Gateway into operation.


The first attempt a few month ago failed and therefore the project was on hold until now. An article in make 03/2019 gave me the impetus for a new attempt.

My essential setup steps:
  1. Put the parts together.
    Caution: Do not power up the RAK831 card without connecting the antenna.
  2. Prepare a SDCard with a Raspberry Image - I use "Raspbian Buster with desktop" (Release date: 2019-09-26, Kernel 4.19)
  3. Perform a general update
    sudo apt-get update && sudo apt-get upgrade
  4. Enable SPI using raspi-config
  5. Clone the ttn gateway repo
    git clone https://github.com/ttn-zh/ic880a-gateway.git
  6. Run the setup script
    cd ic880a-gateway
    sudo ./install.sh
  7. Register the gateway on TTN website
After the restart I check the service status:

pi@ttn-gateway:~ $ systemctl status ttn-gateway
● ttn-gateway.service - The Things Network Gateway
   Loaded: loaded (/lib/systemd/system/ttn-gateway.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2019-10-08 14:05:42 CEST; 779ms ago
  Process: 346 ExecStart=/opt/ttn-gateway/bin/start.sh (code=exited, status=1/FAILURE)
 Main PID: 346 (code=exited, status=1/FAILURE)

ttn-gw ttn-gateway[346]: INFO: Statusstream data is enabled
ttn-gw ttn-gateway[346]: INFO: Beacon is disabled
ttn-gw ttn-gateway[346]: INFO: Monitor is disabled
ttn-gw ttn-gateway[346]: INFO: Contact email configured to "my email"
ttn-gw ttn-gateway[346]: INFO: Description configured to "ttn-rak831"
ttn-gw ttn-gateway[346]: INFO: Successfully contacted server router.eu.thethings.network
ttn-gw ttn-gateway[346]: INFO: [main] Starting the concentrator
ttn-gw ttn-gateway[346]: ERROR: [main] failed to start the concentrator
ttn-gw systemd[1]: ttn-gateway.service: Main process exited, code=exited, status=1/FAILURE
ttn-gw systemd[1]: ttn-gateway.service: Failed with result 'exit-code'.

Damn - the same problem as at first try! :-(

An issue thread on github list some possible reasons, among other "the wiring might be wrong". You may also interpret it as "other then expected or as default" and this was the key. On another page about the setup I found the crucial clue: The converter board uses a different reset pin (it use pin 17 instead of 25).

After changing the corresponding setting in /opt/ttn-gateway/bin/start.sh
#! /bin/bash

# Reset iC880a PIN
# SX1301_RESET_BCM_PIN=25
SX1301_RESET_BCM_PIN=17
echo "$SX1301_RESET_BCM_PIN"  > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$SX1301_RESET_BCM_PIN/direction

... it worked as expected. And I see the status "connected" on the TTN console (on TTN website).

To enable the GPS module I have to:
  1. Disable the serial login shell but keep the serial interface enabled - via raspi-config - interface setup.
  2. add the following lines to /opt/ttn-gateway/bin/local_conf.json
    "gps_tty_path": "/dev/ttyS0",
    "fake_gps": false,
    
  3. Reboot and check if it works (it may take some minutes to fetch the GPS position)
    pi@ttn-gateway:/opt/ttn-gateway/bin $ sudo tail -f /var/log/syslog | grep -i gps
    Oct  8 17:55:36 ...: INFO: GPS serial port path is configured to "/dev/ttyS0"
    Oct  8 17:57:39 ...: INFO: GPS is enabled
    Oct  8 17:57:39 ...: INFO: Using real GPS if available.
    Oct  8 17:57:39 ...: INFO: [main] TTY port /dev/ttyS0 open for GPS synchronization
    Oct  8 17:57:39 ...: INFO: GPS thread activated.
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: WARNING: [gps] GPS out of sync, keeping previous time reference
    Oct  8 17:57:39 ...: ### [GPS] ###
    Oct  8 17:57:39 ...: # Valid gps time reference (age: 0 sec)
    Oct  8 17:57:39 ...: # System GPS coordinates: latitude 50.94322, longitude 7.37443, altitude 272 m
    Oct  8 17:57:39 ...: ### [GPS] ###
    Oct  8 17:57:39 ...: # Valid gps time reference (age: 0 sec)
    Oct  8 17:57:39 ...: # System GPS coordinates: latitude 50.94322, longitude 7.37443, altitude 274 m
    
Used hardware:

Raspi3

The converter board with GPS support

RAK831 module

On the left side: 
top - the TTN antenna
bottom - the GPS module (optional)

Connection of the GPS signal

Update: The wiring of the converter board is available on the RAK website.

2019-07-14

Update: ESP8266 based SensorNode V2

I updated the circuit and pcb design of my Esp based SensorNode.
Further details in the github repository.

ESP Programmer

I put together an adapter board to attach a CP2104 board to ESP8266 and provide auto programming mode.


For further details see the github repository.

2019-04-29

ESP8266 based SensorNode

In last weeks I put together a Sensor-Node based on ESP8266. The software part provides:
  • the standard WiFiMonitor to setup the WiFi credentials
  • a web page to configure the connected sensors
  • a web service to read the configuration and current sensor values
  • the data are published via MQTT in a format to be feed into a influxdb
The following sensors are supported:
  • DS18B20 (multiple)
  • BME280
  • Si7021

SensorNode config page
SensorNode configuration page

I designed a board to be put into a USB port with a temperature and a humidity sensor. 
SensorNode circuit
SensorNodeUSB circuit

SensorNode pcb bottom side
SensorNodeUSB PCB bottom side

SensorNode pcb top side
SensorNodeUSB PCB top side
More information can be found in the GitHub repo SensorNode.




2018-03-25

ESP8266 - Convert from human readable date/time to epoch timestamp in Lua

For my current ESP8266 NodeMCU project I need a Lua function to convert the date/time returned by the DS3231 to epoch timestamp.

Update: I also wrote a function to verify the validity of the input parameter (see this github gist)

2017-01-07

Wifi Scanner with ESP8266 + TFT ST7735B (NodeMCU)

After successful connect the ESP8266 with the ST7735 display I want to do more than the demo - so here comes a Wifi Scanner.

Same hardware setup as in the previous blog post.



And here is the source code:

2017-01-02

ESP8266 (NodeMCU) + 1.8 Inch TFT LCD Display Modul 128X160 SPI Serial ST7735B

Some notes how to connect a "1.8 Inch TFT LCD Display Modul 128X160 SPI Serial ST7735B IC SD Card für Arduino" to a ESP8266 running with NodeMCU.




You need a NodeMCU firmware with (at least) the modules bit and UCG (with st7735 display option).

NodeMCU custom build  options.

NodeMCU custom build
options.
[Update] Also SPI must be selected! (Thanks to Lorenz)


Pinout/Connection

The display has a 8-pin and 16-pin interface. The TFT interface in both are the same. You can choose either of the two interfaces for wiring.

     ESP8266 --             DISP             -- ESP8266
     OPTION 1                                   OPTION 2
                 --------------------------
                |      ST7735B 1.8 TFT     |
                |                          |
         GND -- | GND  (1)                 |
         3V3 -- | VCC  (2)                 |
                | NC   (3)                 |
         3V3 -- | BL   (4)         (1) RST | -- GPIO16 (D0)
                | NC   (5)         (2) CS  | -- GPIO15* (D8) 
GPIO16  (D0) -- | RST  (6) TFT     (3) D/C | -- GPIO02 (D4)
GPIO02  (D4) -- | RS   (7) TFT     (4) DIN | -- GPIO13 (D7)
GPIO13  (D7) -- | SDA  (8) TFT     (5) CLK | -- GPIO14 (D5)
GPIO14  (D5) -- | SCK  (9) TFT     (6) VCC | -- 3V3
GPIO15* (D8) -- | CS   (10)TFT     (7) BL  | -- 3V3
                | CLK  (11)SD      (8) GND | -- GND
                | MISO (12)SD              |
                | MOSI (13)SD              |
                | CS   (14)SD              |
                | NC   (16)                |
                | NC   (15)                |
                 --------------------------

*) pull-down 10k to GND

ESP8266 NodeMCU dev board connected to 16pin interface of TFT
ESP8266 NodeMCU dev board connected to 8pin interface of TFT

Test

I use the GraphicsTest.lua to test the connection. GraphicsTest is part of the NodeMCU examples (you have to upload also all GT_*.lua files to run the test).