Industrial monitoring: how to get the most out of it

Take advantage of Open Source Hardware
June 18, 2020 by
Industrial monitoring: how to get the most out of it
Joan F. Aubets - Industrial Shields

Index

Like sand between your fingers

Do you remember the feeling of the sand slipping through your fingers?

For a beach day, it is perfect. But if what you are missing is concrete data of your company, you are missing out on all sorts of opportunities.

Even losing money.

Big challenges

Adapt your business to technology

One of the great challenges that companies face, as if it were a long-distance race, is the adoption of new technologies that are appearing. Although it is materially impossible to be up to date with everything, it is necessary to have a global vision of the company, and to know which technologies you can implement to obtain all kinds of benefits such as:

  • greater safety for operators,

  • improvement in production rates,

  • saving in materials or

  • Preventive Maintenance,

to name a few.

 

Uses and benefits of industrial monitoring

You can monitor the data that may be relevant to you in several ways. On the one hand, through closed solutions where you will need an external partner to be able to update, configure, repair, etc.

 On the other hand, you can choose open source solutions, where you will own the complete solution and have control of:

  • what you want to monitor

  • how often,

  • where to send or store the data, etc.

All this, at a much lower cost of acquisition, due to savings in licenses and savings in consulting and programming by a third party.

As an example of how much can be done using open source solutions, we will show some implementations of monitoring elements.

Program a DHT22 humidity and temperature sensor

Sensor Features

- 3.3V to 6V power supply.
- 2.5mA current consumption.
- Output - Digital signal.
- Temperature measurement between -40 and 125ºC, with an accuracy of 0.5ºC to 25ºC.
- Temperature measurement resolution: 8-bit, 0.1ºC
- Humidity measurement between 0 and 100%, with an accuracy of 2-5% for temperatures between 0 and 50ºC.
- Temperature measurement resolution: 8-bit, 0.1%
- Sample rate of 2 samples / s: 2Hz.
- Resistance connection with a value between 4.7K and 10K.
Program a DHT22 humidity and temperature sensor

    Industrial Arduino DHT library for use in programming. In this case, we are using the Adafruit library that you can download for free here.

    (https://github.com/adafruit/DHT-sensor-library)

    With this library, you can easily read both sensors and not worry about the communication protocol between the PLC Arduino and those sensors.

    With the already imported library, we can start programming.

    This example show you how to read humidity and temperature (Celsius and Fahrenheit).

    #include "DHT.h" #define DHTPIN 2     //Pin where is the sensor connecte

    #define DHTTYPE DHT22   // Sensor DHT22

    DHT dht(DHTPIN, DHTTYPE);

    void setup() {
    Serial.begin(9600);
    Serial.println("Loading...");
    dht.begin();
    }

    void loop() {
    delay(2000);
    float h = dht.readHumidity(); //Reading the humidity
    float t = dht.readTemperature(); //Reading the temperature in Celsius degree
    float f = dht.readTemperature(true); //Reading the temperature in Fahrenheit degrees

    //--------Sending the reading through Serial port-------------

    Serial.print("Humidity ");
    Serial.print(h);
    Serial.print(" %t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.print(" *C ");
    Serial.print(f);
    Serial.println(" *F");
    }

    Using RS-485 between two Arduino PLC Controller

    If you need communication elements, the RS-485 is common in industrial environments.

    For use between controller Arduino automation-based industrial PLC automation you can use the code that you will see below, and also keep in mind the features of the Modbus RTU protocol, which allows communication between industrial controllers, in case your project requires that type of communication.

    The following code has the function of communicating the Master and the Slave by sending the instruction to activate the relay to turn on a water pump.

    An example of Simplecomm Master communication:

    #include <RS485.h>
    #include <SimpleComm.h>
    
    // Create SimplePacket for sending and receiving data
    SimplePacket packet;
    
    // Define master address
    uint8_t masterAddress = 0;
    
    // Define slave address to communicate with
    uint8_t slaveAddress = 1;
    
    // Value to send as packet data
    int value = 5;
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    void setup() {
    	Serial.begin(9600L);
    
      // Start RS485
      RS485.begin(19200L);
      RS485.setTimeout(20);
    
      // Start SimpleComm
      SimpleComm.begin(masterAddress);
    }
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    void loop() {
      static unsigned long lastSent = millis();
    
      // Send packet periodically: once per second
      if (millis() - lastSent >= 10000) {
        // Set request packet data
        packet.setData(value);
    
        // Send request to slave
        if (SimpleComm.send(RS485, packet, slaveAddress)) {
          lastSent = millis();
    
          Serial.print("Sent value: ");
          Serial.println(value);
        }
      }
    
      // Get responses
      if (SimpleComm.receive(RS485, packet)) {
        // Update value from the response
        value = packet.getInt();
    
        Serial.print("Received value: ");
        Serial.println(value);
      }
    }

    An example of Simplecomm Slave communication:

    #include <RS485.h>
    #include <SimpleComm.h>
    
    // Create SimplePacket for sending and receiving data
    SimplePacket request;
    SimplePacket response;
    
    // Define slave address to communicate with
    uint8_t slaveAddress = 1;
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    void setup() {
    	Serial.begin(9600L);
    
      // Start RS485
      RS485.begin(19200L);
      RS485.setTimeout(20);
    
      // Start SimpleComm
      SimpleComm.begin(slaveAddress);
    }
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    void loop() {
      // Get requests
      if (SimpleComm.receive(RS485, request)) {
        int value = request.getInt();
    
        Serial.print("Received value: ");
        Serial.println(value);
    if ( value==5){
      digitalWrite(R0_8,HIGH);
      delay(5000);
      digitalWrite(R0_8,LOW);
      
    }
        // Process value
        //value++;
    
        // Send response to the request packet source
        response.setData(value);
        if (SimpleComm.send(RS485, response, request.getSource())) {
          Serial.print("Sent value: ");
          Serial.println(value);
        }
      }
    }

    Improve and implement your monitoring 

    If you bet on industrial automation and want to be the owner of your equipment avoiding the payment of licenses and saving on consulting, contact us.

    Our technical-commercial team will help you determine which solution best suits your needs. Control of your company, just one click away.

    We are waiting for you.

    If you still have some questions regarding monitoring solutions, contact us!

    We will help you find the best monitoring solution.

    Share this post on your favorite social media


        

    ​Search in our Blog

    Industrial monitoring: how to get the most out of it
    Joan F. Aubets - Industrial Shields June 18, 2020

    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 >>>