04-03-2017, 16:48
Hello,
I have a well in the garden and I would like to take advantage of the weatherduino TX to transfer the water level. I use an ultrasonic sensor SRF05 which is very widespread.
Is it possible to integrate it as spudstrawb did on the thread: http://www.meteocercal.info/forum/Thread...light=case
I will not use a UV sensor, so I would like to have the well level at this location (as spudstrawb did) on the RX and WD. I do not have enough programming skills to change the code.
I will use a waterproof DS18B20 sensor to know the water T ° but this is already provided on the TX card so no worries.
Thanks
code for display on lcd 16,2 and serial. I use only %, others values are calculation.
I have a well in the garden and I would like to take advantage of the weatherduino TX to transfer the water level. I use an ultrasonic sensor SRF05 which is very widespread.
Is it possible to integrate it as spudstrawb did on the thread: http://www.meteocercal.info/forum/Thread...light=case
I will not use a UV sensor, so I would like to have the well level at this location (as spudstrawb did) on the RX and WD. I do not have enough programming skills to change the code.
I will use a waterproof DS18B20 sensor to know the water T ° but this is already provided on the TX card so no worries.
Thanks
code for display on lcd 16,2 and serial. I use only %, others values are calculation.
Code:
//HC RS04 Ultrasonic ranging module
int triggerPort = 2;
int echoPort = 3;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,4,5,6,7);
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode( triggerPort, OUTPUT );
pinMode( echoPort, INPUT );
}
void loop() {
digitalWrite(triggerPort, LOW); // set to LOW trigger's output
digitalWrite(triggerPort, HIGH); // send a 10us pulse to the trigger
delayMicroseconds( 10 );
digitalWrite(triggerPort, LOW);
long duration = pulseIn(echoPort, HIGH);
long r = 3.4 * duration / 2; // here we calculate the distance using duration
float distance = r / 100.00;
float pourcent = duration;
Serial.print("duree: ");
Serial.println(duration);
Serial.print("distance: ");
if( duration > 38000 ) Serial.println("out of reach"); // if duration in greather than 38ms, the obstacle is out of reach
else { Serial.print(distance); Serial.print("cm ");}
pourcent = map(duration, 1000, 10500, 100, 0); //1000 pour le niveau haut et 10500 pour le niveau bas
lcd.setCursor(0, 0);
lcd.print("niveau:");
lcd.print(pourcent);
lcd.print(" % ");
delay( 1000 ); // wait for 1s
}