The ESP32 board has access to the NTP server (Network Time Protocol) through Internet which can be used to get timestamps (UNIX timestamp) with a precision within a few milliseconds.Following the below steps you'll be able to send data with NTP timestamp to AskSensors through MQTT.
- Active AskSensors account: Subscribe to a 15 days free trial(SIMPLE, PRO or GURU).
- Create a new sensor. For additional details on how to setup a sensor, simply click here and follow the simple process.
- Follow these steps to get familiar with AskSensors.
- Install the NTP Client library for the Arduino IDE: Navigate to the Sketch > Include Library > Manage Libraries. Wait for Library Manager to download libraries index and updated list of installed libraries.Filter your search by typing ‘ntpclient’. There should be a couple entries. Look for NTPClient by Fabrice Weinberg. Click on that entry, and then select Install.
- Install the MQTT PubSubClient Library for the Arduino IDE.
- Download this demo from the AskSensors Github page.
- Modify Your WIFI SSID and password and The Api Key In and username to set the MQTT Topic:username/apiKeyIn
- Connect your ESP32 board to the computer via serial/USB and upload the code using the Arduino IDE.
- Check your Sensor data stream timestamps on your AskSensors workspace.
- Open a serial terminal. You can cross-check the AskSensors graph readings with the values being printed on your ESP32 Terminal.
Comments