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!
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
it can look a bit like this project - Data-Logger Shield for Arduino -
merged with a pulse counter - Arduino Playground - EEM12L-32AKWhMonitoring -
This works ok but how to i add to this water cost? 1m3 = 2,76€
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.
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)
OK. I will try. I have water meter with pulse sensor. 1 pulse = 1 litre
Post your code here if you get stuck.
Don't waste too much water when testing it though !
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:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
insippo:
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.
#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.
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
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.
Okay.
Then i want to add ethernet shield and send data to web server.I have Wiznet w5100.
Ever get this working with the Ethernet?