Compressor Monitoring

by Luca Stivè in Circuits > Arduino

115 Views, 1 Favorites, 0 Comments

Compressor Monitoring

WhatsApp Image 2024-05-27 at 09.24.33.jpeg

The objective of this project is to build a device that can monitor a compressor’s temperature, pressure and sound. The data collected by the sensors is uploaded to Thingsboard and then imported into a spreadsheet.

Supplies

images wemos (1).jpg
pixelcut-export.jpeg
pixelcut-export (1).jpeg
pressure sensor.jpg

To build the device it will be necessary to use the following materials and components:

Flowchart

pixelcut-export (1).png

Once the board is connected to WiFi and the Thingsboard server, the various sensors detect the temperature, pressure and sound of the compressor. When the compressor is turned on, the sound value identified by the sensor is higher than 1000(ADC). The data then gets printed onto the Serial Monitor and sent to Thingsboard every 4 seconds. When the compressor is off, the sound value is less than 1000(ADC) and this time the data on the Serial Monitor is sent to Thingsboard every 60 seconds.

Circuit

circuito definitivo.png

The circuit was recreated on Fritzing with all the sensors. 

Casing

box.png

The circuit is contained within a plexiglass casing: its components are laser cut and pasted together with hot glue. The quotas are in centimeters.

Downloads

Structure

Compressore con circuito.jpeg
Sensore pressione.jpeg
box con circuito.png

The circuit is mounted on the compressor’s cage and attached to it via cable ties. The pressure sensor is connected to the manometer.

Code

As already mentioned, ESP32 connects to WiFi and Thingsboard. If the compressor is on, the data is sent to Thingsboard every 4 seconds, otherwise the data gets uploaded every 60 seconds:

#include <DHT.h>
#include <WiFi.h>
#include <PubSubClient.h>

unsigned long currentMillis;
long startMillis = 0;
float suond;
int pinsound = 34;
int value = 0;
float p;
int pressure = 39;
#define DHTPIN 13
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// WiFi
const char* ssid = "vallauri.docenti"; //Name WiFi
const char* password = "fossano-vallauri"; //password WiFi

// Thingsboard
const char* mqttServer = "thingsboard.cloud"; //Server Thingsboard
const int mqttPort = 1883; //Thingsboard port
const char* mqttUsername = "tVxYM9AxKNskYfXsrPCs"; //Username Thingsboard
const char* mqttTopic = "v1/devices/me/telemetry";

WiFiClient espClient;
PubSubClient client(espClient);

void connectWiFi() { // WiFi connection
Serial.println("WiFi connecting...");
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connection...");
}

Serial.println("WiFi connected");
}

void connectMQTT() { // Thingsboard connection
Serial.println("Connecting Thingsboard...");

while (!client.connected()) {
if (client.connect("ESP32Client", mqttUsername, NULL)) {
Serial.println("Connected");
} else {
WiFi.reconnect(); //WiFi reconnection;
Serial.print("Connection failed, rc=");
Serial.print(client.state());
Serial.println("repeat in 5 seconds");
delay(5000);
}
}
}

void setup() {
Serial.begin(115200);
connectWiFi();
client.setServer(mqttServer, mqttPort);
pinMode(pinsound, INPUT);
pinMode(pressure, INPUT);
dht.begin();

}

void loop() {
if (!client.connected()) {
connectMQTT();
}
long period;
p = analogRead(pressure);
p = map (p, 0, 4095, 0, 1200);
p = (p / 100);
float temperature = dht.readTemperature();
value = analogRead(pinsound);
if (value >= 1000) {
period = 4000;
} else {
period = 60000;
}
currentMillis = millis(); //Time
if (currentMillis - startMillis >= period) {
String sound = "{\"sound\":" + String(value) + "}";
String pres = "{\"pressure\":" + String(p) + "}";
String temp = "{\"temperature\":" + String(temperature) + "}";

client.publish(mqttTopic, sound.c_str()); //Publish data on Thingsboard
client.publish(mqttTopic, pres.c_str());
client.publish(mqttTopic, temp.c_str());

Serial.print("Send data to ThingsBoard: "); //Write on Serial Monitor
Serial.print(sound);
Serial.print(" ");
Serial.print(pres);
Serial.print(" ");
Serial.println(temp);

startMillis = currentMillis;
}
}

Data

ehi.png
aho.png

The data sent to Thingsboard is exported to a spreadsheet to make the necessary considerations. The compressor was monitored for one day and a time interval of 3 hours was considered for the data analysis. As can be seen from the temperaturepressure graph, as the pressure increases the temperature also increases, as demonstrated by the gas law (p V = n R T).

Even though the temperature sensor is not inside the tank, it still detects an increase in temperature since the tank, due to it being metallic, is a thermal conductor. From the sound graph, as the internal pressure increases, the noise also increases, confirming the fact that the compressor is active. 

Downloads

Conclusion

In conclusion, we’ve managed to create a device capable of monitoring the compressor, knowing when it is on and what temperature and pressure it is at. This device can be very useful for calculating the energy consumption of the compressor during its operation.