{ "id": "6pOGYw5O3iOY1Gc6", "meta": { "instanceId": "workflow-3625acc2", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:46.229809", "updatedAt": "2025-09-29T07:07:46.229819", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production" }, "name": "Remote IOT Sensor monitoring via MQTT and InfluxDB", "tags": [ "automation", "n8n", "production-ready", "excellent", "optimized" ], "nodes": [ { "id": "4997f226-f236-4d27-bea4-904744d9ff07", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ -700, -360 ], "parameters": { "width": 340, "height": 120, "content": "MQTT trigger subscribed to a topic called wokwi-weather via a Mosquitto MQTT broker. The trigger receives the temperature and humidity payloads from a DHT22 sensor connected to a remote ESP32 microcontroller " }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "9d4f1da6-fda3-4312-a6b1-bd0ac499dde7", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ -240, -360 ], "parameters": { "height": 100, "content": "Javascript code to extract the temperature and humidity values to ensure correct JSON format for the database" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "d8f01dba-5019-457e-8c1a-99c802282fdf", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [ 140, -360 ], "parameters": { "width": 260, "height": 120, "content": "HTTP request node posts temperature and humidity data from the DHT22 sensor to the InfluxDB data bucket running on a local host {{ $env.WEBHOOK_URL }}" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "020858a6-7771-4322-8eb6-b83e99b3563d", "name": "Remote Sensor MQTT Trigger", "type": "n8n-nodes-base.mqttTrigger", "position": [ -580, -220 ], "parameters": { "topics": "wokwi-weather", "options": {} }, "credentials": { "mqtt": { "id": "xtd75tjk1hKlQOba", "name": "MQTT account" } }, "typeVersion": 1, "notes": "This mqttTrigger node performs automated tasks as part of the workflow." }, { "id": "51e6f59f-9b93-4121-8db4-7f47b929fdf5", "name": "Data ingest to InfluxDB bucket", "type": "n8n-nodes-base.httpRequest", "position": [ 200, -220 ], "parameters": { "url": "{{ $env.API_BASE_URL }}&bucket=&precision=s", "body": "={{ $json.payload }}", "method": "POST", "options": {}, "sendBody": true, "contentType": "raw", "sendHeaders": true, "headerParameters": { "parameters": [ { "name": "Authorization", "value": "Token " } ] } }, "notesInFlow": true, "typeVersion": 4.2, "notes": "This httpRequest node performs automated tasks as part of the workflow." }, { "id": "6abe1212-b128-492f-b485-401a4315fcbc", "name": "Payload data preparation node", "type": "n8n-nodes-base.code", "position": [ -180, -220 ], "parameters": { "jsCode": "// Try to parse the incoming message as JSON\nlet data;\ntry {\n data = JSON.parse($json.message); // $json.message is expected to be a JSON string\n} catch (e) {\n // If parsing fails, throw an error\n throw new Error(\"Invalid JSON in MQTT message\");\n}\n\n// Get the topic from the input, or use a default value\nconst topic = $json.topic || \"unknown-topic\";\n\n// Make sure humidity and temp are numbers\nif (typeof data.humidity !== \"number\" || typeof data.temp !== \"number\") {\n throw new Error(\"Missing or invalid humidity/temp in MQTT message\");\n}\n\n// Create a formatted string like: \"topic_name humidity=45,temp=22\"\nconst line = `${topic} humidity=${data.humidity},temp=${data.temp}`;\n\n// Return the result in the expected format\nreturn [\n {\n json: {\n payload: line\n }\n }\n];" }, "typeVersion": 2, "notes": "This code node performs automated tasks as part of the workflow." } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000 }, "versionId": "d1311dca-5edf-4f14-86b9-629937cd3416", "connections": { "51e6f59f-9b93-4121-8db4-7f47b929fdf5": { "main": [ [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-f96c467e", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-01c61489", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-7a8c0941", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-b996e7df", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-08886c56", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-d387ec6d", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-812f1bc8", "type": "main", "index": 0 } ], [ { "node": "error-handler-51e6f59f-9b93-4121-8db4-7f47b929fdf5-ec6cdb70", "type": "main", "index": 0 } ] ] } }, "description": "Automated workflow: Remote IOT Sensor monitoring via MQTT and InfluxDB. This workflow integrates 5 different services: stickyNote, httpRequest, code, stopAndError, mqttTrigger. It contains 8 nodes and follows best practices for error handling and security.", "notes": "Excellent quality workflow: Remote IOT Sensor monitoring via MQTT and InfluxDB. This workflow has been optimized for production use with comprehensive error handling, security, and documentation." }