MX on Linux

From Cumulus Wiki
Jump to navigationJump to search

Using MX on UNIX-derived Operating Systems

MX runs on various UNIX-derived operating systems (OS), including those found on Apple Mac computers, and those found on devices running Linux.

Introduction

This article focuses on a device called the Raspberry Pi. It is a small board of electronics that can actually run Windows, Mac OS, Chrome OS, various Linux distributions, or the Raspbian OS (based on Ubantu Linux). In this article, the focus is on the last OS, because that is easiest to install, so look elsewhere on the web for details of installing alternatives.

The article will give you some guidance on:

  • Choosing a Pi model to buy
  • Setting it up,
    • either connecting it to a keyboard, mouse, and monitor (could be TV), and internet (wired Ethernet or wireless)
    • or running it headless, where all instructions are typed into another device and the Pi has no keyboard, mouse, or monitor, but is connected to internet (wired Ethernet or wireless)
  • Installing OS
  • Installing Mono
  • Installing Apache, PHP, MariaDB, PhpMyAdmin, and copying your database from another device
  • Running MX

A very quick introduction to Linux

This article is not the place to teach you Linux, you can find books and on-line articles for yourself, but I list here enough for you to understand the instructions used elsewhere in this article.

If you have a Raspberry Pi with a monitor attached, you will see a raspberry icon that you can click to get access to many features including shutdown options.

  • To shutdown a Pi, type sudo halt, and then optionally turn the power off when the shut down has completed.
  • To reboot your Pi, type sudo reboot, and then you will see that your Pi shuts down and then boots up again. Although the notes below rarely mention this instruction, it is usually advisable to reboot after installing new packages, or changing the configuration, to ensure everything works correctly, so you will probably use it quite often during set up.

sudo

Almost all instructions here start with a "sudo", it basically gives administrative rights to whatever follows, and therefore allows you to do tasks that only work in the root user. You use it as a prefix to almost every command you type in terminal mode. There are 3 system commands that will only work with this prefix (or by using the shutdown options in the main menu - raspberry icon in square):

  • sudo halt = stops any cpu functions, but leaves Pi running; used when you have reached the end of commands you want to do for now
  • sudo poweroff = makes pi do a tidy shutdown and turn off its power; used when you will not be using Pi for a while
  • sudo reboot (or "sudo reboot -verbose" for diagnostic output during shutdown and reboot) = makes pi close down and then reboot; used when you change settings, and after you install new software, to ensure Pi starts with all applications

~ and /

The tilde symbol ~ denotes the home directory for the current user. Sub-directories within the current user's folder can be identified by ~/documents or similar notation. To reference a folder in root or any other area, the prefix is always /.

To see what files and folders are in the current directory, type dir for just names or ls for details.

To make a new folder in the current directory, type sudo mkdir folder_name. To give a folder and all its sub-folders and files full permissions (think carefully whether you really want to do this) type something like sudo chmod -R ugo+rw /var/www/html. See next sub-section for explanation.

nano

There are various text editors available on a Pi, nano is a simple one. Like other text editors this can create a file when a file does not exist and edit (subject to file permissions) an existing file. The sudo gives you access to any file, it does not change the actual file access, so you might find you can read a file, but not save it after you have done your edit.

The full syntax is sudo nano -B Path_file_name where the -B means it will create a backup of how the file was before (this can be enabled while in the editor by pressing the control key down and typing B). Alternatively use -C which stores each version in a back-up directory. If you want to edit from a particular line and column you can use +line.column, and also optionally use -l (lower-case "L") to display line numbers which might be useful when trying to correct a problem with a log file like dayfile.txt. If you don't specify a file name, then nano will create a new file and you will need to specify where to save it before exit.


After typing the nano command you need to specify a filename (it might include a path, see previous sub-section) and there are examples later in this article, but if you decide to host a web site on your Pi then you might want to edit its home page with (.html or .php) name like sudo nano /var/www/html/index.php. After you have made an alteration to the current contents of the file, various options are shown at the bottom. Here are two key ones:

  • First is ^O which is used to save the file whilst staying in the editor, to do this press the control key down and type O. Next it shows the current file name, if you press Enter then that file will be overwritten.
  • Another is ^X which means if you press the control key down and type X you get the exit dialogue. If you have not used control and O to save the file, it asks whether you want to save the edited file (type Y), although the Y carries on, any other key stroke cancels without saving, then it shows the current file name, if you press Enter then that file will be overwritten.

