QuakeLogic Blog Archive

Install an MQTT Broker on Ubuntu With Mosquitto for EEW Alerts

Terminal showing Mosquitto MQTT broker installation on Ubuntu for earthquake early warning messaging

In short: To install an MQTT broker on Ubuntu, run sudo apt update, sudo apt install mosquitto mosquitto-clients, then sudo systemctl enable mosquitto and sudo systemctl start mosquitto. Mosquitto listens on port 1883 and allows anonymous clients by default; test it with mosquitto_sub and mosquitto_pub. For production, add a password file and TLS. QuakeLogic uses MQTT to deliver earthquake early warning messages to IP-based sirens.

MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol designed for constrained devices and low-bandwidth, high-latency, or unreliable networks. It is widely used in IoT (Internet of Things) applications to facilitate communication between devices. In this guide, we will walk you through the steps to install and start an MQTT broker on Ubuntu using Mosquitto, a popular MQTT broker.

At QuakeLogic, we often use the MQTT service to deliver earthquake early warning messages, for example to activate the IP-based sirens that operate over the network.

Seismic monitoring instrumentation for "Why Every Facility Needs a Comprehensive Earthquake Early Warning Policy"

Step 1: Update Your System

Before installing any new software, it’s always a good idea to update your package list to ensure you have the latest version of all your installed packages.

sudo apt update

Step 2: Install Mosquitto and Mosquitto Clients

Mosquitto is a lightweight MQTT broker that is easy to install and configure. The Mosquitto clients package includes command-line tools to test your setup.

sudo apt install mosquitto mosquitto-clients

Step 3: Enable and Start the Mosquitto Service

Once installed, you need to enable the Mosquitto service to start on boot and then start the service.

  1. Enable the Mosquitto service: sudo systemctl enable mosquitto
  2. Start the Mosquitto service: sudo systemctl start mosquitto
  3. Check the status of the Mosquitto service: sudo systemctl status mosquitto You should see an output indicating that Mosquitto is active and running.

Step 4: Configure Mosquitto (Optional)

By default, Mosquitto is configured to allow anonymous connections on port 1883. For more advanced configurations, you can edit the Mosquitto configuration file located at /etc/mosquitto/mosquitto.conf.

  1. Open the configuration file: sudo nano /etc/mosquitto/mosquitto.conf
  2. Example configuration for allowing remote connections: listener 1883 allow_anonymous true
  3. Save and exit the file, then restart Mosquitto to apply changes: sudo systemctl restart mosquitto

Step 5: Test Mosquitto

To ensure Mosquitto is working correctly, you can use the Mosquitto clients to publish and subscribe to messages.

  1. Open two terminal windows.
  2. In the first terminal window, subscribe to a topic: mosquitto_sub -h localhost -t test/topic
  3. In the second terminal window, publish a message to the topic: mosquitto_pub -h localhost -t test/topic -m "Hello MQTT"

You should see the message “Hello MQTT” appear in the first terminal window.

Step 6: Secure Mosquitto (Optional)

For production environments, it is important to secure your MQTT broker. You can enable password protection and TLS/SSL encryption.

  1. Create a password file: sudo mosquitto_passwd -c /etc/mosquitto/passwd username
  2. Edit the Mosquitto configuration to use the password file: allow_anonymous false password_file /etc/mosquitto/passwd
  3. Restart Mosquitto: sudo systemctl restart mosquitto

For TLS/SSL encryption, you need to generate certificates and configure Mosquitto to use them. Detailed instructions can be found in the Mosquitto documentation.

Conclusion

By following these steps, you can easily set up an MQTT broker on your Ubuntu system using Mosquitto. This setup will allow you to facilitate communication between IoT devices efficiently. For more advanced configurations and security setups, refer to the Mosquitto documentation or reach out to the community for support.


About QuakeLogic

QuakeLogic is a leading provider of advanced seismic monitoring solutions, offering a range of products and services designed to enhance the accuracy and efficiency of seismic data acquisition and analysis. Our innovative technologies and expert support help organizations worldwide to better understand and mitigate the impacts of seismic events.

Contact Information

For more information about our products and services, please visit our website or contact our sales team. We are here to help you with all your seismic monitoring needs.


Thank you for choosing QuakeLogic. We look forward to assisting you with your seismic monitoring projects. Stay tuned to our blog for more tips and guides on using seismic monitoring tools and other technological solutions!

Key Takeaways

  • Install with sudo apt update followed by sudo apt install mosquitto mosquitto-clients.
  • Enable at boot and start: sudo systemctl enable mosquitto, sudo systemctl start mosquitto; verify with systemctl status.
  • Default config allows anonymous connections on port 1883; edit /etc/mosquitto/mosquitto.conf and add listener 1883 for remote clients.
  • Test with mosquitto_sub -h localhost -t test/topic in one terminal and mosquitto_pub -t test/topic -m 'Hello MQTT' in another.
  • Secure production brokers with mosquitto_passwd, allow_anonymous false and TLS certificates.

