MX on Linux: Difference between revisions

4,301 bytes added ,  29 September 2020
no edit summary
No edit summary
== 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.
 
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 (useful if you want to connect a weather station using USB and connect a keyboard).
 
While both models support wireless links and Bluetooth, the latter model also allows a wired Ethernet connection, and that may be useful if that is how you connect to your weather station (an Ethernet connection is also advisable if you want to install a web server, on your Pi). Having an Ethernet connection, as explained later, makes it possible to easily install the Windows Operating System on your Raspberry Pi on first boot.
 
* Raspberry Pi Zero W
** 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, orand if you want to do other tasks (e.g. word processing - '''Libre Office''' is installed as standard on a Pi) 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 capabilitycapabilities, but ismay be 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.
 
Generally buying as a kit is cheaper than buying items individually. A typical kit includes the Pi board with components and interfaces on it, a power supply (with a plug suitable for your mains sockets), a micro-SD card (see later sub-section), some connection leads, and a case that you can fit the board into to protect it.
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.
 
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. Some designs have additional holes for securing peripherals.
This obviously depends on your PI model and on your weather station connection type.
 
You may need a power supply.
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.
*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.
 
You may need to buy connection leads:
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 a HDMI lead to connect your PI to your TV or a spare computer monitor.
 
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 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.
 
