Introduction: Uploading Vibrational Sensor Value to IOT ThingSpeak Using NodeMCU
There are several critical machines or expensive equipments which suffer damages due to vibrations. In such a case, a vibration sensor is required to find out whether the machine or equipment is producing vibrations or not. Identifying the object which is continuously vibrating is not a tricky job if the proper sensor is used to detect the vibration. There are several types of vibration sensors available in the market which can detect the vibration by sensing acceleration or velocity and could provide excellent result. However, such sensors are too expensive where the accelerometer is used.
In this project, Connect NodeMCU with Vibration sensor and LED. When no vibration is detected, Vibration sensor output is 0 (low voltage),otherwise its output is 1(high voltage). This voltage can be read using PWM pin. If NodeMCU get 0 (no vibration) from vibration sensor it will turn on green LED and turn off Red LED. If NodeMCU get 1 from vibration sensor, it will turn on Red LED and turn off green LED. Here using PWM pins the sensor value is read as analog and giving range for blinking the led.
ThingSpeak is an Open-Source IoT application and API to store and retrieve data from Hardware devices and Sensors. It uses HTTP Protocol over the Internet or LAN for its communication. The MATLAB analytics is included to analyze and visualize the data received from your Hardware or Sensor Devices.
We can create channels for each and every sensor data. These channels can be set as private channels or you can share the data publically through Public channels. The commercial features include additional features. But we will be using the free version as we doing it for educational purpose.
(If you want to learn more about the ThingSpeak in general, and/or The Project, visit https://www.instructables.com/)
- Collect data in private channels
- .Share Data with Public Channels
- REST API and MQTT APIS
- MATLAB® Analytics and Visualizations.
- Worldwide Community
In this tutorial, using an LM393 Vibrational sensor to plot its value on ThingSpeak using NodeMCU. In this program the NodeMCU to read and store the sensor data into a variable and then upload it to ThingSpeak using its channel name and API key. The NodeMCU should be connected to the internet via Wi-Fi. We will see how to create ThingSpeak Channels and configure it on NodeMCU.
Step 1: Components Required
- LM393 Vbrational Sensor
- Jumper Wires
1.NodeMCU LUA WiFi Internet ESP8266 Development Board :NodeMCU Dev Kit/board consist of ESP8266 wifi enabled chip. The ESP8266 is a low-cost Wi-Fi chip developed by Espressif Systems with TCP/IP protocol. For more information about ESP8266, you can refer ESP8266 WiFi Module.
LM393 Vibration Sensor Module : It can detect the vibration of the surrounding environment.Sensitivity is adjustable by the blue digital potentiometer adjustment.It's operating voltage ranges from 3.3V-5V. Output formis digital (0 and 1).
Jumper Wires: Jumper wires are simply wires that have connector pins at each end, allowing them to be used to connect two points to each other without soldering. Female to female connector is used in this project.
Step 2: Connecting Components
There 3 leads are +5V, , DOUT, and GND.The +5V and GND leads establishes power for the Vibration sensor.The other one is the DOUT (digital out).
The +5V and GND leads establishes power for the vibration sensor. The other lead is DOUT (digital output). How the sensor works is the terminal DOUT gives voltage output in proportion to the amount of vibration the sensor detects. The digital value is read by using PWM pin in NodMCU.The more vibration it detects, the greater the analog voltage it will output. Conversely, the less it detects, the less analog voltage it will output. If the analog voltage reaches a certain threshold, it will send a sginal to the led pins and according to the condition red and green led blinks.
To connect the sensor, there are 3 leads. The +5V terminal of the sensor connects into the 5V terminal of the NodeMCU. The GND terminal of the sensor connects into the GND terminal of the NodeMCU. This establishes power for the sensor. The other connection is the digital output of the sensor. It is connect to PWM pin D0 of the NodeMCU.
Step 3: Procedure
Step 1: Go to https://thingspeak.com/ and create your ThingSpeak Account if you don’t have. Login to Your Account.
Step 2: Create a Channel by clicking ’New Channel
Step 3: Enter the channel details. Name: Any Name Description: Optional Field 1: Sensor reading – This will be displayed on the analytics graph. If you need more than 1 Channels you can create for additional Sensor Data. Save this setting.
Step 4: Now you can see the channels. Click on the ‘API Keys’ tab. Here you will get the Channel ID and API Keys. Note this down.
Step 5: Open Arduino IDE and Install the ThingSpeak Library. To do this go to Sketch>Include Library>Manage Libraries. Search for ThingSpeak and install the library. ThingSpeak Communication Library for Arduino, ESP8266 and ESP32 https://thingspeak.com
Step 4: The Code
Download the code attached here and upload it on your board, and wire everything as shown in previous diagram.
The output will be like above image in ThingSpeak. Hope this made it easier for you. Be sure to subscribe if you liked this article and found it useful, and if you have any questions or need help with anything, just leave a comment below…
Thanks to elemetnzonline.com..