Frequently Asked Questions

How do I install Mosquitto on Ubuntu?

Update the package list with sudo apt update, then install the broker and command-line tools with sudo apt install mosquitto mosquitto-clients. Enable the service to start at boot using sudo systemctl enable mosquitto, start it with sudo systemctl start mosquitto, and confirm it is active with sudo systemctl status mosquitto. The broker is then listening on port 1883.

How do I test that the MQTT broker is working?

Open two terminals. In the first, subscribe to a topic with mosquitto_sub -h localhost -t test/topic. In the second, publish with mosquitto_pub -h localhost -t test/topic -m "Hello MQTT". If the message appears in the first terminal, the Mosquitto broker is routing messages correctly between clients and the installation is complete.

How do I allow remote connections to Mosquitto?

Edit /etc/mosquitto/mosquitto.conf with sudo nano and add listener 1883 together with allow_anonymous true for an open test broker, then restart with sudo systemctl restart mosquitto. Also make sure port 1883 is open in any firewall. For anything beyond a lab test, replace anonymous access with a password file and TLS encryption.

How do I secure a Mosquitto MQTT broker?

Create a password file with sudo mosquitto_passwd -c /etc/mosquitto/passwd username, then set allow_anonymous false and password_file /etc/mosquitto/passwd in the configuration and restart Mosquitto. For encryption, generate certificates and configure a TLS listener as described in the Mosquitto documentation. Password protection plus TLS is the minimum for a production broker.

Why is MQTT used for earthquake early warning?

MQTT is a lightweight publish/subscribe protocol built for constrained devices and low-bandwidth or unreliable networks, which makes it well suited to pushing time-critical alerts to many endpoints at once. QuakeLogic uses an MQTT broker to deliver earthquake early warning messages, for example to activate IP-based sirens across a network the moment a warning is issued.

Need help with a project? QuakeLogic designs and supplies seismic monitoring, earthquake early warning, structural health monitoring, infrasound, and shake table systems. Browse QuakeLogic products or contact our engineering team with your site, structure, or test requirements.

Acceleration or Velocity Data for Earthquake Monitoring?

Accelerometer and broadband seismometer recordings compared for earthquake monitoring

In short: Choose acceleration or velocity data based on what you need to detect: accelerometers suit near-field strong motion because they capture high frequencies and measure peak ground acceleration directly, while broadband seismometers recording velocity have lower noise and clearer low-frequency signals for small, distant or deep earthquakes. Many networks use both sensor types, and SeisComP can process either.

In earthquake monitoring, the choice between using acceleration data or velocity data for event detection depends on several factors, including the objectives of your monitoring system, the type of sensors available, and the specific characteristics of the seismic events you are interested in detecting. Both types of data have their own advantages and disadvantages. Let’s explore these in detail.

Acceleration Data

Pros

  1. High Sensitivity to Ground Shaking: Accelerometers are highly sensitive to ground shaking and can capture high-frequency components of seismic waves. This makes them ideal for detecting strong ground motions close to the epicenter of an earthquake.
  2. Broad Frequency Range: Acceleration data can cover a broad frequency range, allowing for the detection of both high-frequency and low-frequency seismic events.
  3. Capturing Peak Ground Acceleration (PGA): Accelerometers provide direct measurements of PGA, which is a crucial parameter for assessing the intensity of shaking and potential damage during an earthquake.
  4. Structural Health Monitoring: In addition to earthquake detection, acceleration data is valuable for structural health monitoring and assessing the dynamic response of buildings and infrastructure.

Cons

  1. Noise Sensitivity: Acceleration data can be more sensitive to noise, especially from human activities and environmental factors. This can make it challenging to distinguish between seismic events and noise.
  2. Complex Integration for Velocity: To derive velocity data from acceleration data, numerical integration is required. This process can introduce errors, especially at low frequencies, due to baseline drifts and noise.

Velocity Data

Pros

  1. Lower Noise Levels: Velocity data, typically recorded by broadband seismometers, generally has lower noise levels compared to acceleration data, making it easier to detect small and distant earthquakes.
  2. Clearer Low-Frequency Signals: Velocity data is better at capturing low-frequency signals, which are important for detecting and analyzing distant and deep earthquakes.
  3. Direct Use for Seismic Analysis: Many seismic analysis methods, such as spectral analysis and moment tensor inversion, are based on velocity data. This makes velocity data more straightforward to use in these applications.
  4. Continuous Monitoring: Velocity data is well-suited for continuous monitoring of seismic activity, as it provides a clearer picture of the overall seismic background.

Cons

  1. Limited High-Frequency Sensitivity: Velocity sensors are less sensitive to high-frequency components of ground motion, which can limit their effectiveness in detecting near-field, high-frequency seismic events.
  2. Additional Equipment Cost: Broadband seismometers that record velocity data are generally more expensive than accelerometers, which can increase the overall cost of the monitoring system.

