Project in progress
Equipment Efficiency with IBM Watson

Equipment Efficiency with IBM Watson © LGPL

This project focused on the calculation of machine efficiency along with various parameters visualized on IBM Watson IoT platform.

  • 1,194 views
  • 3 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

This project focused on the calculation of machine efficiency along with various parameters visualized on IBM Watson IOT platform. Data acquisition was done by sensors at the edge level and using those data several parameters were calculated, viz. run-time, down-time, machine availability. The sensor used in this project is the hall effect sensor that concluded the run-time of the machine. Data was pushed to the platform through MQTT protocol from the node-MCU.

Code

Node MCU code to push data to IBM WatsonC/C++
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
int data;

#include <ESP8266WiFi.h>
#include <PubSubClient.h> 

//-------- Customise these values -----------
const char* ssid = "SSID";
const char* password = "Password";

#define ORG "ORGID"
#define DEVICE_TYPE "nodemcu"
#define DEVICE_ID "node"
#define TOKEN "Authtoken"
//-------- Customise the above values --------

char server[] = ORG ".messaging.internetofthings.ibmcloud.com";
char authMethod[] = "use-token-auth";
char token[] = TOKEN;
char clientId[] = "d:" ORG ":" DEVICE_TYPE ":" DEVICE_ID;

const char eventTopic[] = "iot-2/evt/status/fmt/json";
const char cmdTopic[] = "iot-2/cmd/led/fmt/json";

#define Switch A0
#define LED D2

String spd,rt,mst,bt,ma,up,dn;//ch
unsigned long btet=0,rtet=0,btStartTime,rtStartTime;
unsigned long utet=0,dtet=0,utStartTime,dtStartTime;//ch

WiFiClient wifiClient;
void callback(char* topic, byte* payload, unsigned int payloadLength) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < payloadLength; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();


}
PubSubClient client(server, 1883, callback, wifiClient);

int publishInterval = 5000; // 5 seconds//Send adc every 5sc
long lastPublishMillis;

void setup() {
  Serial.begin(9600);
  s.begin(9600);
  pinMode(LED, OUTPUT);
  pinMode(Switch, INPUT);
  
  wifiConnect();
  mqttConnect();
}

void loop() {
  spd=Speed();
  mst=machst();
  
  btStartTime = millis();
  if(data<10 or mst=="OFF")
  {
    utet=0;//ch
    
    delay(1000);
    }
    
  btet =btet+(millis() - btStartTime);//ch
  dtet =dtet+(millis() - btStartTime);//ch
  

  dn=String(dtet/60000);//ch
  bt=String(btet/60000);

  rtStartTime = millis();
  if(data>10 and mst=="ON")
  {

    dtet=0;//ch
    
    delay(1000);
    }
    
  rtet =rtet+(millis() - rtStartTime);//ch
  utet =utet+(millis() - rtStartTime);//ch
  
  

  up=String(utet/60000);
  rt=String(rtet/60000);
 
  float irt=float(rtet);
  float ibt=float(btet);
  
  float eff=(float(irt-ibt)/irt)*100.0;
  ma=String(eff);
  
  
    Serial.println(" speed "+spd+" machine status "+mst+" bt "+bt+" rt "+rt+" Machine Availability "+ma+" Uptime "+up+" Downtime "+dn);//ch
delay(500);

  //IBM platform hosting
  if (millis() - lastPublishMillis > publishInterval) {
    publishData();
    lastPublishMillis = millis();
  }

  if (!client.loop()) {
    mqttConnect();
  }
  
}