If you do choose a model 3 (or later), consider whether you do want to buy a USB mouse and USB keyboard to use with it.
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 (and videos) about setting up a Pi. A search engine will give you multiple choices!
You can find, online, instructions about setting up a Pi. The obvious place to look is [https://www.raspberrypi.org/documentation/setup/ the manufacturer's web site], or the same documentation on [https://github.com/raspberrypi/documentation/blob/master/setup/README.md their github page]. However, you might look at [http://www.okdo.com/gettingstarted a supplier's web site], or various other sources of "how to" advice.
 
*The obvious place to look is [https://www.raspberrypi.org/documentation/setup/ the manufacturer's web site], they have the same documentation on [https://github.com/raspberrypi/documentation/blob/master/setup/README.md their github page].
*You may prefer to look at [http://www.okdo.com/gettingstarted or another supplier's web site],
* or you can always look various general sources of "how to" advice.
 
== The Micro-SD card ==
 
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).
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.
 
#A Pi will work with either a class 4 (only 4 times faster), or a class 10, micro-SD card.
Setting up a Pi is simple assuming you have bought a micro-SD card that is, either pre-installed with [https://github.com/raspberrypi/documentation/blob/master/installation/noobs.md 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.
#Just for the standard install you need a card with a '''minimum of 8 GB'''.
#Given we are going to add Mono and Cumulus MX to the card, I advise you buy a card with at least 16 GB (as the default operating system installation takes up almost half of that),
#* but you might prefer to buy a 32 GB or 64 GB (or add an external USB drive or USB memory stick) if you intend to keep a lot of data on the Pi.
 
I won't mention manufacturer names here, but one well known brand (that uses descriptions like extreme) is the market leader, and does have greater reliability than cheaper cards from other manufacturers.
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 [https://www.raspberrypi.org/downloads/ Raspberry Pi download page], those at [https://thepihut.com/blogs/raspberry-pi-tutorials/the-raspberry-pi-tutorial-beginners-guide this supplier's tutorial guide], or [https://cumulus.hosiene.co.uk/viewtopic.php?p=139422#p139422 those in Cumulus support forum].
 
''Setting up a Pi is simpler'' '''if you buy a micro-SD card that is''':
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.
* either pre-installed with [https://github.com/raspberrypi/documentation/blob/master/installation/noobs.md NOOBS (Novel Out of Box Software)],
* or pre-installed with the Raspberry Pi operating system.
 
NOOBS makes it easy to install (by default) Raspberry Pi operating system, as if you insert such a micro-SD card into a new Raspberry Pi computer, when you power up the Pi, the operating system will be installed during that first boot. If you have a Raspberry Pi model with an Ethernet connection, and you connect your Pi to your hub/router before you first switch it on, then at that first boot, NOOBS will offer you a choice of several operating systems, with Raspberry Pi as first choice.
== The Operating System ==
 
Various suppliers offer cards of 16 to 64 GB with NOOBS pre-installed ready for use in a Pi (I bought from a firm in Haverhill, Suffolk, UK).
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.
 
My advice is to buy your micro-SD card from a firm that specialises in selling Raspberry Pi computers and accessories. That should ensure you buy a card with the latest version of NOOBS (or Raspberry Pi Operating System) and that will make your life simpler than buying a blank micro-SD card and having to down load and add the operating system yourself.
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 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 may be available with the Pi micro-SD under a special offer for buying two items together.
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
 
== The Operating System ==
Be aware that unless the installed NOOBS (see [https://github.com/raspberrypi/noobs/releases 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).
 
As said before, a number of operating systems can be installed on your Pi, even 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.
 
To keep this article simple, I will assume you have bought a micro-SD card either pre-installed with an operating system (OS) so you are ready to go, or you used NOOBS (as described earlier) to install your chosen OS.
== Pre-configuring the Pi for headless operation ==
 
If you do need to install any operating system you choose, normally the instructions will be found from where you download the system you have selected. If you have brought a card without NOOBS, you can download/install the Raspberry Operating System Buster yourself, following either instructions on the [https://www.raspberrypi.org/downloads/ Raspberry Pi download page], those at [https://thepihut.com/blogs/raspberry-pi-tutorials/the-raspberry-pi-tutorial-beginners-guide this supplier's tutorial guide], or [https://cumulus.hosiene.co.uk/viewtopic.php?p=139422#p139422 those in Cumulus support forum]. To save you looking any of those up, the next sub-section summarises what you need to do.
You can store files in the boot partition of the micro-SD card that can be accessed by Windows.
 
=== How to add Raspberry Operating System to a card yourself ===
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.
 
*Download from https://www.raspberrypi.org/downloads.
=== Secure Shell Home ===
*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 on the micro-SD card (one the boot partition is a FAT partition that can be accessed by Windows, but the larger Linux partition is invisible to Windows).
 
=== Is the operating system obsolete or up to date?===
==== What is SSH?====
 
It is important that your Raspberry Pi (or other device) has the latest operating system version installed. If the Operating System installed is an obsolete one, then each package it includes (e.g. Libre Office), and each package you add (e.g. Mono or PHP), will also be obsolete versions. In the worst case scenario, any attempt to install a package might fail giving an error message that the relevant Raspberry Pi repository is archived.
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).
 
If you have a micro-SD card pre-installed with NOOBS, as described above, the first boot will install the operating system. It is the version of NOOBS that is included on the card that determines which Raspberry Pi Operating System version is set up:
====How to set up SSH?====
*Wheezy (7) released in 2013
*Jessie (8) dating from 2015
*Stretch (9) released in 2017 (up to this called Raspbian Operating System)
*Buster (10) available from 2019 (the first to be called Raspberry Pi Operating System)
*Bullseye (11) under test in 2020
 
Be aware that many such pre-loaded and pre-formatted cards include an obsolete version of NOOBS.
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!
*You may find your card 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),
*a good supplier sells a card that installs latest Raspberry Operating System Buster (Version 10 of Debian, released in 2019).
 
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 <tt>touch ssh</tt>, 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 <tt>ssh pi@raspberrypi</tt> 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 <tt>https://www.putty.org/</tt>).
 
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 [https://thepihut.com/blogs/raspberry-pi-tutorials/remotely-accessing-the-raspberry-pi-via-rdp-gui-mode 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:
<pre>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
 
network={
ssid="YourNetwork"
psk="YourNetworkPassword"
key_mgmt=WPA-PSK
}</pre>
 
*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 [https://cumulus.hosiene.co.uk/viewtopic.php?p=139422#p139422 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 ===
Whether on your Pi, or from a remote computer terminal session, the command to use is <tt>sudo raspi-config</tt>.
 
==== Mandatory configurations ====
 
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 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.con'''f file added to micro-SD card earlier.
 
==== Recommended configurations ====
 
The default '''locale''' for a Pi is normally '''en_GB.UTF-8''', as they are designed by a company based in UK. 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.
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!
=== 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 dependvary depending upon whichthe Raspbian operating system version we have installed, see [https://www.mono-project.com/download/stable/#download-lin-raspbian Mono instructions for Raspberian]. Here are 2the oflatest the2 options when this article was updated (if your Mono installation fails, then you selected wrong one):
 
For Raspberian 9 (stretch):
=== Installing Mono ===
 
Assuming you have now gotWith all the pre-requisites correct as in previous steps, you now need tocan install mono by simply typing <tt>sudo apt-get install -y mono-complete</tt>. 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. "sudo" as already described gives us rights, "apt-get" is one of the ways to search the Raspberry respository for applications, "install" is the action we want to do, and "mono-complete" is the package we want.
 
=== Completing Package Installation ===
====Download on Raspberry Pi====
 
If you are download on your Pi, and that is the easiest option, 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 <tt>sudo mkdir ~/CumulusMX</tt> 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 MX 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 <tt>hostname -I</tt>). Most networks are setup in a way that the subnet range is from 192.168.1.0 to 192.168.1.255.
# Run MX as a '''systemd service''' (see the more recent posts in the service link above), be aware that at time of typing this is planned to be incorporated in a future release but the MX developer has no knowledge in this area
 
=Optional actions=
= Adding a web server =
 
The above has covered all you need to do to use a Raspberry Pi (or other Unix-based device) to run MX.
== Ensuring up to date ==
 
However, some people want to do more, so various options are covered in the remainder of this article.
As before, we run <tt>sudo apt update && sudo apt upgrade -y</tt> 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 (or another web server) ==
 
=== Before adding any extra packages ===
'''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 <tt>sudo apt install apache2 -y</tt>. You might want to use Fast CGI and therefore add <tt>sudo apt-get install libapache2-mod-fcgid</tt>.
 
*We run <tt>sudo apt update && sudo apt upgrade -y</tt> to ensure all packages are up to date before we attempt to add another package.
If you choose '''nginx''', install that web server with <tt>sudo apt-get install nginx -y</tt>.
*I remind you here that this does not update everything on your computer to the latest versions available for a Pi, that requires a different (more risky) command not taught here.
*Instead, the instruction quoted above just updates your Pi to a consistent state; based on what is in the repository you are already using.
 
==Databases built into Cumulus MX==
If you choose '''lighttpd''', install it with <tt>sudo apt-get install lighttpd -y</tt>.
 
Cumulus MX includes two SQLite databases;
== Install PHP Hypertext Pre-processor ==
#The first database was added by Steve Loft, but he never documented what it is used for (see [[Cumulusmx.db]]) and in the support forum when someone asked, nobody was able to answer.
#The second database is the [[Weather Diary]] added by Mark Crossley, that is documented, and in the support forum there is a topic comparing the differences between Cumulus 1 and Cumulus MX weather diaries.
 
You do not need to know what is in those databases to use MX. The [[MX Administrative Interface|Admin Interface]] provides a page to view or edit the weather diary.
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 <tt>sudo apt install php -y</tt>, which version you get depends on your Pi and its operating system. To check which modules have been installed type <tt>php -m</tt>. For PhpMyAdmin your php modules loaded (they are also listed in the .ini file, where unwanted ones can be commented out), must include at least mysqli and mbstring, I will say how to find the .ini files later.
 
Optionally, you could install phpLiteAdmin (the significant part of that name is in the middle) to read those SQLite databases. Install it using <tt>sudo apt install phpliteadmin</tt>.
Alternatively, you can install <tt>sudo apt install</tt> particular php modules, or a particular version, by selecting components from a list like "<tt>php7-fpm php7-cgi php7-cli php7-common php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y</tt>, only use this approach to force a particular version (but you may find that is not available), or if you are short of space, and you are only going to use a minority of the php features available in the full set of modules.
 
If you do find out what the first database is used for, please update the Wiki article on it!
 
 
=== Install Apache 2 (or another web server) ===
 
I will mention 3 possible web servers:
#If you choose '''Apache''' it is probably the most comprehensive, so if you have enough space on your Pi, install it using <tt>sudo apt install apache2 -y</tt>.
#*You might want to use Fast CGI (if you don't know what that is, skip this) and therefore add <tt>sudo apt-get install libapache2-mod-fcgid</tt>.
#If you choose '''nginx''', install that web server with <tt>sudo apt-get install nginx -y</tt>.
#If you choose '''lighttpd''', install it with <tt>sudo apt-get install lighttpd -y</tt>.
 
=== 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 simplest instruction to install it is <tt>sudo apt install php -y</tt>, which version you get depends on your Pi and its operating system.
*To check which PHP modules have been installed by the above command, type <tt>php -m</tt>.
*If you later want to use a database (and a tool like PhpMyAdmin), then your php modules loaded must include at least '''mysqli''' and '''mbstring'''.
*I will explain how to find the .ini files later, but unwanted modules can be commented out in your .ini file.
 
'''Alternatively''', you can install particular php modules, or a particular PHP version, by selecting components from a list. To do this type something like <tt>sudo apt install php7-fpm php7-cgi php7-cli php7-common php7.3-mbstring php7.3-mysql php7.3-curl php7.3-gd php7.3-zip -y</tt>. Only use this approach to force a particular version (but you may find that is not available), or if you are short of space, and you are only going to use a minority of the php features available in the full set of modules.
 
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. To view a php web page, go into a browser and type in a url with the same IPv4 address as you use for the admin interface, omit the port (:8998) and instead type in your web page name (e.g. //192.168.1.'''xy'''/index.php, where you need to determine digits that replace '''xy''').
 
To test that php is installed, type <tt>php -v</tt> into terminal, and you will see the exact version that has been installed, a confirmation that it offers command line interface (cli), and a copyright notice.
 
===Creating a Home web page on your web server===
The ''web server'' main '''php.ini''' is found at ''/etc/php/7.n/apache2/php.ini'' (where 'n' depends on your Raspberry OS version and therefore which PHP version was installed, that was found out in last paragraph). You may need to edit this file for example to specify where your include files are stored (if not in same folder as script with require/include). Replace "apache2" by "cli" in the path for the ''batch'' '''php.ini''' file that you may also need to edit.
 
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. To view a php web page, go into a browser and type in a url with the same IPv4 address as you use for the admin interface, omit the port (:8998) and instead type in your web page name (e.g. //192.168.1.'''xy'''/index.php, where you need to determine digits that replace '''xy''').
To run a php script in batch, type <tt>php - f <file_name></tt>. You can redirect the output by adding a greater than symbol and the destination file (i.e. > log_file) on the same terminal line.
 
===Finding your PHP configuration file===
== Install Maria database ==
 
For sake of simplicity in this article, from now on I will assume the web server you installed is "apache2", change that segment (in the paths quoted below here), if you installed a different web server.
Since MySQL database is controlled by Oracle, it is not available for Raspberry Pi repository.
 
The ''web server'' main '''php.ini''' is found at ''/etc/php/7.n/apache2/php.ini'' (where 'n' depends on your Raspberry OS version and therefore which PHP version was installed, that was found out in last sub-section).
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 <tt>sudo apt install mariadb-server php-mysql -y</tt>.
 
You may need to edit this file for example to specify where your include files are stored (if not in same folder as script with require/include). Replace "apache2" by "cli" in the path for the ''batch'' '''php.ini''' file that you may also need to edit.
 
To run a php script in batch, type <tt>php - f <file_name></tt>. You can redirect the output by adding a greater than symbol and the destination file (i.e. > log_file) on the same terminal line.
 
If you want the MX external commands to run a PHP script for you, use something like "sh" as the program to run (i.e. run shell script); and in the parameters something like
'''/home/pi/CumulusMX/MXutils/autoEOD.sh''' will run a script "autoEOD.sh" you have added to the "MXutils" folder. In that script, you put something like (assuming you have added a folder 'batch' with a subfolder 'log'):
<pre>#!/bin/sh
# This MX batch command file is initiated automatically by Cumulus MX software during last stage of processing the end of a meteorological day
echo "It stores feedback in log file CumulusMXDailyBatch (file name ends with day of month)"
sudo php -f the_path_and_filename_goes_here.php > /home/pi/CumulusMX/batch/log/DailyBatch_Day$(date +%d).log
</pre>
 
 
 
=== Install Maria database ===
 
MySQL database software is controlled by Oracle and not made available for inclusion in 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 <tt>sudo apt install mariadb-server php-mysql -y</tt>.
 
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.
 
=== Making your database secure ===
 
We need to assign passwords to control access to the database by typing into terminal <tt>sudo mysql_secure_installation</tt>. That brings up a screen:
# 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 sucessfullysuccessfully completes, is "Thanks for using MariDB".
 
== Installing Adminer, PhpLiteAdmin, or PhpMyAdmin ==
 
=== Installing Adminer, 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 <tt>sudo apt install phpliteadmin</tt>.
 
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.
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'''.
 
===Getting web and database servers ready for use===
 
We need to create a user for PhpMyAdmin (or adMiner or whatever) to access our database and another for Cumulus to use to access the database tables. At the moment our database access has the single root@localhost user we created when we installed MariaDB. The initial password was set then, and we need to use it to get access to MariDB monitor where we can insert some SQL commands to create these two users. PhpMyAdmin on first start up will ask for username and password, thereafter it will use same log-in, let us create a user called 'admin' for it. The user name and password for the data base is set in MX using the [[MX_Administrative_Interface#MySQL_settings|MySQL_settings]] in the admin interface, let us create a user called 'weather'. Obviously, these names might not be what you use, but you can amend commands below accordingly. For each line with SQL, it must end with a semicolon (;) as shown. The SQL lines have a prompt of a greater than symbol (>) while the command lines have a prompt showing current path. Note that "identified by" is followed by a password enclosed in single quotes.
 
We will need to restart Apache (or whichever web server we installed) any time we change our php.ini files, database passwords, and anything else that is checked when the web server starts.
 
 
 
== Pre-configuring the Pi for headless operation ==
 
The terminology "headless" means using another device to send commands to a Pi via a wired or wireless network, instead of connecting a keyboard and monitor (or TV) to the Pi.
 
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.
 
If you insert the micro-SD card (used on your Pi) into your PC, you can store files in the boot partition of the micro-SD card that can be accessed by Windows.
 
 
 
=== 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 <tt>touch ssh</tt>, 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 <tt>ssh pi@raspberrypi</tt> 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 <tt>https://www.putty.org/</tt>).
 
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 [https://thepihut.com/blogs/raspberry-pi-tutorials/remotely-accessing-the-raspberry-pi-via-rdp-gui-mode this tutorial] for one way to do this.
 
===Headless Wireless Network set up===
 
If you don't connect a keyboard and monitor to your Raspberry Pi, you can't set up the wireless network configuration on it.
 
You can use the SSH approach described above to access the '''Raspi-config''' tool and in that do the necessary configuration.
 
There is one further, complicated, way to set up the wireless configuration so that the wireless network will work when you first boot up your Raspberry Pi. If you have brought the Zero model, that does not allow Ethernet connection, you might decide to follow this complex approach that involves creating a text file in the boot partition of your micro-SD card, and store it in the boot directory on your micro-SD card with a file name '''wpa_supplicant.conf'''.
 
A note of caution here, it is easy to make mistakes, and you may find this does not work. It is presented here just to cover all options, to use this does require some technical skill, a novice will be better off avoiding this.
 
Ensuring you are using a text editor that won't add any unwanted control characters, add the following text using UTF-8 encoding:
<pre>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
 
network={
ssid="YourNetwork"
psk="YourNetworkPassword"
key_mgmt=WPA-PSK
}</pre>
 
*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'' (SSID) 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 [https://cumulus.hosiene.co.uk/viewtopic.php?p=139422#p139422 Notes by ExperiMentor] (a contributor, in Switzerland, to the Cumulus support forum).
 
== Adding a web server and database server ==
 
Now you have a Raspberry Pi (or another device than can be left running all the time without consuming a lot of electricity), you might want to add a web server and database server so you can make use of the web templates that Cumulus MX provides, and its ability to update database tables. This is an option, and may not be useful to you, but is described here in case it is something that you want to do.
5,838

edits