Practical Considerations

Application-Specific Choices

  • Near-Field Earthquake Detection: If the primary goal is to detect and analyze strong ground motions near the earthquake source, accelerometers and acceleration data are preferable due to their high sensitivity to ground shaking and ability to capture high-frequency signals.
  • Far-Field Earthquake Detection: For detecting distant or deep earthquakes, broadband seismometers that record velocity data are more suitable due to their ability to capture low-frequency signals and their lower noise levels.
  • Comprehensive Monitoring Systems: Many advanced seismic monitoring systems use both types of sensors to take advantage of the strengths of each type of data. This hybrid approach provides a more complete picture of seismic activity and allows for robust event detection and analysis.

SeisComP Usage

SeisComP, a popular seismic monitoring software, can handle both acceleration and velocity data. The choice of which type of data to use with SeisComP depends on the specific goals of your monitoring system. SeisComP can process and integrate data from both types of sensors, allowing you to customize your setup based on your needs.

Conclusion

Both acceleration and velocity data have their own advantages and disadvantages for earthquake monitoring. The choice between the two should be based on the specific requirements of your monitoring system, including the type of seismic events you aim to detect, the proximity to the seismic source, and the available budget. By carefully considering these factors, you can design an effective seismic monitoring system that meets your needs.

For expert guidance and support, consider reaching out to QuakeLogic, your seismic monitoring expert. QuakeLogic provides advanced seismic monitoring solutions tailored to enhance the accuracy and efficiency of seismic data acquisition and analysis.


We hope you found this guide helpful. For more tips and guides on using SeisComP and other seismological tools, stay tuned to our blog. If you have any questions or need further assistance, feel free to reach out to our support team. Happy seismographing!

About QuakeLogic

QuakeLogic is a leading provider of advanced seismic monitoring solutions, offering a range of products and services designed to enhance the accuracy and efficiency of seismic data acquisition and analysis. Our innovative technologies and expert support help organizations worldwide to better understand and mitigate the impacts of seismic events.

Contact Information

For more information about our products and services, please visit our website or contact our sales team. We are here to help you with all your seismic monitoring needs.


Thank you for choosing QuakeLogic. We look forward to assisting you with your seismic monitoring projects.

Key Takeaways

  • Accelerometers: high sensitivity to strong shaking, broad frequency range, direct PGA, useful for structural health monitoring.
  • Accelerometer drawbacks: more sensitive to cultural noise; integrating to velocity introduces low-frequency errors from baseline drift.
  • Broadband seismometers (velocity): lower noise, clearer low-frequency signals, direct input to spectral analysis and moment tensor inversion.
  • Velocity drawbacks: weaker high-frequency sensitivity for near-field events and higher instrument cost.
  • Near-field monitoring favors accelerometers, far-field favors seismometers; hybrid networks and SeisComP handle both.

Frequently Asked Questions

When should I use an accelerometer instead of a seismometer for earthquake monitoring?

Use an accelerometer when the goal is to record strong ground motion close to the epicenter. Accelerometers are highly sensitive to ground shaking, capture high-frequency components, measure peak ground acceleration directly and are also valuable for structural health monitoring of buildings. Their trade-offs are greater sensitivity to human and environmental noise and errors when integrating to velocity at low frequencies.

Why is velocity data better for detecting distant earthquakes?

Velocity data from broadband seismometers has lower noise levels and captures low-frequency signals more clearly, which is what distant and deep earthquakes produce at a station. That makes small and far-field events easier to detect, and many seismic analysis methods such as spectral analysis and moment tensor inversion work directly on velocity records. The downsides are reduced high-frequency sensitivity and higher sensor cost.

Can SeisComP process both acceleration and velocity data?

Yes. SeisComP can ingest, process and integrate data from both accelerometers and velocity sensors, so a monitoring system can be configured around whichever data type, or both, best matches its objectives. The choice depends on the events you target, proximity to the source and budget rather than any software limitation.

What problems arise when integrating acceleration to velocity?

Deriving velocity from acceleration requires numerical integration, and that process amplifies low-frequency errors caused by baseline drift and noise in the accelerometer record. The result can be unreliable at long periods unless careful baseline correction and filtering are applied, which is one reason broadband seismometers are preferred when low-frequency content matters.

Should a seismic network use both accelerometers and seismometers?

Many advanced seismic monitoring systems deploy both sensor types to combine their strengths: accelerometers for strong near-field shaking and PGA, broadband seismometers for low-noise detection of small and distant events. This hybrid approach gives a more complete picture of seismic activity and more robust event detection, at the cost of additional equipment.

Need help with a project? QuakeLogic designs and supplies seismic monitoring, earthquake early warning, structural health monitoring, infrasound, and shake table systems. Browse QuakeLogic products or contact our engineering team with your site, structure, or test requirements.