Look out for any error message here, you might not have write permissions on an existing file. If you change the file name shown, then it can save as another file, but you will be asked if the new name is correct (again type Y to continue saving). Whilst rm filename will remove a file even if it is write protected, for nano you need to change the file permissions with sudo chmod -R ugo+rw ~/CumulusMX for full access to all files in your Cumulus installation (see the syntax below if you want to restrict access).

  • chmod command to modify permissions
  • letters indicating whose permission is being modified
    • u = Owning user
    • g = Group
    • o = Other users (Public)
  • sign for add or remove permissions
  • + = add permission
  • - = remove permission
  • letters indicating what permission is being changed
    • r = read (4)
    • w = write (2)
    • x = execute (1)

Note that as an alternative shorter syntax you can use numbers e.g. 666 is equivalent to ugo+rw. The first number relates to u, the second to g and the last to o. The values in brackets in list above are added to derive the number. So if you are reading the Cumulus support forum and you see a reference to permissions which includes a string of 3 digits, now you can understand what is meant.

install

This is used for installing packages, you will often see it used with a parameter -y; as without that parameter you have to type Y to continue at each step of an install.

It is important to mention here that the version of packages installed may well be obsolete, this install is finding versions from a Raspberian repository, more recent versions may be available from the providers of each package. To keep this article simple, I accept the Operating System that is installed by NOOBS, even if it is not the latest available from the Raspberian web site, I accept the versions of Mono, Apache, PHP, MariaDB, and others, that are found at the time you issue the install command. The update and upgrade command that I use in multiple places in this article is still only finding the versions available in the repository, and is included just in case the repository is being updated after any install finishes.

If you have more skill than the level of the person at which this article is aimed at, then you should know how to install the latest version from the appropriate web sites.

rename

You can rename a file or a folder with various commands, but the one I will describe here is sudo rm filename.

Miscellaneous

I have created a section here, in case anyone wants to add any more instructions. Please feel free to rename it, or indeed add any clarification anywhere in this article.

Meanwhile, look at this article for more commands.

Which Raspberry Pi to buy

A standard desktop computer consumes at least 200 Watts of power (that is when it is idle, it will increase depending on peripherals attached and any processing being done) all the time it is switched on. A Pi Zero W consumes half a Watt when idle, and up to 1.78 Watt when running tasks or connected to peripherals. A Pi model 4 B (the latest model at time of writing) consumes 2.85 to 80 Watt depending on whether it is idle or working hard. Although Cumulus MX does not need to run 24/7, derived values like highest, lowest, average, and so on, will be more accurately calculated if MX is left running. Although the Pi is not the only small computer model available, it is probably the most popular and the easiest one to use if you do want to run MX all the time and not wreck the planet!

First make a list of what you need

  • Do you want to use a mouse and key board?
    • If so, a model with multiple USB sockets is advisable (like 3B+)
    • This also applies if you want to be able to plug in a USB stick (perhaps for transferring files between devices, e.g. Cumulus configuration and data folder files)
  • Do you want a wired connection to your hub or router?
    • Maybe you are going to update external sites, a wired connection may provide a faster and more dependable communication than a wireless link
    • If so, a model including an Ethernet socket is advisable (like 3 B+)
    • Remember that if you are operating the pi in headless mode, a wired or wireless connection to your LAN is needed for your other device to communicate with the Pi
  • Will your MX need to update a database, feed data to a web site, upload to external sites, or control other devices?
    • If so, a model Zero will have to do each task in turn, and you will see some delay in information updates, plus you will need to use a larger time between updates
    • If so, a model Three (or Four) will be noticeably faster, and support all options in MX, and can update external sites more frequently
  • What interface does your weather station use?
    • If your station communicates to MX via wireless, then you choose a model that supports wireless at the right frequency, all models support basic wireless
    • If your station communicates via Ethernet, then either a wired, or wireless, connection is possible between router/hub and Pi as the station will be plugged into your hub or router
    • If your station communicates to MX via USB, then choose between the model 0W with one USB socket, and the model 3B+ with 4 USB sockets depending on whether you might want to use another USB socket ever
    • If your station uses another communication port (such as serial interface), then you need the additional components that support that interface

Now research how the various models relate to your needs

