Pranav KundaikarVinayak Shantaram Joshi
Published © MIT

Water Level Alerting System

Get an alert via email when the water level reaches a critical threshold.

IntermediateFull instructions provided30 minutes22,772
Water Level Alerting System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Arduino IDE
Arduino IDE
Integromat

Story

Read more

Schematics

Connection for using HC-SR04 with Boltduino and Bolt

Connections for using HC-SR04 with Arduino and Bolt

Code

Water Level Detecting System using Ultrasonic HC-SR04

C/C++
#include <Ultrasonic.h>
#include <BoltIoT-Arduino-Helper.h>

#define ULTRASONIC_TRIG_PIN 12
#define ULTRASONIC_ECHO_PIN 13

Ultrasonic ultrasonic(ULTRASONIC_TRIG_PIN,ULTRASONIC_ECHO_PIN);
int distance=0;

String getDistance(String *arguments){
  distance = ultrasonic.read();
    String returnString=""+String(distance);
    return returnString;
}

void setup() {
  boltiot.begin(Serial);
  // put your setup code here, to run once:
  boltiot.setCommandString("RD\r",getDistance);
  boltiot.setCommandString("GetDistance",getDistance);
}

void loop() {
  boltiot.handleCommand();
  // put your main code here, to run repeatedly:
  
}

WaterLevelDetection

