Offline
Newbie
Karma: 0
Posts: 18
|
 |
« on: February 09, 2013, 04:02:37 am » |
I have Arduino Leonardo, ethernet shield Wiznet w5100 with sd card and poe,water meter with impulse out Minomess ETK-M pulse - Pulse value 10 l/Imp, i ordered DS1307 RTC, LCD 16x2 and Ubuntu 12.04 web server.How to create something this? Help me program!
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 48
Posts: 1416
May all of your blinks be without delay
|
 |
« Reply #1 on: February 09, 2013, 05:14:12 am » |
If you want someone to write the code for you then you would be better off asking in Gigs and Collaborations http://arduino.cc/forum/index.php/board,26.0.html
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 90
Posts: 9407
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #2 on: February 09, 2013, 05:41:34 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #3 on: February 11, 2013, 01:23:04 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6386
-
|
 |
« Reply #4 on: February 11, 2013, 01:28:59 pm » |
You would need to calibrate the sensor so that you had an accurate reading in liters or cubic meters, and then multiply that by your cost-per-liter or cost-per-cubic-meter to calculate the corresponding cost.
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 48
Posts: 1416
May all of your blinks be without delay
|
 |
« Reply #5 on: February 11, 2013, 01:34:23 pm » |
The code you posted a link to tells you how many litres of water have passed through the sensor. You know how many litres there are in a cubic metre. You know how much a cubic metre of water costs. So, the cost is just a matter of doing the maths and outputting the result.
Have you tried any of the example scripts that came with the Arduino ? The arithmetic operators, add, subtract, multiply, divide and others are described in the Arduino reference installed with the IDE and accessible from the IDE menu (Help/Reference)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #6 on: February 11, 2013, 02:04:58 pm » |
OK. I will try. I have water meter with pulse sensor. 1 pulse = 1 litre
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 48
Posts: 1416
May all of your blinks be without delay
|
 |
