Showing posts with label sensors. Show all posts
Showing posts with label sensors. Show all posts

Tuesday

OTA with Ubuntu Core

 


IoT (Internet of Things): IoT refers to the interconnection of everyday objects, devices, and appliances to the internet, allowing them to collect and exchange data. These objects, often embedded with sensors and communication hardware, can include everything from smart thermostats and wearable fitness trackers to industrial machines and autonomous vehicles. IoT enables these devices to transmit data, receive commands, and interact with other devices or centralized systems, often with minimal human intervention. Whether it’s smart cities, wearable technology, robotics, autonomous vehicles, or any other new and emerging IoT sector, network connectivity is central to IoT’s advancement.

OTA (Over-the-Air) Updates: OTA updates are a method of remotely delivering software updates and patches to devices or systems connected to the internet. This process allows for the seamless and efficient deployment of updates to devices without requiring physical access or manual intervention. OTA updates are commonly used in IoT, among other applications, for several important reasons:

1. Remote Accessibility: Many IoT devices are deployed in remote or hard-to-reach locations, making it impractical to update them manually. OTA updates eliminate the need for physical access to these devices.

2. Efficiency: OTA updates can be delivered in a more efficient manner, often transmitting only the changes or "deltas" between the current and updated software versions. This reduces bandwidth and time requirements.

3. Security: IoT devices often need security patches and updates to protect against vulnerabilities. OTA updates enable the timely delivery of these critical security fixes, reducing the risk of cyberattacks.

4. Bug Fixes and Improvements: IoT devices may experience software bugs or require feature enhancements. OTA updates provide a mechanism for delivering bug fixes and new features to improve device performance and functionality.

5. Cost Reduction: Implementing OTA updates can reduce operational costs associated with manual updates, such as sending technicians to remote locations or recalling devices for updates.

6. User Experience: For consumer IoT devices, OTA updates enhance the user experience by ensuring that devices are always running the latest and most reliable software.

In summary, IoT involves connecting everyday objects to the internet to collect and exchange data, while OTA updates are a crucial tool for remotely delivering software updates to IoT devices. They are essential for ensuring device security, efficiency, and functionality, especially in scenarios where manual updates are impractical or costly.

Ubuntu Core: A secure and reliable IoT operating system

Ubuntu Core is a lightweight, secure, and reliable operating system designed for IoT and embedded devices. It is based on Ubuntu, one of the most popular Linux distributions, and uses snaps for software packaging. Snaps are self-contained packages that include all of the dependencies needed to run an application, making them easy to install and update.

Ubuntu Core is ideal for IoT devices because it is small and efficient, uses minimal resources, and is very secure. It also has a long support lifecycle, which means that devices will continue to receive security updates for many years.

Snaps: A secure and reliable way to package IoT software

Snaps are a secure and reliable way to package and distribute IoT software. They are self-contained packages that include all of the dependencies needed to run an application, making them easy to install and update. Snaps are also isolated from each other and from the base operating system, which helps to improve security and stability.

For IoT devices, snaps can be distributed through a private Snap Store, or IoT App Store. This allows software vendors to distribute their software directly to their customers, without having to go through a third-party app store.

Benefits of using Ubuntu Core and snaps for IoT devices

There are many benefits to using Ubuntu Core and snaps for IoT devices, including:

Security: Ubuntu Core is a very secure operating system, and snaps are isolated from each other and from the base operating system, which helps to improve security even further.

Reliability: Ubuntu Core is a very reliable operating system, and it has a long support lifecycle, which means that devices will continue to receive security updates for many years.

Ease of use: Snaps are easy to install and update, and they can be distributed through a private Snap Store, or IoT App Store.

Efficiency: Ubuntu Core is a lightweight and efficient operating system, which makes it ideal for IoT devices with limited resources.

Overall, Ubuntu Core and snaps are a powerful combination for IoT devices. They offer a secure, reliable, and easy-to-use platform for developing and deploying IoT applications.

However, it is not fully free. For developer personal use it is free. For commercial use the free tier enables you to ship Ubuntu Core free of charge and receive unscheduled updates when bandwidth allows, or on-demand for emergencies.

For the first 20 devices, you can test Ubuntu Core free of charge and receive unscheduled updates.


Screenshots taken from Ubuntu

Let's discuss the challenges associated with delivering consistent, reliable, and robust software updates to low-powered, inaccessible, and remotely administered embedded IoT devices. It highlights the solutions provided by Ubuntu Core and snaps at overcoming these challenges. 

Here's a summary of the key points:

1. Introduction to the Challenges: Delivering software updates to IoT devices, given their remote and often inaccessible locations, is a significant challenge. The growth of IoT devices and data generation amplifies this challenge.

