How to install PostgreSQL in Raspberry Pi PLC
Store your Industrial Application in a Postgres database of your industrial Raspberry PLC
9 November, 2021 by
How to install PostgreSQL in Raspberry Pi PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

When running an industrial application, there is always some data that we would like to store in order to analyze. 

In this blog post, we will do the following:

We are going to create a database in PostgreSQL to store data with Node-RED by using a industrial Raspberry Pi PLC!

Latest Posts

DATABASES

Databases are a collection of organized information that can easily be accessed, managed updated and deleted.

Database systems are very important for companies since they allow to the storage of relevant information useful in the future for later analysis.

Odoo • Text and Image
Odoo • Image and Text

POSTGRES

Some examples of open-source databases are:

  • PostgreSQL

  • MariaDB

  • MongoDB

  • SQLite

  • Cassandra

  • CockroachDB

  • Neo4j

In this blog post, we will be using PostgreSQL as it is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. 

For this, we are going to follow these steps:

1. Update and upgrade the system packet manager.
sudo apt update
sudo apt upgrade

2. Install PostgreSQL.
sudo apt install postgresql

3. Change to the postgres user
sudo su postgres

4. Create a new role for our pi user
createuser pi -P --interactive
During this process, you will be prompted to answer some details.

5. Load up the command line interface of psql.
psql

6. Now, create a database called as you want. In our case: isdb.
CREATE DATABASE isdb;

7. Connect to the database:
\connect isdb;

8. Create a table called as you want, in our case is_table, with the row names, and its datatype.
CREATE TABLE is_table (name text, data text);

9. Insert into the table, the values you want to store like:
INSERT INTO is_table VALUES ('IS_user','My example data');

10. Once the values were inserted, let's check the data in our database:
SELECT * FROM is_table;

PostgreSQL - How to install PostgreSQL in Raspberry PLC

👉 Now, you will be ready to store data in your Raspberry Pi PLC controller in order to analyze all the parameters of your open-source project! 
How to install PostgreSQL in Raspberry Pi PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
9 November, 2021
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!