Step-by-step programming for gas leakage detection
- Arduino Uno
- Arduino Uno Grove Board
- MQ2 LPG Gas Sensor
- ESPRESSIF ESP-01
- 2.2 KILOHM RESISTOR
- 1 KILOHM RESISTOR
- GREEN LED
- RED LED
- JUMPER WIRE (FEMALE TO FEMALE)
- JUMPER WIRE (FEMALE TO MALE)
- JUMPER WIRE (MALE TO MALE)
- MALE HEADER
- ESPRESSIF ESP-01 FEMALE HEADER
- VERO BOARD
- SOLDERING KIT
- SOLDERING LED
- SOLDERING WIRE
- LAPTOP
- ARDUINO UNO IDE
- GROVE BOARD CONNECTORS
- BUZZER
- ESP-01 ADAPTER
We are using the Thingsboard demo IoT platform.
Step 1:Provision Device
- Login to demo.thingsboard.io and click on "Devices" on the side menu
- In the devices page, click on the "+" icon to create a new device
- Input the name of your choice for the device, then click "add"
Step 2: Connect Device
-
Get the device credentials. Click on the new device you created, on the resulting window, click on "copy access token" and paste
-
To connect, we will send telemetry. Which means, send data to the platform. There are different protocols for sending data. You can send data via HTTP, MQTT, MODBUS, LORAWAN etc. We will be using HTTP.
-
On command prompt, write this command: curl -v -X POST -d "{"Gas level": 25}" $THINGSBOARD_HOST_NAME/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"
$THINGSBOARD_HOST_NAME = demo.thingsboard.io $ACCESS_TOKEN = the token you copied from step 2
-
Press enter.
-
On the devices window, click on your device, in the resulting window, click on "latest telemetry", you will see the information that you just sent.
Step 3: Create Dashboard:
3.1: Create empty dashboard:
- Open the dashboard page, click the "+" icon in the top right corner. Select "Create New Dashboard"
- Input dashboard name as the one you wish, then click "Add" to add the dashboard
- Click on the new dashboard you created. On the resulting page, click on the "Open Dashboard" button
3.2: Add entity alias:
- On the bottom right corner of the page resulting from the click of the "Open Dashboard" button, you will see a pencil icon. Click on it to enter edit mode
- Click on entity aliases. It is the next icon after the gear icon on the top of this window
- Click "Add alias"
- Input alias name, for example, "MyDevice". Select the "Single entity" Filter type. Select "Device" as Type and type "My New" to enable autocomplete. Choose your device from the auto-complete and click on it.
- Click "Add" and then "Save".
- Finally, click "Apply changes" in the dashboard editor to save the changes. Then you should enter edit mode again.
3.3: Add table widget
- Enter edit mode. Click on the "Add new widget" button.
- Select the "Cards" widget bundle. Select the "Latest values" tab. Click on the header of the Entities widget. The "Add Widget" window will appear.
- Click "Add" to add the data source. A widget may have multiple data sources, but we will use only one in this case.
- Select "MyDevice" entity alias. Then click on the input field on the right. The auto-complete with available data points will appear. Select "temperature" data point and click "Add".
- Resize the widget to make it a little bigger. Just drag the bottom right corner of the widget. You can also play with the advanced settings if you would like to edit the widget.
3.4: Add Chart Widget
- Enter Edit mode.
- Click the "Add new widget" icon in the bottom right corner of the screen.
- Click the "Create new widget" icon.
- Select the "Charts" bundle. Scroll down and click on the "Timeseries - Flot" chart widget.
- Click the "Add Datasource" button.
- Select "MyDevice" Alias. Select the "temperature" key. Click "Add".
- Drag and Drop your widget to the desired space. Resize the widget. Apply changes.
- Publish different telemetry values multiple times Step 2. Note that the widget displays only one minute of data by default.
- Enter Edit mode. Open time selection window. Change the interval and aggregation function. Update the time window and apply changes.