- ESP-32: The ESP32 makes it easy to use the Arduino IDE and the Arduino Wire Language for IoT applications. This ESp32 IoT Module combines Wi-Fi, Bluetooth, and Bluetooth BLE for a variety of diverse applications. This module comes fully-equipped with 2 CPU cores that can be controlled and powered individually, and with an adjustable clock frequency of 80 MHz to 240 MHz. This ESP32 IoT WiFi BLE Module with Integrated USB is designed to fit in all ncd.io IoT products.
- IoT Long Range Wireless Vibration And Temperature Sensor:IoT Long Range Wireless Vibration And Temperature Sensor are battery operated and wireless, meaning that current or communication wires need not be pulled to get it up and operating. It tracks the vibration information of your machine constantly and captures and operating hours at full resolution together with other temperature parameters. In this, we are using NCD’s Long Range IoT Industrial wireless vibration and temperature sensor, boasting up to a 2 Mile range using a wireless mesh networking architecture.
- ZigBee Coordinator Long Range Wireless Mesh Modem with USB Interface
- Arduino IDE
- PubSubClient Library
Arduino Client for MQTT
This library provides a client for doing simple publish/subscribe messaging with a server that supports MQTT.
For more information about MQTT, visit mqtt.org.
The latest version of the library can be downloaded from GitHub
The library comes with a number of example sketches. See File > Examples > PubSubClient within the Arduino application.Full API Documentation.
The library uses the Arduino Ethernet Client api for interacting with the underlying network hardware. This means it Just Works with a growing number of boards and shields, including:
- Arduino Ethernet
- Arduino Ethernet Shield
- Arduino YUN – use the included YunClient in place of EthernetClient, and be sure to do a Bridge.begin() first
- Arduino WiFi Shield - if you want to send packets greater than 90 bytes with this shield, enable the MQTT_MAX_TRANSFER_SIZE option in PubSubClient.h.
- Sparkfun WiFly Shield – when used with this library
- Intel Galileo/Edison
- ESP32The library cannot currently be used with hardware based on the ENC28J60 chip – such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an alternative library available.
The Wire library allows you to communicate with I2C devices, often also called "2 wire" or "TWI" (Two Wire Interface), can download from Wire.h
- Wire.begin()Begin using Wire in master mode, where you will initiate and control data transfers. This is the most common use when interfacing with most I2C peripheral chips.
- Wire.begin(address)Begin using Wire in slave mode, where you will respond at "address" when other I2C masters chips initiate communication.
- Wire.beginTransmission(address)Start a new transmission to a device at "address". Master mode is used.
- Wire.write(data)Send data. In master mode, beginTransmission must be called first.
- Wire.endTransmission()In master mode, this ends the transmission and causes all buffered data to be sent.
- Wire.requestFrom(address, count)Read "count" bytes from a device at "address". Master mode is used.
- Wire.available()Returns the number of bytes available by calling receive.
- Wire.read()Receive 1 byte.
Steps to send data to labview vibration and temperature platform using IoT Long Range Wireless Vibration and Temperature Sensor and ZigBee Coordinator Long Range Wireless Mesh Modem with USB Interface:
- First, we need a Labview utility application which is ncd.io Wireless Vibration and Temperature Sensor.exefile on which data can be viewed.
- This Labview software will work with ncd.io wireless Vibration Temperature sensor only.
- To use this UI, you will need to install following drivers Install run time engine from here64bit
- 32 bit
- Install NI Visa Driver
- Install LabVIEW Run-Time Engine and NI-Serial Runtime.
- Getting started guide for this product.
Uploading the Code to ESP32 Using Arduino IDE
- Download and include the PubSubClient Library and Wire.h Library.
- You must assign your unique Ubidots TOKEN, MQTTCLIENTNAME, SSID (WiFi Name) and Password of the available network.
- Compile and upload the Ncd__vibration_and_temperature.inocode.
- To verify the connectivity of the device and the data sent, open the serial monitor.If no response is seen, try unplugging your ESP32 and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code 115200.
Serial Monitor Output
Making the Ubidots Work
- Create the account on Ubidots.
- Go to my profile and note down the token key which is a unique key for every account and paste it to your ESP32 code before uploading.
- Add a new device to your Ubidot dashboard name ESP32.
- Inside device create new variable name sensor in which your temperature reading will be shown.
Now you can view the Temperature and other sensors data which was previously viewed in the serial monitor. This happened because the value of different sensor reading is passed as a string and store in a variable and publish to the variable inside device esp32.
- Create dashboard in Ubidots.
Creating Events in Ubidots
- Select Events (from the Data dropdown).
- To create a new event, click the yellow plus icon in the upper right corner of the screen.
Types of Events :Ubidots support already integrated events to allow you to send Events, Alerts, and Notifications to those who need to know, when they need to know.Ubidots' prebuilt integrations include:
1. Email notifications
2. SMS notifications
3. Webhook events - learn more
4. Telegram notifications
5. Slack notifications - learn more
6. Voice call notifications - learn more
7. Back to normal notification - learn more
8. Geofence notifications - learn more
- Then choose a device and associating variable that indicates the devices' "values."
- Now selct a thresold value for your event to trigger and compare it to device values and also select time to trigger your event.
- Establish and configure which actions are to be executed and the message to the receiver: Send SMS, Email, Webhooks, Telegrams, Phone Calls, SLACK, and webhooks to those who need to know.
- Configure the Event notice.
- Determine the activity window the events may/may not be executed.
- Confirm your Events.
Output of Event in Your Mail
Export Your Ubidots Data to Google Sheets
In this we can extract the data stored in the Ubidots cloud for further analysis.The possibilities are enormous; for instance, you could create an automatic report generator and send it to your customers every week.
Another application would be device provisioning; if you have thousands of devices to deploy, and their information is in a Google Sheet, you could create a script to read the sheet and create a Ubidots data source for every line on the file.Steps to do this-
- Create a Google Sheet and add two sheets to it with these names:
- From your Google Sheet, click on "Tools" then "Script Editor...", then "Blank Project".
- Open the Script Editor.
- Add the code below (in the code section) to the script Script.
- Done! now open your Google Sheet again and you'll see a new menu to trigger the functions.