void wifiConnect() {
  Serial.print("Connecting to "); Serial.print(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.print("nWiFi connected, IP address: "); Serial.println(WiFi.localIP());

}

void mqttConnect() {
  if (!!!client.connected()) {
    Serial.print("Reconnecting MQTT client to "); Serial.println(server);
    while (!!!client.connect(clientId, authMethod, token)) {
      Serial.print(".");
      delay(500);
    }
    if (client.subscribe(cmdTopic)) {
      Serial.println("subscribe to responses OK");
    } else {
      Serial.println("subscribe to responses FAILED");
    }
    Serial.println();
  }
}

String Speed()
{
  if (s.available()>0)
  {
    data=s.read();
    //Serial.println(data);
  }
  return(String(data));
}

String machst()
{
  if(analogRead(Switch)>900)
  {
    digitalWrite(LED,HIGH);
    return("ON");
  }
  if(analogRead(Switch)<200)
  {
    digitalWrite(LED,LOW);
    return("OFF");
    
  }
  
}


void publishData() {


  String data = "{";
  data+="\n";
  data+= "\"d\": {";
  data+="\n";
  data+="\"gau\": \"";
  
  data=data+spd+"\"," ;//get speed
  
  data+="\n";
  data+="\"st\": \"";
  
  data=data+mst+"\"," ;//get machine status
  
  data+="\n";
  data+="\"rt\": \"";
  
  data=data+rt+"\"," ;//get run time
  
  data+="\n";
  data+="\"bt\": \"";
  
  data=data+bt+"\"," ;//get breakdown time
  
  data+="\n";
  data+="\"av\": \"";
  
  data=data+ma+"\"," ;//calculate machine availability 

  data+="\n";
  data+="\"up\": \"";

  data=data+up+"\"," ;//up time

  data+="\n";
  data+="\"dn\": \"";

  data=data+dn+"\"" ;//down time
  
  data+="\n";
  data+="}";
  data+="\n";
  data+="}";

  Serial.print("Sending payload: "); Serial.println(data);

  if (client.publish(eventTopic, (char*) data.c_str())) {
    Serial.println("Publish OK");
  } else {
    Serial.println("Publish FAILED");
  }
}
ARDUINO Code for HALL Sensor and serial interface with node MCUC/C++
#include <SoftwareSerial.h>
SoftwareSerial s(5,6);

volatile byte revolutions;

unsigned int rpmilli;
float speed;

unsigned long timeold;

void setup()
{
Serial.begin(9600);
s.begin(9600);
attachInterrupt(0, rpm_fun, RISING);

revolutions = 0;
rpmilli = 0;
timeold = 0;
}

void loop()
{
if (revolutions >= 1) {

rpmilli = revolutions/(millis()-timeold);

timeold = millis();
revolutions = 0; 
rpmilli=rpmilli *1000;
s.write(int(rpmilli));
Serial.print("RPM:");
Serial.print(rpmilli);

}
}

void rpm_fun()
{
revolutions++;
}

Schematics

Circuit Diagram
Circuit zjq5gy3hco
IBM Watson Platform UI
Platform ui esfpeakgi1

Comments

Created by

Pratik Roy

Are you Pratik Roy? Claim this project and add it to your profile.

This is mine

Posted by

 aozzi5nbfw
Pratik_Roy98
  • 0 projects
  • 2 followers

Published on

December 17, 2019

Members who respect this project

DefaultHorde logo sw u1wn0ivlcl

and 3 others

See similar projects
you might like

Similar projects you might like

Atmospheric Air Analyser

Project in progress by Tejas Shah and Kavyashree P

  • 5,682 views
  • 7 comments
  • 28 respects

Arduino-ESP WiFi Integration

Project in progress by Turai Botond

  • 11,475 views
  • 11 comments
  • 56 respects

Continuous Erosion

Project showcase by Julian Hespenheide

  • 2,202 views
  • 1 comment
  • 4 respects

Fitness Tracker Using POV Display

Project showcase by sayinath karuppanan

  • 2,924 views
  • 0 comments
  • 5 respects

Hot Air Balloon or Weather Satellite Navigation System

Project tutorial by Patel Darshil

  • 2,675 views
  • 0 comments
  • 16 respects

Embedis: Project Keystore Library

by thingSoC

  • 2,170 views
  • 1 comment
  • 8 respects
Add projectSign up / Login