Running OTmonitor on a Raspberry Pi

Here are some basic instructions for people unfamiliar with linux who want to run otmonitor on a Raspberry Pi:
Step #1
Download and install an OS onto the SD card, as explained on the Raspberry Pi web site. If you intend to use a monitor with your Raspberry Pi, choose the "Raspberry Pi OS with desktop" image. If your Raspberry Pi is supposed to run "headless", the "Raspberry Pi OS Lite" image suffices.

For a headless system, you may want to enable ssh before booting the device. If you don't have wired LAN available, you will also want to preconfigure wifi for a headless system.

Step #2
Put the SD card into the Raspberry Pi. Attach a network cable, monitor, mouse and keyboard, as necessary. Then power it up.

Step #3
Wait for the system to boot. This may take a while the first time, because the file system will automatically be expanded and then the system boots again.

For a headless system, you'll need to figure out which IP address has been assigned to the Raspberry Pi. If necessary, connect to the device and log in as user "pi" with password "raspberry".

Step #4
When running the Pi with a monitor, the system will have already prompted you for some configuration settings. If not, or if you accidentally pressed "Next" too quickly, or you want to change the choices you made, open a terminal (Ctrl+Alt+T, if you don't have a mouse) and run the raspi-config tool manually. This also needs to be done on a headless system:
sudo raspi-config

Use the cursor keys to go to "Localisation Options" and "Timezone". Select the desired time zone.

If you are going to access the OTGW using the built-in serial port, navigate to "Interface Options", "Serial Port", and choose "No" for a serial login shell and "Yes" for the serial port hardware to be enabled. This is not necessary when using a USB->Serial adapter or for the wifi or ethernet versions of the gateway from the nodo shop.
Warning: The built-in serial port of the Raspberry Pi uses 3.3V logic. You will damage the device if it is connected to the OTGW without proper level shifters.

Make any other configuration changes you want, then exit the tool. If it asks to reboot, choose "No".

Step #5
Actually install the otmonitor application using the following commands:
mkdir bin cd bin wget -O otmonitor http://otgw.tclcode.com/download/otmonitor-ahf chmod +x otmonitor cd
Step #6
The location where the application was installed did not exist before, so it is not included in the current PATH environment variable. Either log out and log back in to resolve that, or add it manually:
PATH=$HOME/bin:$PATH

Step #7
Run the application. On a desktop system, you can run the GUI version:
otmonitor
To run otmonitor without a GUI, you will need to enable the webserver to be able to configure it:
otmonitor --daemon --webserver=8880
Now a browser can be pointed at http://<RaspberryPiIP>:8880/.

If you don't want to have to use a port number in the URL, the webserver must be started on port 80. However, all ports below 1024 are reserved. So you need administrator rights to use those ports:

sudo otmonitor --daemon --webserver=80

Step #8
Now configure the application. At least the connection to the OTGW will needs to be specified. When configuring otmonitor via the web GUI, close the tab when done to make sure the changes are saved.

Once the application has been configured, it may be convenient to start it automatically on each boot. The two modes of operation require different methods:

GUI mode
The steps are:
  1. Create an autostart directory under .config in pi's home directory.
  2. Download otmonitor.desktop into the newly created autostart directory.

From the command line, this can be done using these commands:

mkdir ~/.config/autostart wget -P ~/.config/autostart http://otgw.tclcode.com/download/otmonitor.desktop
Daemon mode
The easiest way to automatically start an otmonitor daemon is via crontab:
crontab -e
Add the following line at the end:
    @reboot /home/pi/bin/otmonitor --daemon
    
Or for a webserver on port 80:
    @reboot sudo /home/pi/bin/otmonitor --daemon
    
This can also be done without the need to use an editor:
(crontab -l;echo @reboot /home/pi/bin/otmonitor --daemon) | crontab
Or:
(crontab -l;echo @reboot sudo /home/pi/bin/otmonitor --daemon) | crontab