Summary
As a part of my predictive maintenance exercises, I have started using motor usage to collect data and to perform anomaly detection. As a first step, I have decided to release a simple version of data generator using motor. Motor will be controlled by ESP32 MCU, which will receive commands from Thingsboard server. The forward/backward/resting position along with speed set will be recorded and saved in postgresDB. The code and dashboard template are available in GitHub repository. I am really excited to present my current project as an entry for world in motion contest. Hope you all will like it.
Hardware requirement
- L293D motor driver
- DC gear motor
- ESP32 (I have used ESP wroom32)
- Jumper cables
- breadboard
Software requirement
- Arduino IDE
- Thingsboard server (self-hosted or use trial version
Connection
ESP32 L293D MOTOR
18 IN1
19 IN2
4 ENA ENA
OUT1 M+
OUT2 M-
Creating a device in Thingsboard
- Log into your thingsboard account. On left side, you’ll “Devices” option. Select that option.
- Click the “+” on right side to create a new device. Give it a name and select “Credentials”.
- Enter a non-easily recognisable password and make sure to note it down somewhere safe. Once done, click “add”.
Creating a dashboard
- On left side, select “Dashboards”. Import the json file available in GitHub repository.
- Once imported make sure to replace the device ID with the one you have created by editing the widgets.
Programming the ESP32 MCU
- Install the ESP32 package for Arduino.
- Install ThingsBoard & arduinojson library through library manager.
- Open the file provided in the GitHub repo.
- Replace the SSID, password, server IP and device credentials in config.h to match yours.
- Select the board according to your MCU and upload the code
Data generation
- On the dashboard you’ll greeted with multiple widgets. Use the knob widget to set the speed. Backward/Forward/halt are self-explanatory. The charts will show the state diagram of motor at a time and the chart below will show you the speed set at that time.
- Control the motor using the widgets, the data will be automatically stored into postgresdb available by default in thingsboard server.
To be implemented
- Attach vibration sensor to pick up vibration caused by motor - especially whenever the state changes.
- The alarm widget is a placeholder for now. Severity of alarm will be calculated; alerts will be generated. Email will be sent to user when motor speed exceeds threshold.
- Perform analytics on the sensor data
Notes
- This blog is meant to be a basic intro to a multi part series. Currently the data is generated by manually pressing the widgets. In subsequent blogs, motor will be attached with a load and will be automated to move forward/backward.
- Few more parameters need to be incorporated to provide reliable analytics.
PS: If you guys know a way to measure DC motor speed using microcontroller (With and without load), please let me know.
Will meet you guys on next blog without updated version! Toodles!!