The extensive connectivity inherent in IoT devices brings with it a significant responsibility: the imperative to ensure devices remain updated, patched, and secure. This onus primarily rests on the choice of update and delivery mechanisms adopted by IoT vendors.

In the past, there were only a few ways to handle failed updates or software regressions in industrial automation systems:

Send engineers to affected sites: This is a costly and time-consuming option, and it is not always feasible, especially for systems with a large number of devices or devices that are located in remote areas.

Recall the devices: This is also a costly and time-consuming option, and it can disrupt production.

Remotely update each device individually: This is a time-consuming and error-prone option.

These options are no longer sufficient for the needs of modern industrial automation systems. Today, there are more sophisticated tools and techniques that can be used to handle failed updates and software regressions in a more efficient and effective way.

2. Historical Update Problems: Traditional update mechanisms often involve replacing files and binaries on the system, which can lead to system impairments if anything goes wrong during the update process. Recovering from failed updates or faulty updates is resource-intensive and not scalable.

Over the course of many decades, updates and their corresponding management systems have consistently superseded existing files and binaries within a system. Often, these updates form intricate and interdependent chains. In cases where issues arise, such as software bugs, power outages, or filesystem problems, the system's functionality becomes compromised. Addressing these challenges typically necessitates costly expert interventions for recovery.

An even more complex issue emerges when the update process itself proceeds as planned, but the update contains faults that require reversion. Resolving this problem proves challenging in traditional systems. It involves the retrieval of an older version from a package repository and its installation over a malfunctioning system, often requiring specialized scripts from a package maintainer.

3. Requirements for an Effective Update Solution: An effective update solution for IoT devices should include features like automated updates, mechanisms for update recovery, provisions for critical updates, and redundancy to handle unforeseen situations.

4. Ubuntu Core and Snaps: Ubuntu Core, designed for IoT and embedded devices, uses snaps as a secure, dependency-free packaging system. Snaps can be containerized, ensuring separation between the base system and applications. Updates are transactional, meaning they are only installed if successful, and recovery mechanisms are in place.

5. Security: Security is a significant concern for IoT devices, and Ubuntu Core's design ensures security by using immutable foundations, confined applications through snaps, and a read-only filesystem.

6. Update Mechanics and Recovery: Ubuntu Core delivers updates as deltas to save bandwidth, ensuring that updates are transferred efficiently. If an update fails, the system can be rolled back to the previous working state. The document explains how snaps enable parallel installations and epoch-based updates.

7. System Maintenance: Maintenance is crucial for system functionality. Good design, read-only filesystems, and encapsulation of data within snaps help minimize maintenance requirements.

8. Streamlined CI/CD Process: Ubuntu Core offers a streamlined CI/CD process for snap creation and publishing, with channels, tracks, and branches to manage stability expectations.

9. Advantages of Ubuntu Core and Snaps: The document highlights that Ubuntu Core and Snaps provide a solution that simplifies and ensures confidence in software updates for IoT devices, regardless of deployment scale or update frequency.

Overall, Ubuntu Core and Snaps address the complex challenges of updating software on IoT devices, providing reliability, security, and efficiency in the process.


Photo by Cemil Aybaci

SCADA

 



SCADA stands for Supervisory Control and Data Acquisition. It is a system that is used to monitor and control industrial processes. SCADA systems are used in a wide variety of industries, including manufacturing, power generation, and oil and gas.

A SCADA system typically consists of a number of different components, including:

  • Sensors: Sensors are used to collect data about the industrial process, such as temperature, pressure, and flow rate.
  • PLCs (Programmable Logic Controllers): PLCs are used to control the industrial process based on the data collected by the sensors.
  • HMI (Human-Machine Interface): The HMI is a computer display that allows the operator of the SCADA system to monitor and control the industrial process.

The SCADA system works by collecting data from the sensors and sending it to the PLCs. The PLCs then use this data to control the industrial process. The operator of the SCADA system can monitor the industrial process and make changes to the control settings using the HMI.

SCADA systems are used in a wide variety of industries, including:

  • Manufacturing: SCADA systems are used in manufacturing plants to monitor and control the production process.
  • Power generation: SCADA systems are used in power plants to monitor and control the power generation and distribution process.
  • Oil and gas: SCADA systems are used in oil and gas facilities to monitor and control the drilling, production, and transportation of oil and gas.

Here are some specific examples of where SCADA systems are used:

  • In a food processing plant, a SCADA system can be used to monitor and control the temperature of food products as they are being processed.
  • In a water treatment plant, a SCADA system can be used to monitor and control the levels of chemicals in the water.
  • In a power grid, a SCADA system can be used to monitor and control the flow of electricity.