JSON
This is a json file containing the blueprint for the Integromat scenario.
{
    "name": "Water Level Detection",
    "flow": [
        {
            "id": 15,
            "module": "app#bolt-iot:executeCommand",
            "version": 1,
            "parameters": {
                "__IMTCONN__": 445281
            },
            "mapper": {
                "command": "serialBegin",
                "parameters": {
                    "baud": "9600",
                    "deviceName": ""
                }
            },
            "metadata": {
                "designer": {
                    "x": 8,
                    "y": -3
                },
                "restore": {
                    "command": {
                        "label": "Initialize serial communication"
                    },
                    "__IMTCONN__": {
                        "label": "My Bolt connection"
                    }
                },
                "parameters": [
                    {
                        "name": "__IMTCONN__",
                        "type": "account",
                        "label": "Connection",
                        "required": true
                    }
                ],
                "expect": [
                    {
                        "name": "command",
                        "type": "select",
                        "label": "Command",
                        "required": true,
                        "validate": {
                            "enum": [
                                "digitalWrite",
                                "digitalRead",
                                "analogRead",
                                "analogWrite",
                                "serialBegin",
                                "serialWrite",
                                "serialRead",
                                "version",
                                "restart",
                                "isAlive"
                            ]
                        }
                    },
                    {
                        "name": "parameters",
                        "spec": [
                            {
                                "name": "deviceName",
                                "type": "text",
                                "label": "Device name",
                                "required": true
                            },
                            {
                                "name": "baud",
                                "type": "number",
                                "label": "Baud",
                                "required": true
                            }
                        ],
                        "type": "collection",
                        "label": "Parameters"
                    }
                ]
            }
        },
        {
            "id": 1,
            "module": "app#bolt-iot:executeCommand",
            "version": 1,
            "parameters": {
                "__IMTCONN__": 445281
            },
            "mapper": {
                "command": "serialWrite",
                "parameters": {
                    "data": "GetDistance",
                    "deviceName": ""
                }
            },
            "metadata": {
                "designer": {
                    "x": 300,
                    "y": 0
                },
                "restore": {
                    "command": {
                        "label": "Send serial data output"
                    },
                    "__IMTCONN__": {
                        "label": "My Bolt connection"
                    }
                },
                "parameters": [
                    {
                        "name": "__IMTCONN__",
                        "type": "account",
                        "label": "Connection",
                        "required": true
                    }
                ],
                "expect": [
                    {
                        "name": "command",
                        "type": "select",
                        "label": "Command",
                        "required": true,
                        "validate": {
                            "enum": [
                                "digitalWrite",
                                "digitalRead",
                                "analogRead",
                                "analogWrite",
                                "serialBegin",
                                "serialWrite",
                                "serialRead",
                                "version",
                                "restart",
                                "isAlive"
                            ]
                        }
                    },
                    {
                        "name": "parameters",
                        "spec": [
                            {
                                "name": "deviceName",
                                "type": "text",
                                "label": "Device name",
                                "required": true
                            },
                            {
                                "name": "data",
                                "type": "text",
                                "label": "Data",
                                "required": true
                            }
                        ],
                        "type": "collection",
                        "label": "Parameters"
                    }
                ]
            }
        },
        {
            "id": 14,
            "module": "app#bolt-iot:executeCommand",
            "version": 1,
            "parameters": {
                "__IMTCONN__": 445281
            },
            "mapper": {
                "command": "serialRead",
                "parameters": {
                    "till": "10",
                    "deviceName": ""
                }
            },
            "metadata": {
                "designer": {
                    "x": 600,
                    "y": 0
                },
                "restore": {
                    "command": {
                        "label": "Read incoming serial data"
                    },
                    "__IMTCONN__": {
                        "label": "My Bolt connection"
                    }
                },
                "parameters": [
                    {
                        "name": "__IMTCONN__",
                        "type": "account",
                        "label": "Connection",
                        "required": true
                    }
                ],
                "expect": [
                    {
                        "name": "command",
                        "type": "select",
                        "label": "Command",
                        "required": true,
                        "validate": {
                            "enum": [
                                "digitalWrite",
                                "digitalRead",
                                "analogRead",
                                "analogWrite",
                                "serialBegin",
                                "serialWrite",
                                "serialRead",
                                "version",
                                "restart",
                                "isAlive"
                            ]
                        }
                    },
                    {
                        "name": "parameters",
                        "spec": [
                            {
                                "name": "deviceName",
                                "type": "text",
                                "label": "Device name",
                                "required": true
                            },
                            {
                                "name": "till",
                                "type": "number",
                                "label": "Till",
                                "required": true,
                                "validate": {
                                    "max": 127,
                                    "min": 0
                                }
                            }
                        ],
                        "type": "collection",
                        "label": "Parameters"
                    }
                ]
            }
        },
        {
            "id": 18,
            "module": "math:EvaluateExpression",
            "version": 1,
            "parameters": {},
            "mapper": {
                "expression": "100-{{parseNumber(14.value)}}"
            },
            "metadata": {
                "designer": {
                    "x": 869,
                    "y": -2
                },
                "expect": [
                    {
                        "name": "expression",
                        "type": "text",
                        "label": "Expression",
                        "required": true
                    }
                ]
            }
        },
        {
            "id": 13,
            "module": "google-email:ActionSendEmail",
            "version": 1,
            "parameters": {
                "account": 445282
            },
            "filter": {
                "name": "Check if water level to high",
                "conditions": [
                    [
                        {
                            "a": "{{18.result}}",
                            "b": "60",
                            "o": "number:greater"
                        }
                    ]
                ]
            },
            "mapper": {
                "cc": [],
                "to": [
                ],
                "bcc": [],
                "html": "Water level has reached {{18.result}}cms.",
                "subject": "Warning! Water Level is too high!!",
                "attachments": []
            },
            "metadata": {
                "designer": {
                    "x": 1145,
                    "y": -3
                },
                "restore": {
                    "cc": {
                        "mode": "chose",
                        "items": []
                    },
                    "to": {
                        "mode": "chose",
                        "items": [
                            "undefined"
                        ]
                    },
                    "bcc": {
                        "mode": "chose",
                        "items": []
                    },
                    "account": {
                        "label": ""
                    },
                    "attachments": {
                        "mode": "chose",
                        "items": []
                    }
                },
                "parameters": [
                    {
                        "name": "account",
                        "type": "account",
                        "label": "Connection",
                        "required": true
                    }
                ],
                "expect": [
                    {
                        "name": "to",
                        "spec": {
                            "name": " ",
                            "type": "email",
                            "label": "Email address",
                            "required": true
                        },
                        "type": "array",
                        "label": "To",
                        "labels": {
                            "add": "Add a recipient",
                            "edit": "Edit a recipient"
                        },
                        "required": true
                    },
                    {
                        "name": "subject",
                        "type": "text",
                        "label": "Subject"
                    },
                    {
                        "name": "html",
                        "type": "text",
                        "label": "Content"
                    },
                    {
                        "name": "attachments",
                        "spec": [
                            {
                                "name": "fileName",
                                "type": "filename",
                                "label": "File name",
                                "required": true,
                                "semantic": "file:name"
                            },
                            {
                                "name": "data",
                                "type": "buffer",
                                "label": "Data",
                                "required": true,
                                "semantic": "file:data"
                            },
                            {
                                "name": "cid",
                                "type": "text",
                                "label": "Content-ID"
                            }
                        ],
                        "type": "array",
                        "label": "Attachments",
                        "labels": {
                            "add": "Add an attachment",
                            "edit": "Edit an attachment"
                        }
                    },
                    {
                        "name": "cc",
                        "spec": {
                            "type": "email",
                            "label": "Email address"
                        },
                        "type": "array",
                        "label": "Copy recipient",
                        "labels": {
                            "add": "Add a copy recipient",
                            "edit": "Edit a copy recipient"
                        }
                    },
                    {
                        "name": "bcc",
                        "spec": {
                            "type": "email",
                            "label": "Email address"
                        },
                        "type": "array",
                        "label": "Blind copy recipient",
                        "labels": {
                            "add": "Add a blind copy recipient",
                            "edit": "Edit a blind copy recipient"
                        }
                    }
                ]
            }
        }
    ],
    "metadata": {
        "version": 1,
        "scenario": {
            "roundtrips": 1,
            "maxErrors": 3,
            "autoCommit": false,
            "sequential": false,
            "confidential": false,
            "dataloss": false,
            "dlq": false
        },
        "designer": {
            "orphans": []
        },
        "zone": "eu1.integromat.com"
    }
}

Credits

Pranav Kundaikar

Pranav Kundaikar

2 projects • 22 followers
Co-Founder & CTO @ Bolt IoT.
Vinayak Shantaram Joshi

Vinayak Shantaram Joshi

11 projects • 63 followers

Comments