« Reply #7 on: February 11, 2013, 02:29:57 pm » |
Post your code here if you get stuck.
Don't waste too much water when testing it though !
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #8 on: February 12, 2013, 01:20:00 am » |
I do not want pulses and freguency. Lcd could be shown only to liters and price. Water cost is 1m3 = 2,76 € . Water meter 1 pulse = 1 litre /********************************************************** This is example code for using the Adafruit liquid flow meters.
Tested and works great with the Adafruit plastic and brass meters ------> http://www.adafruit.com/products/828 ------> http://www.adafruit.com/products/833
Connect the red wire to +5V, the black wire to common ground and the yellow sensor wire to pin #2
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution **********************************************************/ #include "LiquidCrystal.h" LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// which pin to use for reading the sensor? can use any pin! #define FLOWSENSORPIN 2
// count how many pulses! volatile uint16_t pulses = 0; // track the state of the pulse pin volatile uint8_t lastflowpinstate; // you can try to keep time of how long it is between pulses volatile uint32_t lastflowratetimer = 0; // and use that to calculate a flow rate volatile float flowrate; // Interrupt is called once a millisecond, looks for any pulses from the sensor! SIGNAL(TIMER0_COMPA_vect) { uint8_t x = digitalRead(FLOWSENSORPIN); if (x == lastflowpinstate) { lastflowratetimer++; return; // nothing changed! } if (x == HIGH) { //low to high transition! pulses++; } lastflowpinstate = x; flowrate = 1000.0; flowrate /= lastflowratetimer; // in hertz lastflowratetimer = 0; }
void useInterrupt(boolean v) { if (v) { // Timer0 is already used for millis() - we'll just interrupt somewhere // in the middle and call the "Compare A" function above OCR0A = 0xAF; TIMSK0 |= _BV(OCIE0A); } else { // do not call the interrupt function COMPA anymore TIMSK0 &= ~_BV(OCIE0A); } }
void setup() { Serial.begin(9600); Serial.print("Flow sensor test!"); lcd.begin(16, 2); pinMode(FLOWSENSORPIN, INPUT); digitalWrite(FLOWSENSORPIN, HIGH); lastflowpinstate = digitalRead(FLOWSENSORPIN); useInterrupt(true); }
void loop() // run over and over again { lcd.setCursor(0, 0); lcd.print("Pulses:"); lcd.print(pulses, DEC); //lcd.print(" Hz:"); lcd.print(flowrate); //lcd.print(flowrate); //Serial.print("Freq: "); Serial.println(flowrate); Serial.print("Pulses: "); Serial.println(pulses, DEC); // if a plastic sensor use the following calculation // Sensor Frequency (Hz) = 7.5 * Q (Liters/min) // Liters = Q * time elapsed (seconds) / 60 (seconds/minute) // Liters = (Frequency (Pulses/second) / 7.5) * time elapsed (seconds) / 60 // Liters = Pulses / (7.5 * 60) float liters = pulses; //liters /= 7.5; //liters /= 60.0;
/* // if a brass sensor use the following calculation float liters = pulses; liters /= 8.1; liters -= 6; liters /= 60.0; */ Serial.print(liters); Serial.println(" Liters"); lcd.setCursor(0, 1); lcd.print(liters); lcd.print(" Liters "); delay(100); } Moderator edit: [code] [/code] tags added.
|
|
|
|
« Last Edit: February 12, 2013, 01:24:05 am by Coding Badly »
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 48
Posts: 1416
May all of your blinks be without delay
|
 |
« Reply #9 on: February 12, 2013, 01:23:14 am » |
I do not want pulses and freguency. Lcd could be shown only to liters and price. Water cost is 1m3 = 2,76 €
As I said The code you posted a link to tells you how many litres of water have passed through the sensor. You know how many litres there are in a cubic metre. You know how much a cubic metre of water costs. So, the cost is just a matter of doing the maths and outputting the result.
Remove any other output that you don't want.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #10 on: February 12, 2013, 12:39:54 pm » |
#include "LiquidCrystal.h" LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
// which pin to use for reading the sensor? can use any pin! #define FLOWSENSORPIN 2
// count how many pulses! volatile uint16_t pulses = 0; // track the state of the pulse pin volatile uint8_t lastflowpinstate; // you can try to keep time of how long it is between pulses volatile uint32_t lastflowratetimer = 0; // and use that to calculate a flow rate volatile float flowrate; // Interrupt is called once a millisecond, looks for any pulses from the sensor! SIGNAL(TIMER0_COMPA_vect) { uint8_t x = digitalRead(FLOWSENSORPIN); if (x == lastflowpinstate) { lastflowratetimer++; return; // nothing changed! } if (x == HIGH) { //low to high transition! pulses++; } lastflowpinstate = x; flowrate = 1000.0; flowrate /= lastflowratetimer; // in hertz lastflowratetimer = 0; }
void useInterrupt(boolean v) { if (v) { // Timer0 is already used for millis() - we'll just interrupt somewhere // in the middle and call the "Compare A" function above OCR0A = 0xAF; TIMSK0 |= _BV(OCIE0A); } else { // do not call the interrupt function COMPA anymore TIMSK0 &= ~_BV(OCIE0A); } }
void setup() { Serial.begin(9600); Serial.print("Flow sensor test!"); lcd.begin(16, 2); pinMode(FLOWSENSORPIN, INPUT); digitalWrite(FLOWSENSORPIN, HIGH); lastflowpinstate = digitalRead(FLOWSENSORPIN); useInterrupt(true); }
void loop() // run over and over again { lcd.setCursor(0, 0); lcd.print(pulses, DEC); lcd.print("Liitrit"); Serial.println(pulses, DEC); Serial.print("Liitrit ");
float liters = pulses; liters *= 0.00276;
Serial.print(liters, DEC); Serial.println(" EUR-i"); lcd.setCursor(0, 1); lcd.print(liters); lcd.print(" EUR-i"); delay(100); }
All working ok but water cost in EUR looks 0,0027600000222 (sample) . I need 0,00000 format. This line : Serial.print(liters, DEC); Serial.println(" EUR-i"); I convert pulses to liters and liters to cost.
Sorry my english.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #11 on: February 12, 2013, 01:31:35 pm » |
All working very well. This line : Serial.print(liters,DEC); Serial.println(" EUR-i"); was wrong I write : Serial.print(liters,5); Serial.println(" EUR-i"); and cost is 0,00000
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Tesla Member
Karma: 89
Posts: 6386
-
|
 |
« Reply #12 on: February 12, 2013, 02:03:59 pm » |
Glad you fixed it. For future reference, when posting code please enclose it in [ CODE ] [ /CODE ] tags. The # button in the editing window inserts these for you.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 18
|
 |
« Reply #13 on: February 12, 2013, 02:27:28 pm » |
Okay.
Then i want to add ethernet shield and send data to web server.I have Wiznet w5100.
|
|
|
|
|
Logged
|
|
|
|
|
|