Tunir Das
Published

IoT and ML based Electrical Fault Predictor using Bolt IoT

Predict faults in electrical equipment using Internet of Things and Machine Learning.

IntermediateFull instructions provided1.5 hours1,811
IoT and ML based Electrical Fault Predictor using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LM 35 Temperature Sensor
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Resistor 330 ohm
Resistor 330 ohm
×1
5 mm LED: Red
5 mm LED: Red
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Male/Male Jumper Wires
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App
Bolt Cloud
Bolt IoT Bolt Cloud
Mailgun
VMware Workstation 12 Player

Story

Read more

Schematics

System Schematics

Schematic Diagram of the Hardware Connection using Fritzing.

Code

Temp_Alert_Electrical_Equipment.py

Python
The main python code has been named as Temp_Alert_Electrical_Equipment.py. this code is responsible for checking temperaure every 1 minute, compaqring sensor value with threshold and sending out an alert if threshold value is breached.
import json
import config
import time
from boltiot import Email, Bolt
max_temp_sensor_value=300
mybolt = Bolt (Configuration.bolt_api_key, Configuration.bolt_device_id)
mailer=Email(Configuration.MAILGUN_API_KEY,Configuration.SANDBOX_URL,Configuration.SENDER_EMAIL, Configuration.RECIPIENT_EMAIL)
while True: 
  print ("Reading sensor value")
  response = mybolt.analogRead('A0') 
  data = json.loads(response) 
  print ("Sensor value is: " + str(data['value']))
  try: 
    sensor_value = int(data['value']) 
    if sensor_value > max_temp_sensor_value:
      response=mybolt.digitalWrite ('0','HIGH')
      print(response)
      print("Making request to Mailgun to send an email")
      response = mailer.send_email("Alert! Check for Fault", "The Current temperature sensor value is " +str(sensor_value))
      response_text = json.loads(response.text)
      print("Response received from Mailgun is: " + str(response_text['message']))
  except Exception as e: 
    print ("Error occured: Below are the details")
    print (e)
  time.sleep(60)

JavaScript Code

JavaScript
The JavaScript code for plotting and predicting the temperature readings w.r.t time, to be written in Product Configuration in Bolt Cloud is given as (Screenshot of Code Tab: Figure 7):
setChartLibrary ('google-chart');
setChartTitle ('IoT based Online Temperature Monitoring for Electrical Equipment');
setChartType('predictionGraph');
setAxisName('time_stamp','temp');
mul (0.0977);
plotChart('time_stamp','temp');

Configuration.py

Python
We store all the credentials in a separate file since it is sensitive data which should not be shared with anyone. Hence it is a good practice to avoid using credentials in code directly. I have named the file storing the credential data as Configuration.py.
""" MAILGUN CONFIGURATION """  
MAILGUN_API_KEY = "You can find in your Mailgun dashboard"
SANDBOX_URL = "You can find in your Mailgun dashboard “ 
SENDER_MAIL = "Mail Address of Mailgun." 
RECIEVER_MAIL = "Write Your mail" 
""" BOLT IOT CONFIGURATION """  
bolt_api_key = "This is your Bolt Cloud account API key"
bolt_device_id = "This is the ID of your Bolt device"

Credits

Tunir Das

Tunir Das

3 projects • 5 followers
YouTube: https://www.youtube.com/channel/UCqUo_xeyKlJ8mN1cT7zjQ6Q?

Comments