Water level indicat...
 
Notifications
Clear all

Water level indicator

81 Posts
12 Users
11 Reactions
12.3 K Views
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  

I have the custom chars for the bar graph of your interested.?


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

   
ReplyQuote
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  

   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@tooter

Posted by: @tooter

Is it possible to change the out of range amount  as I would like the range to be low for the frash water tank and high for the grey water and a 3-5 sec buzzer to sound when fresh is down to 25% and grey is at 75%.

Yes, you can change it to suit your needs... you'll just need to store your desired values in some variables.  The logic will be very similar.  Have a go at it first, and if stuck, I or someone else here will help you to make it work.  One thing I thought about in the mean time... is that it's probably a good idea to introduce an offset, because theoretically, at zero, the sensor is under water, or on the verge of being underwater.

You could add another variable and set it's offset to say 5cm above the water level to start with, adding it to your overall calculations, and then fine tuning it's value depending on the exact location of your sensor in relation to the full level position of the water in the tank.

Cheers!


   
ReplyQuote
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  

   
ReplyQuote
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  
Posted by: @frogandtoad

Yes, you can change it to suit your needs... you'll just need to store your desired values in some variables.  The logic will be very similar.  Have a go at it first, and if stuck, I or someone else here will help you to make it work.  One thing I thought about in the mean time... is that it's probably a good idea to introduce an offset, because theoretically, at zero, the sensor is under water, or on the verge of being underwater.

Hi I had a go at making the serial print "Fill Tank" when the litres is <=. but for some reason it don't work but dont know why. There must be more to it than this.

 

if(Litres1 <= 1

Serial.println("Fill Tank");


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @tooter

Today I've been trying to make the lcd come on for 5 sec after a button press with some success the only problem is calculations are only made when the screen is off when button is pressed it locks what ever is on the screen until it turns off again. not realy a problem but not expected.

I think your problem with screen lock-up is that the code that detects the button activation is in the "setup()" area of the code. The set() is only run once when the MCU is rebooted. Any button detection should be moved to the loop() section that continually run. You have done a great job of using millis() to ensure a potential loop will keep running without delays.

I understand your still in the debugging phase of your project but I have a couple of questions on your approach. I see a lot of code for calculating volume of the tanks and quantity in the tanks. Would it not be more useful and easier to just use percent full? That way someone doesn't need to know how large the tanks are to know if they are about to overflow or go empty?

Secondly, you may want to start looking into methods for averaging your readings. From what I read in you header you want the system to warn you with a buzzer when the tanks need servicing. I am assuming the measurements will be going on while the motor home is moving (this may not be your intention and will only run when stationary). If the system is running while moving, water movement in the tanks my cause a lot of extraneous unwanted warnings. 


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @tooter

if(Litres1 <= 1

Serial.println("Fill Tank");

I didn't see this in your posted code but the problem may be as simple as you are missing a closing ")".

 

if(Litres1 <= 1 Serial.println("Fill Tank"));


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 
Posted by: @tooter

There must be more to it than this. 

if(Litres1 <= 1

Serial.println("Fill Tank");

Perhaps,

if(Litres1 <= 1)

Serial.println("Fill Tank");

 


   
ReplyQuote
Ruplicator
(@ruplicator)
Member
Joined: 4 years ago
Posts: 127
 
Posted by: @robotbuilder
Posted by: @tooter

There must be more to it than this. 

if(Litres1 <= 1

Serial.println("Fill Tank");

Perhaps,

if(Litres1 <= 1)

Serial.println("Fill Tank");

 

Oops you're right I'm terrible with syntax.


   
ReplyQuote
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  
Posted by: @ruplicator

I think your problem with screen lock-up is that the code that detects the button activation is in the "setup()" area of the code. The set() is only run once when the MCU is rebooted. Any button detection should be moved to the loop() section that continually run. You have done a great job of using millis() to ensure a potential loop will keep running without delays.

ahh knew it was something daft like that thanks ill try it tomorrow.

Posted by: @ruplicator

I understand your still in the debugging phase of your project but I have a couple of questions on your approach. I see a lot of code for calculating volume of the tanks and quantity in the tanks. Would it not be more useful and easier to just use percent full? That way someone doesn't need to know how large the tanks are to know if they are about to overflow or go empty?

Yes I suppose that would be easier as the amount of water isn't really that important more how full/empty the tank is. It would be beneficial to me to simplify the code.

Posted by: @ruplicator

Secondly, you may want to start looking into methods for averaging your readings. From what I read in you header you want the system to warn you with a buzzer when the tanks need servicing. I am assuming the measurements will be going on while the motor home is moving (this may not be your intention and will only run when stationary). If the system is running while moving, water movement in the tanks my cause a lot of extraneous unwanted warnings. 

No the water meter will only be active when the van is stationary as the 12v electric has a safety cut out when the van is moving.


   
ReplyQuote
(@tooter)
Member
Joined: 4 years ago
Posts: 33
Topic starter  
Posted by: @robotbuilder
Posted by: @tooter

There must be more to it than this. 

if(Litres1 <= 1

Serial.println("Fill Tank");

Perhaps,

if(Litres1 <= 1)

Serial.println("Fill Tank");

 

sorry yes that is what i have just missed it when i coped it.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@tooter

<snip code>

Posted by: @tooter

Hi yes that works. Am I right in thinking the statements you added was a delay in the output from the sensor readings?.

No, it is a software "interrupt" every 2000ms.

The "delay" in the labels is misleading in this case.

I tried to redo the code to explain how it works but kept getting problems while trying to test it on actual hardware. Maybe I can come back to it later.

The main loop() is repeated at maximum speed for your particular Arduino but the segment within that loop is only executed if 2000ms has passed regardless of how fast the loop is executed.

In computer games for example you might want to update the display 60 times per second which may be much slower than the main loop is being executed. To do this you save a current clock value and then wait until 1/60th of second has passed by comparing that saved clock value with the current clock value at which point you can display the next game frame or in your case call sendSensorReadings.

This is an example of how it works in the BASIC language I usually use on my PC because it is easy to read and write. I would move as much control code as possible out of the Arduino and into a RPi.  All the Arduino would do is read the sensors and send them to the PC over the serial port (or via the GPIO pins on the RPi).

 

dim as double st 'start time
st = timer 'set st to current time
do
  if timer > st + 0.1 then
    st = timer 'reset start time 
    readInput()
    update()  'update game data
    display() 'display game
  end if
  sleep 2 'free cpu for other things
loop until multikey(&H01) 'loop until ESC key pressed  
  

 

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

   
ReplyQuote
Page 3 / 6