You can look up online what features are included in the various Pi models, and how they differ in power consumption, and cost. But your decision also needs to consider what you need. Here, I won't describe all the different models, but concentrate on just 2 for simplicity. The model Zero W is appealing as it has low power consumption, it is perfectly adequate for running MX (but has limited speed, it runs the various threads MX uses sequentially) especially if you only use standard MX functionality and don't ask MX to do all the optional extras, and has limited interfaces for peripherals. The model Three B plus is appealing as it has medium power consumption, but can cope better with the multiple threads that MX starts, and has more interfaces built in, such as 4 USB 2 ports. both models support wireless links and Bluetooth.

  • Raspberry Pi Zero W
    • Pi Zero W has WiFi and one micro-USB port which is all that is needed for headless running.
    • Installing onto a faster Pi might speed parts of the installation process, but for actual ‘production’ running this slower, and simpler, Pi will be perfectly adequate.
    • It could run a web server, but that might really slow it down.
    • If you run this headless, all updates are done remotely, so the connectivity and speed of the actual Pi are less important
  • Raspberry Pi Three B Plus
    • The faster speed of this Pi although NOT necessary for running Cumulus MX, will cope better if you are asking MX to do lots of processing (e.g. updating database tables or external sites as well as standard processing).
    • Pi Three B Plus has a socket for an external power supply, Ethernet socket (supports wired link); a HDMI socket for audio/video to TV, or computer monitor; a standard jack audio socket for external headphone, or speaker; 4 standard USB type 2 sockets for weather station, mouse, keyboard, USB stick, or other storage device; plus other connections (e.g. camera).
    • This might be better if you also want to run a web server, or other tasks on the same Pi.
    • Also consider this model if it is to be used on a remote site so when you visit it is useful to be able to plug in a monitor and other peripherals, and to spend as little time on updating as possible.

Other models are available, but you need to check their specification against your needs. For example, the current model Four has more capability, but is less appealing as it also consumes more power.

What else to buy

You can buy just the Pi, which is just a circuit board, or a kit that includes other components. Generally buying as a kit is cheaper than buying items individually.

You will need a micro-SD card (preferably class 10, the class number indicates the relative speed of read/write compared to original design, so this class is 10 times faster). I won't mention manufacture names here, but one well known brand (that uses descriptions like extreme) is the market leader and does have greater reliability than cheaper imitators. The card needs to be at least 16 GB as the installation takes up half of that, but you might prefer to install a 32 GB or 64 GB (or add an external drive or USB memory stick) if you intend to keep a lot of data on the Pi. You can buy Micro-SD cards in these capacities with NOOBS so that on first boot they actually install Raspberian onto your Pi.

This obviously depends on your PI model and on your weather station connection type.

You may want to buy a case, that will protect your Pi from accidental damage. A case specifically designed for your Pi model will have cut-outs in the right place for each interface connection, and will have sufficient ventilation for the electrical components to not over-heat.

You may need a power supply. This could be an official Raspberry Pi power supply. Alternatively, any power supply unit that has a micro USB connector will do, the power consumption of a Pi (whichever model) is fairly small, but it will be powered on 24/7, so a low power consumption ‘switched mode’ type is preferred – i.e. one that does not become warm when plugged in with nothing attached. You may have a suitable one left over from an earlier mobile phone. Some designs have additional holes for peripherals to be attached.

You may need to buy connection leads. You may need a HDMI lead to connect your PI to your TV or a spare computer monitor. You may need a USB lead to connect to your weather station (the Pi model Zero requires a micro USB, the Pi model 3 requires a standard A end USB) and your station probably has a USB A end connection. If your weather station connects by Ethernet, you will need one lead to connect the station to the router and possibly another to connect the hub or router to the Pi.

If you do choose a model 3, consider whether you do want a USB mouse and USB keyboard to use with it. This Pi also supports Bluetooth connections.

Finally, you may wish to buy a second micro-SD unit as a spare, or some other USB connected (or network connected) storage for back-ups and extra storage needs.

Setting up your Pi

You can find, online, instructions about setting up a Pi. The obvious place to look is the manufacturer's web site, or the same documentation on their github page. However, you might look at a supplier's web site, or various other sources of "how to" advice.

The Micro-SD card

A Pi requires either a class 4, or a class 10, micro-SD card (or whatever goes with your Pi model) with a minimum of 8 GB. Various suppliers offer cards of 16 to 64 GB with NOOBS pre-installed ready for use in a Pi. You may even buy a kit that includes a Pi board with components and interfaces on it, a power supply, a micro-SD card, some connection leads, and a case that you can fit the board into to protect it.

