Sensor to promt SMS

I have my sketch working for my GSM to send SMS and my sensor to detect distance seperately but i am looking for some advice on how to combine these.

My aim is to sense liquid level so that when a specific distance is sensed it will prompt the GSM to send a text and alert someone.

Any advice or help on this matter would be greatly appreciated. Thanks in advance!

My aim is to sense liquid level so that when a specific distance is sensed it will prompt the GSM to send a text and alert someone.

So, what is the problem? You might want to look at the state change detection example, to see how to send a message ONCE when the liquid reaches the specified level. Getting hundreds of text messages when the tank gets full is not useful. Getting one might be.

Thanks for the response. What you're saying is exactly what I aim to do although after trying it a number of times I can't seem to get it working. I am a beginner with Arduino and programming in general so any help is greatly appreciated. I had a look at the state change detection but since I am using an ultrasonic sensor I am unsure on how to set it to change state at a specific point (it has a range of 4m). Assume I want it to go HIGH when it reaches 3m.

I had a look at the state change detection but since I am using an ultrasonic sensor I am unsure on how to set it to change state at a specific point (it has a range of 4m). Assume I want it to go HIGH when it reaches 3m.

So, you want to send a message when the distance value goes from below 3m to above 3m? That looks like a state change to me.

The difference is that it is the current distance vs. the previous distance that are of interest, not the current vs. previous state of a pin.

You still need to keep track of a previous value (state or distance) and compare the current value (state or distance) to that value.

Yes that's the general idea. I understand what you're saying and it makes sense to keep track of the values although there are some complications.

This is part of a system which will hopefully be in a power sleep mode and only be sensing once every 24hrs. My idea is for my board to have an interrupt if the sensor detects a distance greater than 3m which would in turn initiate an SMS to be sent using my GSM module.

Thanks you, this information is very useful!

My idea is for my board to have an interrupt if the sensor detects a distance greater than 3m

The sensor sends a pulse. It measures that time that it takes to receive an echo. If the Arduino is sleeping, the sensor is not sending pulses. There will, therefore, be no echoes and no time. What part of no data is supposed to trigger an interrupt?

If I understand correctly, you want to wake up once a day, and see if something has been stolen, and, if it has, you need to know right away. Did I miss something?

Yes that is the idea of the system I would like. Do you know of any examples of this because I've been doing my best with my limited knowledge but I'm not getting anywhere.