SCADA systems are an essential part of modern industrial automation. They allow operators to monitor and control industrial processes from a central location, which can improve efficiency and safety.

Yes, it is possible to use digital twins with SCADA and Modbus for industry. In fact, this is a common combination of technologies that can be used to create powerful and effective industrial automation systems.

Here is a real-life example of how digital twins are being used with SCADA and Modbus in industry:

Example:

A large manufacturing plant uses a digital twin to simulate its production process. The digital twin is connected to the plant's SCADA system, which collects data from sensors throughout the plant. The digital twin then uses this data to create a real-time simulation of the production process.

The plant's operators use the digital twin to monitor the production process and identify potential problems. For example, if the digital twin shows that a machine is about to overheat, the operators can take corrective action before the machine actually overheats and shuts down.

The digital twin is also used to optimize the production process. For example, the operators can use the digital twin to experiment with different production parameters to see how they affect the output of the process. This allows the operators to find the optimal production parameters for maximum efficiency and quality.

MODBUS

 



Modbus is a serial communication protocol developed by Modicon in 1979 for use with its programmable logic controllers (PLCs). It is a simple and robust protocol that is widely used in industrial automation applications.

Modbus works by using a master-slave architecture. The master device is responsible for initiating all communications and the slave devices are responsible for responding to the master's requests. Modbus messages can be used to read or write data from the slave devices.

Modbus is a request-response protocol. This means that the master device sends a request to the slave device and then waits for the slave device to respond. The slave device then responds to the master device with the requested data or with an error message if the request was not valid.

Modbus is a very versatile protocol and can be used to communicate with a wide variety of devices, including PLCs, sensors, actuators, and other industrial devices. It is also relatively easy to implement and use, which makes it a popular choice for industrial automation applications.

Modbus is used in a variety of industrial applications, including:

  • Manufacturing
  • Process control
  • Building automation
  • Energy
  • Transportation
  • Infrastructure

Here are some specific examples of where Modbus is used:

  • In a manufacturing plant, Modbus can be used to connect PLCs to sensors and actuators to control the manufacturing process.
  • In a power plant, Modbus can be used to connect PLCs to sensors and actuators to control the power generation and distribution process.
  • In a building, Modbus can be used to connect PLCs to sensors and actuators to control the heating, ventilation, and air conditioning (HVAC) system.

Modbus is a powerful and versatile communication protocol that is widely used in industrial automation applications. It is simple to implement and use, and it can be used to communicate with a wide variety of devices.

Friday

Real-Time Data With IoT & MQTT

 

unplush

For real time data analysis we need real time data to be collected. I would like to share with you this small project for capturing real time temperature and humidity data from sensors and showing that in a local dashboard.

You can connect to the real time data analysis dashboard as well. If you are interested in how to can read my other article here.

We will collect data by temperature and humidity sensor DHT11. Which is very small and cheap. However, work perfectly.

We will be using a microcontroller Arduino with ESP8266 wifi on board. You can use Uno+WiFi R3 AtMega328p+NodeMSU ESP8266 8mb Memory USB-TTL CH340G Compatible for Arduino UNO

Also, we need a local or free MQTT broker. And node-red. Node-RED is a flow-based development tool for visual programming. It makes it easy to wire together different hardware devices, APIs, and online services to create applications. Node-RED is a great tool for developers who want to create IoT applications quickly and easily.

Here are some of the things you can do with Node-RED:

* Control hardware devices, such as lights, sensors, and motors.

* Connect to APIs, such as weather data, stock prices, or social media feeds.

* Send and receive data from online services, such as Google Cloud Platform or Amazon Web Services.

* Create dashboards and visualizations to display data.

* Automate tasks and workflows.

Node-RED is a powerful tool that can be used to create a wide variety of applications. If you are interested in IoT development, Node-RED is a great place to start.

Here are some of the benefits of using Node-RED:

  • Easy to learn and use. Node-RED is a visual programming tool, which means that you don’t need to know how to code to use it. You can simply drag and drop nodes together to create your application.
  • Flexible. Node-RED is very flexible and can be used to create a wide variety of applications.
  • Extensible. There is a large community of Node-RED users who have created a wide range of nodes that can be used in your applications.

Free and open source. Node-RED is free and open source software, which means that it is available to everyone.

MQTT stands for Message Queuing Telemetry Transport. It is a lightweight messaging protocol that is commonly used for Internet of Things (IoT) applications. MQTT is a publish/subscribe protocol, which means that devices can publish messages to topics, and other devices can subscribe to topics to receive messages.