Setting up a Pi is simple assuming you have bought a micro-SD card that is, either pre-installed with NOOBS, or with the Raspbian Pi operating system pre-installed. NOOBS makes it easy to install (by default) Rasbian (insert the SD card into the Pi and when you power up the Pi, the operating system will be installed during that first boot. If you have a model with an Ethernet connection, and that is connected first, then NOOBS can offer a choice of other operating systems, or you can download another compatible operating system and install it on the micro-SD card.

Be aware that many such pre-loaded and pre-formatted cards include NOOBs that installs the obsolete Raspbian Jessie (version 8 of Debian from 2015), a few install the old Raspbian Stretch (Version 9 of Debian, dating from 2017), it is hard (but not impossible, I found only one in Haverhill, Suffolk, UK) to find any supplier that sells a card that installs latest Raspberry Operating System Buster (Version 10 of Debian, released in 2019), therefore you might do better to buy a card without NOOBS and download/install the Raspberry Operating System Buster yourself, following either instructions on the Raspberry Pi download page, those at this supplier's tutorial guide, or those in Cumulus support forum.

If you want to be able to use the micro-SD card in other devices (like your PC), you may need to also buy an adapter which allows the micro-SD card to be plugged into a standard SD socket. This may be included if you buy a micro-SD card not sold specifically for the Pi or available with the Pi SD under a special offer for buying two items together.

The Operating System

As said before, a number of operating systems can be installed on your Pi, even Windows. I leave it to you to read, on-line, how to install the operating system you choose, normally the instructions will be found from where you download the system you have selected.

If you have a micro-SD card pre-installed with an operating system, you are ready to go, but you might find yourself using obsolete software!

If you have a micro-SD card pre-installed with NOOBS (Novel Out of Box Software), as described above, the first boot will install the operating system. By default, it will be the latest Raspbian OS when the card was manufactured:

  • Wheezy (7) released in 2013
  • Jessie (8) dating from 2015
  • Stretch (9) released in 2017
  • Buster (10) available from 2019
  • Bullseye(11) under test in 2020

Be aware that unless the installed NOOBS (see noobs/releases although when I looked this was not up to date) is the latest version, it might install an obsolete version of Raspberry Pi Operating System, and as described in Micro-SD card (previous sub-section) it might be better to download/install latest instead of using NOOBS as described below:

  • If you want to install Raspbian, and it is not pre-installed, download from https://www.raspberrypi.org/downloads.
  • That imager is run on any device, say your pc, and then you select write to save it onto the micro-SD card (don't forget this overwrites anything already on the card).
  • This should work without a need to format the card first, (but if you do need to format it, do so using a SD card formatter downloaded from https://www.sdcard.org/downloads/formatter_4/index.html, not the Windows format tool).
  • After this image has been stored it will have created two partitions (one the boot partition is a FAT partition that can be accessed by Windows, but the larger Linux partition is invisible to Windows).

I said above obsolete software, by that I mean that each package it includes (e.g. Libre Office) and each package you add (e.g. PHP) will also leave you using obsolete versions. In the worst case scenario, an attempt to install a package might give an error message that the relevant Raspberry Pi repository is archived and the installation has failed.

Pre-configuring the Pi for headless operation

You can store files in the boot partition of the micro-SD card that can be accessed by Windows.

There are two key files that, as described in following sub-sections, should be created and added to the micro-SD card in advance on another device before the card is inserted into the PI. When the card is inserted in a Pi, these two files will be removed from that partition, one will switch on a setting that is by default off, the other file will be moved to a new location and enable wireless connection to your local network.

Secure Shell Home

What is SSH?

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. If you have two devices (your Pi and another computer), SSH will allow the two devices to exchange commands and responses between a terminal and a computer. You may be too young to remember when communication with a computer was often done remotely using a Teletype or similar device acting in terminal mode, just 4 decades ago this would have been a familiar experience to anyone working with computers, now it may seem strange for you. It is possible you have remote connection from home to a computer at your work (although that probably uses a different protocol as the network is likely to be more secured).

How to set up SSH?

If you want to run your Pi headless (without monitor, keyboard, mouse), then you must ensure SSH (which is off by default) is switched on as your Pi boots up. The only way to achieve that is by adding a file SSH to the boot partition before the micro=SD card is put into the Pi. If you don't do this you cannot get headless operation, and you will need to move a monitor or TV, mouse, and keyboard, across to the Pi, because you can't even close down the Pi tidily!

The file, you add to the boot partition, must be named "SSH" with those three letters in capitals, but with no file extension. You can create the file with whatever text editor you have available.

  • On a Windows PC, if you right click (while viewing the boot directory on the card) there is an option called New and if you select a text file it will create an empty file with the extension .txt. (In windows there is an option to hide extensions which is on by default, so you may need to deselect this option [New menu -> Options] to see this extension). On Windows you can open the file using Notepad to verify it is empty, if you gave accidentally created a file of another type like word processing it will be full of characters some of which do not display. Anyway, you must remove any extension from the file name so it is really just SSH.

Type into the file touch ssh, but nothing else, no empty lines, no end of line characters.

When the card is inserted into your Pi, on boot this file will be removed and the SSH option will be enabled. The default password is raspberry, once you have successfully got SSH working, then with sudo raspi-config (choose option 1 = Change User Password, and set the new password you will use for your SSH session next time).

Of course if you have a monitor or TY, and a mouse and a keyboard, then you don't need to use SSH, but you can give yourself the best of both worlds by switching SSH on, the easiest way is using the Raspi-config tool, either from the main menu (raspberry Pi icon inside a square) or in terminal mode with sudo raspi-config (choose option 1 = Change User Password, and set the password you will use for your SSH session; then choose option 5 = Interfacing Options, look for SSH).

How to use SSH?

If you have a Windows PC, this will allow you to open a Command prompt, Power Shell, or Terminal window (the selection you have available depends on certain settings). If you have a Linux or Mac device, open Terminal. Next, assuming your Pi is running, on whatever other device you have on the same local network, type ssh pi@raspberrypi to get access to default user in your Pi.

(As an alternative for Windows operating system, you can install PuTTY, and use that. PuTTY software (an SSH client for Windows) can be downloaded from https://www.putty.org/).

When you are using a terminal, some of the key combinations, or mouse actions, will be different to those that work when using the computer normally. You will need to check your terminal application, and also whatever you are running on your Pi; but you might find the mouse can't affect cursor location, the mouse might be needed to select text, the left click might copy what is selected, and the right click might paste what is in clipboard at current cursor position.

Alternative to SSH

While SSH gives you access to command lines, and lets you use sudo to overcome the fact that the default user does not have root rights, there might be some times when you are operating your Pi in a headless state (without keyboard or monitor) yet you want to explore its graphical user interface. See this tutorial for one way to do this.

Wireless Network

Depending on your Pi model, it may on first boot ask you to enter your wireless network details, it may list the wireless networks it finds and ask you to choose, or you might need to use the configuration tool, or you might need to click on an icon with two red crosses.

If your Pi is headless, then use your other computer to create a new file in the boot partition of your micro-SD card, and store it in the boot directory on your micro-SD card under the name wpa_supplicant.conf. Again if you are using Windows you can create it as a text file and then replace the .txt extension with a .conf extension,

Ensuring you are using a text editor that won't add any unwanted control characters, add the following text using UTF-8 encoding:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
    ssid="YourNetwork"
    psk="YourNetworkPassword"
    key_mgmt=WPA-PSK
}
  • Obviously, if you are not in United Kingdom, you will replace GB by the country code that applies to you.
  • Within the first set of quotes, replace YourNetwork by whatever Service Set IDentifier is used for your wireless network. You may have typed this into your mobile phone. It may be shown on a card that slips into a slot on your hub or router, but you may have changed it from that initial setting. Whatever it is, and it can be up to 32 characters (letters, numbers, and symbols), type it within the double quotes. Some routers come with a default SSID that is the manufacturer's name, if left unchanged it might conflict with a neighbour, so it is left to you to pick a SSID that is unique to you using up to 32 characters to personalise it.
  • Within the next set of quotes, which relate to the key (or password) that protects access to your network, replace YourNetworkPassword by whatever Pre-Shared-Key (password) is used for your wireless network. You will have typed this into your mobile phone, so that can automatically connect to your network. In this case, you should have changed it (for security reasons) from whatever was shown as the initial password on the card that slips into a slot on your hub or router (possibly all you have done is add a prefix or suffix that means something to you).
  • Most wireless networks will use Wi-Fi Protected Access (WPA) or (from 2006) Wi-Fi Protected Access II (WPA2) protocols, so WPA-PSK is correct for you. Note that your Pi is only able to use these protocols. The earlier Wired Equivalent Privacy (WEP) was officially withdrawn in 2004 as too easy to crack, so it is not supported on a new Pi.

Should you wish to set up your Pi with several network definitions, please see Notes by ExperiMentor (a contributor to the Cumulus support forum in Switzerland). If you are using your Pi headless from a Windows PC and making use of PuTTY on your PC to see the terminal screen you would see on your Pi by using SSH, I again refer you to those notes for more details, although those notes are written assuming you have bought an empty micro-SD card, you selected a particular version of the Raspberry Operating System to download and that you are installing onto a Zero W model.

Other configuration

There are various other configurations you need to do on your PI. Unlike SSH, these can't be done by storing files on the micro-SD card. You need to use the raspbian configuration tool raspi-config, and this can be accessed on your Pi either in a Graphical User Interface (GUI), or by running a command in Terminal. The same command can be run from a remote device if you successfully have SSH running.

Whether on your Pi, or from a remote computer terminal session, the command to use is sudo raspi-config.

Mandatory

When you use SSH for the first time to connect to your Pi, you will see a warning that SSH is enabled but the password has not been changed, which is a security risk. So it is mandatory to change the network password for your Pi from the default raspberry to something that you can remember but makes life hard for anybody trying to hack into your system with malicious intent.

Within the Raspberian configuration utility, you will see an option to change password. You will need to enter the new password twice before it replaces the old one.

The default network (host) name for your Pi is raspberrypi, obviously we need to replace that as well with a name that personalises it to you and does not make it easy for a hacker to know what device is represented by that network name. The name can most easily be changed within the Raspberian configuration utility, but it can also be edited by opening the file where it is stored using sudo nano /etc/hostname. Once we rename this hostname, if we are working headless, we will see an error message: sudo: unable to resolve host raspberrypi, appearing when we leave the configuration utility. These can be safely ignored (it's just because you renamed the Pi) and will disappear after next reboot of your Pi.

Within the Raspberian configuration utility, you will see a Network Options option, it is there that you change the network name. Network options can also be configured by clicking an icon on the Pi (this icon might be two red crosses if network settings are missing, two parallel arrows if the network settings are not correctly set, or the wireless symbol if your wireless network is working). Hopefully, for you the WiFi network and password have already been set by the wpa-supplicant.conf file added to micro-SD card earlier.

Recommended

If you are only going to use the Pi in headless mode, you will select this next configuration. In Boot Options, Desktop / CLI, select Console Autologin. On your actual Pi, instead of showing the desktop as default, you will see the splash screen (unless in another option you turn it off) that says "Welcome to the Raspberry Pi Desktop - Powered by Raspbian" and a terminal prompt where you can enter commands. Alternatively, in boot options, select another option depending on what you want to do when you have a keyboard and monitor (or TV) connected to your Pi.

The default locale for a Pi is normally en_GB.UTF-8. Within the configuration option, you can add additional locales (in most cases there is a UTF-8 option which is preferred and at least one other encoding), there are also a number of special alternative locales, but I am not going to explain all the options, look it up if the default locale is not acceptable.

  • Whatever locale you use, if you have already been using Cumulus (1 or MX), you need to ensure the locale matches the one used for your log files. The versions of MX released from the middle of 2020 onwards are very fussy that all dates use the same delimiter (see Cumulus_MX_formal_release_versions), so you need to check the chosen locale continues to use the same date separator as before. The locale is affected by the version of Mono you install and whether you use the locale parameter when starting MX, so I cannot cover all options.
  • Anyway, the default locale is fine if you are in the UK, you use decimal points for real numbers, you use commas for list separators, and you don't have dates with month first!
  • To change the locale, enter Localisation Options. Note that there is also a Wi-Fi network country which must be set, but as that has already been set by the wpa-supplicant.conf file added to micro-SD card earlier, it is listed here in the recommended section.

In the same option area, there are some more options:

  1. Change Time-zone, by default UTC is used all year round. In the UK if your Cumulus is set to roll over at 10am in summer, you will wish to change the time-zone to UK time.
  2. Change Keyboard Layout if needed, keyboards can support different numbers of characters, and can have different currency symbols, so select whatever is relevant to you

To leave configuration

Select ‘Finish’.

Installing Mono

Sponsored by Microsoft, Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime.

Preparing for Mono installation

Quite often when we try to install, or update, packages on our Pi we will see messages about dependencies, and in some cases error messages saying the installation has failed or been aborted. Before we can install Mono, there are other packages required and these depend upon which Raspbian operating system we have installed, see Mono instructions for Raspberian. Here are 2 of the options (if your Mono installation fails, then you selected wrong one):

For Raspberian 9 (stretch):

sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-raspbianstretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

For Raspberian 10 (buster):

sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-raspbianbuster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

Checking all packages are up to date

Either type:

sudo apt-get update
sudo apt-get upgrade

or to insert in single line type instead sudo apt-get update && sudo apt-get upgrade.

Installing Mono

Assuming you have now got all the pre-requisites correct as in previous steps, you now need to install mono by typing sudo apt-get install -y mono-complete. It is important to note that MX requires the complete edition of mono as there is also a cut-down developer edition of Mono that can be downloaded/installed.

Completing Package Installation

As the Pi does not know exactly which components are needed when multiple packages are installed with various dependencies, sometimes extra components are installed which in the end are not needed when you complete all your installations. To clear up, delete any components that are not included in dependencies by typing sudo apt autoremove.

Installing (or updating) MX

In Cumulus.ini there are various settings that will need to be initialised if you start using MX, or updated if you have used Cumulus (1 or MX) before. Read the linked article for more information, but one item is to identify how to connect to our weather station. On a zero model with only one USB socket connecting to a weather station that uses USB, the default ComPort will be right. On a model 3 with 4 USB sockets, the first USB device to be connected takes the default (ending in zero), the next device will replace that zero with one, and so on; so providing you plug in your weather station without any other device plugged into USB (plug in keyboard, mouse, external storage or USB stick afterwards) again the default will work.

If you have moved from running MX on Windows to running on your Pi, then you potentially have lots of items to update. If you are using sudo nano Cumulus.ini, then you will see control sequences for replace, next page, prior page, and all these these will come in handy.

MX Distribution

Download whatever version of MX you have decided to install (sometimes the latest version has bugs that might cause a problem for your station or the functionality you use) from CumulusMX/releases

Download on Raspberry Pi

If you are download on your Pi, you may download into ~/downloads folder or you may choose location (depending on whether you have changed settings in Chrome). It is recommended, you type sudo mkdir ~/CumulusMX first, and subsequently extract from that same level in zip, alternatively the extract can create the folder for you. Whichever approach you choose, simply open (if the distribution zip is visible right click gives you open option) the download distribution file, next you will need to click extract and choose where the files go.

Download on PC

If you are download on your PC, then you will probably unzip the distribution there and use a tool like FileZilla to copy the installation to your Pi. First of all you need to configure FileZilla Client, unless you have done that previously and saved the configuration:

  • Host - this is the IPv4 address of your Pi, I can't tell you what it is, but it is likely to be 192.168.z.xy where the z is likely to be a single figure like 0 or 1, and the xy is two figures you can find out by looking for "pi" (or whatever host username you have set on your Pi) in the admin interface for your hub or router. (It can also be found out by typing hostname -I). Most networks are setup in a way that the subnet range is from 192.168.1.0 to 192.168.1.255.
  • Username - the default for this is raspberrypi (although on older Pi it might be Pi), but you can may have changed this (as described earlier). (It can be found by typing hostname) or by looking at the contents of the file /etc/hostname.
  • Password - again the default for this is raspberry but we changed it as one of the mandatory configurations earlier.
  • Port - 22 is the default, and I have not said how you can change this!

Click QuickConnect and you should see the local files in the left frame and your Pi files in the right frame. The easiest way is to find the folder called CumulusMX in the distribution on the left and drag it to the correct position in the right hand frame. Then all you need to do is watch the progress until it successfully finishes.

Configuration files

If you have used Cumulus before, but this is first installation on Pi, then you need to copy some files from old installation to your Pi, here are a couple but you may have further configuration files to copy across:

  • Cumulus.ini
  • Strings.ini

The two examples above are in same folder as Cumulus.exe or CumulusMX.exe. You also may have configuration files in a mqtt folder, or elsewhere (for example I store some batch files that Cumulus runs for me in a batch folder).

Remember as mentioned earlier, the Cumulus.ini file may need editing to update port names, any command locations, and to update file locations.

data and Reports files

The entire content of your existing data and Reports folder should also be copied across to your Pi or transferred across using FileZilla or a similar tool. The same settings as for the distribution can be used, but you will have a different starting point in your left frame.

Running Cumulus

The simplest command to start Cumulus is sudo mono CumulusMx.exe, but you may wish to add Optional_parameters.

In the Cumulus Support forum, there are articles about a stop/start routine, a backup routine, and how to run MX as a service. I will let you hunt for and read the relevant topics, as you may find details in more than one place. This article will avoid these and try to keep it simple.

Adding a web server

Ensuring up to date

As before, we run sudo apt update && sudo apt upgrade -y to ensure all packages are up to date before we attempt to add another package. As before this does not update everything to latest versions, it just updates to a consistent state based on what is in the repository for your raspberian version.

Install Apache 2

Apache is not the only web server software (so choose a different one if you like), but it is probably the most comprehensive, so if you have enough space on your Pi, install it using sudo apt install apache2 -y.

If you choose nginx, install that web server with sudo apt-get install nginx.

Install PHP Hypertext Pre-processor

PHP is not the only script language available, but it is quite comprehensive being able to be used either in a fairly simple way or in an object-oriented way for those trying to achieve more complex scripts. The instruction to install it is sudo apt install php -y, which version you get depends on your Pi and its operating system.

I don't advise it, but you can install just the main php components with sudo apt install php7-fpm php7-cgi php7-cli php7-common, if you are short of space, and you are only going to use simple PHP without a database.

You may wish to create a index.php web page at /var/www/html which is the web server root for browsing, or of course you may wish to copy or FTP here all your existing web pages.

The main php.ini is found at /etc/php/7.n/apache2/php.ini (where 'n' depends on your Raspberry OS version and therefore what PHP version gets installed). Your own .ini file gets stored at /usr/lib/php/7.n/php-production.ini. For PhpMyAdmin your php modules loaded in the .ini file need to include at least mysqli and mbstring.

Install Maria database

Since MySQL database is controlled by Oracle, it is not available for Raspberry Pi repository.

Maria is an alternative that has largely similar command syntax so is likely to work with code (like MX) designed to work with MySQL. Since the MX developer (Mark Crossley) actually uses Maria DB we can have plenty of confidence it is suitable. To install this database server, we type sudo apt install mariadb-server php-mysql -y.

Our database files will be stored at /var/lib/mysql by default. Our MariaDB configuration is stored at /etc/mysql/mariadb.conf.d/50-server.cnf, and it is the datadir= entry that controls where the database files are stored.

If you have been using Cumulus before (and have a database) then you can use PhpMyAdmin on your old device to export out all the Cumulus tables as SQL in a zip file, FTP that zip file across to your Pi, use PhpMyAdmin to import that zip file. Providing you selected the right options for what SQL you created in your export, the import will contain SQL to create the tables and to insert all the rows into each table. You might want to also export/import the PhpMyAdmin tables with your preferences in a separate zip, although these might need some extra transformations, as they are specific to a particular version of the database server (and the old device version may not match the MariaDB version on your Pi.

Restarting Apache

After all these installs, we need to restart Apache (so it loads the PHP and MariaDB), by typing sudo service apache2 restart.

WE will also need to do this any time we change our php.ini files, database passwords, and anything else that is checked when the web server starts.

Making your database secure

We need to assign passwords to control access to the database by typing into terminal sudo mysql_secure_installation. That brings up a screen:

  1. where we are asked to type current password for the root (as no password has yet been set, simply press Enter),
  2. next type Y to signify we are going to set a new password for root,
  3. next type in a new password that you will not forget,
  4. next as explained on the screen we are going to say whether users must select a user name as well as a password, type Y to Remove anonymous users
  5. next we have to decide whether we will only be logging into the database on our Pi (using Localhost) or we might be logging in remotely; type Y or N respectively, but if you choose N remember someone other than you might guess there is a root user and might guess the password you set,
  6. next we have another option of whether to retain or delete a test database, answer N or Y respectively, I would keep the test database for now as you can play with it and then remove it later,
  7. finally you type in another Y as that will Reload the privilege tables and ensure all is set up for your access to the database later.

The message when the process sucessfully completes is "Thanks for using MariDB".

Installing Adminer, PhpLiteAdmin, or PhpMyAdmin

Cumulus MX includes two SQLite databases, one is the Weather Diary, the other's use is not documented (see Cumulusmx.db). You might want to install phpLiteAdmin (the significant part of that name is in the middle) to read those SQLite databases using sudo apt install phpliteadmin.

ExportMySQL.exe and CumulusMX.exe (see Cumulus_MX#Executables for details) both create SQL for updating tables in a MySQL database, such as the one our MariaDB software package we have installed can create; so maybe we want to install a package that lets us back up and manipulate tables in this database. PHPMyAdmin is not the only tool that can be used to manipulate your MySQL like database (that is the significance of the "My" bit in the middle of the tools's name), and you may prefer to load a different tool, perhaps adminer that works using a drill down approach. However, let me assume that you are happy to use PHPMyAdmin and I will describe how to install that. Start the install with sudo apt install phpmyadmin -y. (Alternatively install a drill down package with sudo apt install adminer and I leave you to work out the commands needed after that).

The PhpMyAdmin installer will ask some questions. Use your tab key to select <Yes> when it asks whether you want to configure with dbconfig-common.

Finally, we need to add the mysqli module to our php install, to restart apache, and to create symbolic link for the phpadmin installation to the server web root so can be seen in our browser and used there:

sudo phpenmod mysqli
sudo service apache2 restart
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin


You can view any index.php or PHPMyAdmin web page in your browser by prefixing the address with your Pi URL e.g. http://192.168.1.xy/phpmyadmin where x and y are digits you look up as mentioned before where FTP of MX distribution was described. In this case you will see a PHP MyAdmin log on page where you type username and password (as you may not have added any other user yet, the user will be root).