Water Tank Sensor

Guys I am using a project and it is working perfectly fine, except that I am using pushbullet to send notification to my mobile. Beside using pushbullet I also want to use TWILLIO or anyother sms based service to send sms notification when water level is low in my tank. This i need because the guy who supply water to my house is not using smart phone and sms is the only way forward.

This is the code I am using.

What’s the question, and where’s the code?

I´m using an cheap Ultrasonic Sensor - HC-SR04 to detect water level in this project and use IFTTT-Services in combination with Particle Publish to trigger an alarm via E-Mail, SMS and so on.


I am replicating project and it is working fine. I need notification via SMS… How can i do that.

Project is :

Rather than us chewing it up for you: what have you tried so far?


I tired it with IFTTT but not working.

That’s a bit of a broad description, what exactly did you try that didn’t work?

Hello Moors…

Hope your are doing good. I did not do much except that I enable the IFTTT pushbullet service on IFTTT Page.

Have you tried the SMS triggers that IFTTT offers?


I am using another code to sensor water level in my water tank. As soon as the water level goes down to a certain level… I receive a pushbutton message. I also wanted to integrate SMS function so that I also receive SMS when I do not have wifi. I am not a programmer so plz help me integrate this function.

// This #include statement was automatically added by the Particle IDE.
#include <elapsedMillis.h>

// This #include statement was automatically added by the Particle IDE.
#include "elapsedMillis/elapsedMillis.h"

// This #include statement was automatically added by the Particle IDE.
#include "elapsedMillis/elapsedMillis.h"

String _version = "0.04";

//this reads the flood sensor every 2 seconds

//this defines the frequency of the notifications sent to the user
#define FLOOD_FIRST_ALARM 10000 //10 seconds
#define FLOOD_SECOND_ALARM 60000 //1 minute
#define FLOOD_THIRD_ALARM 300000 //5 minutes
#define FLOOD_FOURTH_ALARM 900000 //15 minutes
#define FLOOD_FIFTH_ALARM 3600000 //1 hour
#define FLOOD_SIXTH_ALARM 14400000 //4 hours - and every 4 hours ever after, until the situation is rectified (ie no more water is detected)


elapsedMillis flood_timer;
elapsedMillis flood_alarm_timer;

int flood_alarm_index = 0;
bool flood_detected = false;
unsigned long flood_next_alarm = 0;

int LED = D7;

void setup() {
 pinMode(LED, OUTPUT);
 Spark.publish("device starting", "Firmware version: " + _version, 60, PRIVATE);

void loop() {

    if ( flood_detected ) {

 * Function Name  : flood_check
 * Description    : check water leak sensor at FLOOD_READ_INTERVAL, turns on led on D7 and raises alarm if water is detected
 * Return         : 0
int flood_check()
    if (flood_timer < FLOOD_READ_INTERVAL) {
        return 0;
    //time is up, so reset timer
    flood_timer = 0;

    if (digitalRead(FLOOD_SENSOR)) {
        //if flood is already detected, no need to do anything, since an alarm will be fired
        if (flood_detected){
            return 0;
        flood_detected = true;
        //reset alarm timer
        flood_alarm_timer = 0;

        //set next alarm
        flood_alarm_index = 0;
        flood_next_alarm = flood_alarms_array[0];
    } else {
        flood_detected = false;
    return 0;

 * Function Name  : flood_notify_user
 * Description    : will fire notifications to user at scheduled intervals
 * Return         : 0
int flood_notify_user()

    if (flood_alarm_timer < flood_next_alarm) {
        return 0;

    //time is up, so reset timer
    flood_alarm_timer = 0;
    //set next alarm or just keep current one if there are no more alarms to set
    if (flood_alarm_index < arraySize(flood_alarms_array)-1) {
        flood_alarm_index = flood_alarm_index + 1;
        flood_next_alarm = flood_alarms_array[flood_alarm_index];

    //send an alarm to user (this one goes to the dashboard)
    Spark.publish(FLOOD_NOTIF, "Underground tank need water!", 60, PRIVATE);

    //send an alarm to user (this one goes to pushbullet servers)
    Spark.publish("pushbullet", "Attention!..Water tank empty. Call water service!", 60, PRIVATE);
   return 0; 

Well, it’s been a long time since I came up with my code and I’m not much of a programmer either :slight_smile: but basically you go to Twilio (or someone similar), set up an account, get your Account id, set up your webhook similar to mine above, then just publish a message to trigger the specific webhook (by it’s name which is the eventName) that sends the SMS.
I did find it difficult to read your code due to formatting issues, and make sure your publish function conforms to that given in the docs and the data is sent by the webhook:

Particle.publish(const char *eventName, const char *data, int ttl, PRIVATE);
Particle.publish(String eventName, String data, int ttl, PRIVATE);


No. I am not aware of this SMS trigger

Give the searcg function on IFTTT a shot then :slight_smile:


I managed to send sms via Twilio. Now I am working on IFTTT coz it is free. I manage to create a new applet using IF ( partcle) and this as (SMS) but did not receive sms yet.


I manage to create a event and receive sms via twilio.

What does your applet look like?