To run MQTT locally, you will need to install an MQTT broker. An MQTT broker is a software application that manages the communication between devices that are publishing and subscribing to topics. There are many different MQTT brokers available, both open source and commercial. Some popular MQTT brokers include:

* Mosquitto

* Eclipse Paho

* HiveMQ

* ActiveMQ

Once you have installed an MQTT broker, you can start publishing and subscribing to topics. To publish a message, you need to specify the topic name and the message payload. The message payload is the actual data that you want to send. To subscribe to a topic, you simply specify the topic name.

Here is an example of how to publish a message to a topic using the Mosquitto broker:

mosquitto_pub -h localhost -t mytopic -m "Hello world!"

This command will publish the message “Hello world!” to the topic “mytopic” on the MQTT broker running on the localhost.

Here is an example of how to subscribe to a topic using the Mosquitto broker:

mosquitto_sub -h localhost -t mytopic

This command will subscribe to the topic “mytopic” on the MQTT broker running on the localhost. When a message is published to the topic “mytopic”, the mosquitto_sub command will print the message payload to the console.

MQTT is a simple and lightweight messaging protocol that is well-suited for IoT applications. It is easy to install and use, and it can be used to connect a wide variety of devices.

Hope you already installed the Arduino IDE in your system. Add the following libraries from the IDE.

  • ESP8266WiFi
  • PubSubClient
  • DHT

Connect to your microcontroller and port in IDE. Create a new sketch with this code do not forget to update your wifi username, password etc.

Upload the code to your microcontroller.

Run the mqtt server.

Run node-red to create two pub of temperature and humidity. And two subscribers for node-red dashboard. Below is the node-red flow chart for this application.

Temperature node:

{
"id": "8af3f91e138dfc7f",
"type": "mqtt in",
"z": "7c0214a9d7501627",
"name": "temp mqtt",
"topic": "sensor/temperature",
"qos": "0",
"datatype": "auto-detect",
"broker": "89cb5cc4b9d9ccc2",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 160,
"y": 120,
"wires": [
[
"91b12e2e350dc914",
"fe8591a0be99386b"
]
]
},
{
"id": "89cb5cc4b9d9ccc2",
"type": "mqtt-broker",
"name": "remote broker",
"broker": "broker.emqx.io",
"port": "1883",
"clientid": "dhiraj",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "test",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]

Humidity node:

{
"id": "62cd8fffc101abf7",
"type": "mqtt in",
"z": "7c0214a9d7501627",
"name": "humidity mqtt",
"topic": "sensor/humidity",
"qos": "0",
"datatype": "auto-detect",
"broker": "89cb5cc4b9d9ccc2",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 170,
"y": 260,
"wires": [
[
"91b12e2e350dc914",
"bb13832944ebe60a"
]
]
},
{
"id": "89cb5cc4b9d9ccc2",
"type": "mqtt-broker",
"name": "remote broker",
"broker": "broker.emqx.io",
"port": "1883",
"clientid": "dhiraj",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "test",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]

Temperature gauge node:

{
"id": "fe8591a0be99386b",
"type": "ui_gauge",
"z": "7c0214a9d7501627",
"name": "",
"group": "30b7c6cd1061cb67",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Temperature ",
"label": "Celsius ",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#00b500",
"#e60039",
"#e93407"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 650,
"y": 300,
"wires": []
},
{
"id": "30b7c6cd1061cb67",
"type": "ui_group",
"name": "Group 1",
"tab": "6cc408fc9b1895d7",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "6cc408fc9b1895d7",
"type": "ui_tab",
"name": "Tab 1",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]

Humidity gauge node:

{
"id": "bb13832944ebe60a",
"type": "ui_gauge",
"z": "7c0214a9d7501627",
"name": "",
"group": "d8f94d45e6e6f994",
"order": 0,
"width": 0,
"height": 0,
"gtype": "gage",
"title": "Humidity",
"label": "%RH",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#0ef10e",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"diff": false,
"className": "",
"x": 640,
"y": 380,
"wires": []
},
{
"id": "d8f94d45e6e6f994",
"type": "ui_group",
"name": "Group 2",
"tab": "6cc408fc9b1895d7",
"order": 2,
"disp": true,
"width": 6
},
{
"id": "6cc408fc9b1895d7",
"type": "ui_tab",
"name": "Tab 1",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]

Dashboard

I am a Software Architect | AI, Data Science, IoT, Cloud ⌨️ 👨🏽 💻

I love the learn and share knowledge. Thank you.

AI Assistant For Test Assignment

  Photo by Google DeepMind Creating an AI application to assist school teachers with testing assignments and result analysis can greatly ben...