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
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
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.
Industrial monitoring: how to get the most out of it