Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: several moisture sensors on: February 23, 2014, 05:42:10 am
15-20 point + lcd 20x4 .  I bought Arduino mega for this.
2  Using Arduino / Sensors / several moisture sensors on: February 23, 2014, 03:36:15 am
How to connect to arduino several soil moisture sensors and measure soli moisture ? I want to measure soil moisture in several places in greenhouse.
3  Using Arduino / General Electronics / Lead acid battery + solar panel monitor on: September 04, 2013, 01:25:11 am
Where I find sheme for ds2438 battery monitor and sketch for arduino ?
4  Using Arduino / Sensors / Arduino DS2438 smart battery monitor on: June 27, 2013, 03:47:25 pm
I read tons of post and not find how to build smart batteri monitor with arduino and ds2438 and 4x16 lcd. Please help me. Maybe where is sample sketch too.

Im not specialist.
5  Using Arduino / Programming Questions / Re: Serial output in lcd. on: May 19, 2013, 07:15:23 am
I got it
6  Using Arduino / Programming Questions / Serial output in lcd. on: May 19, 2013, 01:33:34 am
On lcd nothing but serial monitor working fine.

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
/*
0   -   232 rxd
1   -   232 txd
2   -   rw (LCD) pin 4
3   -   enable (LCD) pin 6
4   -   sd card 9   (ETHERNET SHIELD)
5   -   lcd d4   (LCD)
6   -   lcd d5   (LCD)
7   -   lcd d6   (LCD)
8   -   lcd d7   (LCD)
9       -       DS18B20
10   -   w5100 select(ETHERNET SHIELD)
11   -   SPI MOSI (ETHERNET SHIELD)
12   -   SPI MISO (ETHERNET SHIELD)
13   -   SPI CLK (ETHERNET SHIELD)

ANALOG
0   -   MOISTURE in (analog)   moisture_input 0
1   -   moisture (digital)     divider_top 2
2   -   moisture 1 (digital)   divider_bottom 3
3   -   window open (digital)
4   -   window close (digital)
5   -   water pump (digital)
 
 
 Moisture
 
Connect two nails and a resistor as shown

      analog 1---*   #define divider_top A1
                  |
                  \
                  /
                  \ R1
                  /
                  |
                  |
      analog 0----*   #define moisture_input A0
                  |
                  |
                  *----> nail 1
                 
                  *----> nail 2
                  |
                  |
                  |
      analog 2---*   #define divider_bottom A2

*/



 

         
         
         
         
         
             // initialize the library with the numbers of the interface pins
            LiquidCrystal lcd(2, 3, 5, 6, 7, smiley-cool;
           
           // Data wire is plugged into pin 9 on the Arduino
            #define ONE_WIRE_BUS 9
             
            // Setup a oneWire instance to communicate with any OneWire devices
            OneWire oneWire(ONE_WIRE_BUS);
             
            // Pass our oneWire reference to Dallas Temperature.
            DallasTemperature sensors(&oneWire);
             
            // Assign the addresses of your 1-Wire temp sensors.
            // See the tutorial on how to obtain these addresses:
            // http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
             
            DeviceAddress insideThermometer = { 0x28, 0x2B, 0xE6, 0xDA, 0x02, 0x00, 0x00, 0x43 };
            //DeviceAddress outsideThermometer = { 0x28, 0x6B, 0xDF, 0xDF, 0x02, 0x00, 0x00, 0xC0 };
            //DeviceAddress groundThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };
             
            #define moisture_input 0 // analog pin  0, nail 1
            #define divider_top 1 // resistor analog pin 1
            #define divider_bottom 2 // nail 2 analog pin 2
            int waterPump =A5; // water pump analog pin 5
            int moisture;
            int Koguprotsent;
            int tempHigh =A3; // window open relay
            int tempLow =A4; //window close relay
     
             int X=0;
       
            void setup(void)
            {
           
            pinMode (tempLow, OUTPUT);
            pinMode (tempHigh, OUTPUT);
            pinMode (waterPump, OUTPUT);
             digitalWrite(waterPump, LOW);
             digitalWrite (tempLow, LOW);
             digitalWrite (tempHigh, LOW);
             
             // set up the LCD's number of columns and rows:
              lcd.begin(16, 2);
             
              // start serial port
              Serial.begin(9600);
             
              // Start up the library
              sensors.begin();
             
              // set the resolution to 10 bit (good enough?) maybe 9 bit better
              sensors.setResolution(insideThermometer, 9);
            //  sensors.setResolution(outsideThermometer, 9);
            //  sensors.setResolution(dogHouseThermometer, 9);
            }
             
            void printTemperature(DeviceAddress deviceAddress)
            {
              float tempC = sensors.getTempC(deviceAddress);
              if (tempC == -127.00) {
                Serial.print("Error getting temperature");
              } else {
                Serial.print("C: ");
                Serial.print(tempC);
                //-- panin koodi siia..
              }
                     
                     if (tempC >= 27 && X ==0){
                       digitalWrite(tempHigh, HIGH);
                      delay(6000);
                      digitalWrite(tempHigh, LOW);
                     X = 1;
                     }
 
                     if (tempC <= 24 && X ==1){
                      //luuk alla
                     X = 0;
                     
                      digitalWrite(tempLow, HIGH);
                      delay(6000);
                      digitalWrite(tempLow, LOW);
}
 
             
               
             
            }
             
            void loop(void)
            {
             
 {
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read());
    }
  }
}             
             
     
              //---- soil
             
        //     Serial.print("Getting Soil Moisture...\n\r");
              moisture=SoilMoisture(); // soilmoister as variable
               Koguprotsent = ((moisture*100)/970); // mina sain max väärtuseks 950
              Serial.print("Niiskuse absoluut arv: ");
              Serial.println(moisture);
             
               Serial.print("Mullas on niiskust ");
               Serial.print(Koguprotsent);
               Serial.print(" % ");
             
              Serial.println();
             
             
              delay(1000); // tuleks sättida endale sobivaks.
             
             
             
                if (Koguprotsent >= 90){
               
              digitalWrite(waterPump, LOW);
             
                }
                if (Koguprotsent <= 75){
                 
                   digitalWrite(waterPump, LOW);
                   delay(1000);                    //pumba töö aeg.Katsetamise käigus selgub palju oleks normaalne aeg pumba tööks,et ei tekiks uputust.
                   digitalWrite(waterPump, HIGH);
             
             
                }
               
                //---------- temp
              delay(1000);
              Serial.print("Getting temperatures...\n\r");
              sensors.requestTemperatures();
             
              Serial.print("Inside temperature is: ");
              printTemperature(insideThermometer);
              Serial.print("\n\r");
            //  Serial.print("Outside temperature is: ");
            //  printTemperature(outsideThermometer);
            //  Serial.print("\n\r");
            //  Serial.print("Dog House temperature is: ");
            //  printTemperature(dogHouseThermometer);
            //  Serial.print("\n\r\n\r");
            }
             
           
             
             
            int SoilMoisture(){
              int reading;
              // set driver pins to outputs
              pinMode(divider_top,OUTPUT);
              pinMode(divider_bottom,OUTPUT);
             
              // drive a current through the divider in one direction
              digitalWrite(divider_top,LOW);
              digitalWrite(divider_bottom,HIGH);
             
              // wait a moment for capacitance effects to settle
              delay(1000);
             
              // take a reading
              reading=analogRead(moisture_input);
             
              // reverse the current
              digitalWrite(divider_top,HIGH);
              digitalWrite(divider_bottom,LOW);
             
              // give as much time in 'reverse' as in 'forward'
              delay(1000);
             
              // stop the current
              digitalWrite(divider_bottom,LOW);
             
              return reading;
             
             //relays for temp
             pinMode(tempHigh,OUTPUT);
             
           
           
           
             
            }
7  Using Arduino / Networking, Protocols, and Devices / How to build Arduino+XBee 1km link ? on: April 19, 2013, 03:31:08 am
How to build link ? Solar power+ Arduino + Xbee+ ds18b20+ moisture sensors and other side web log server. I want to put arduino to the greenhouse measure temp. and moisture and send this data over air to web log server. What I need ?

Sorry my english.
8  Using Arduino / Displays / Re: Midas I2C LCD 16x2 on: March 26, 2013, 03:15:40 pm
LCD pins:

1 VOUT
 2 CAP1N
3 CAP1P
4 VDD
5 VSS
6 SDA
7  SCL
8 RST

Datasheet is here http://www.farnell.com/datasheets/1485486.pdf
Tomorrow i scan.
9  Using Arduino / Displays / Re: Midas I2C LCD 16x2 on: March 26, 2013, 02:51:13 am
I don't know what is wrong.Nothing on lcd.
10  Using Arduino / Displays / Midas I2C LCD 16x2 on: March 25, 2013, 08:53:35 am
How do I get this to work ? Wiring from here http://www.workshopshed.com/2012/07/a-little-venture-with-electronics-lcd.html
I can't download library from this site.
This is LCD http://ee.farnell.com/midas/mccog21605b6w-sptlyi/lcd-cog-2x16-stn-grn-b-l-i2c/dp/2063208?Ntt=mccog21605b6w-s
I have Leonardo
11  Using Arduino / Displays / Samsung 4004B 24x2 lcd ? on: February 19, 2013, 01:11:44 pm
in back wite Samsung 4004B and 94VO 2500  and MCL M01 .Lcd 24x2. How to connect it to arduino and use this ?
12  Using Arduino / Sensors / photoelectric switch diffuse type yos-18-n-u-x-3 on: February 19, 2013, 08:05:20 am
Can I build counter with this sensor + lcd ? Sensor operating voltage is 10-30 V DC 200 mA.
13  Using Arduino / Programming Questions / Re: Water usage and cost. Please help me programming 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.

14  Using Arduino / Programming Questions / Re: Water usage and cost. Please help me programming 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
15  Using Arduino / Programming Questions / Re: Water usage and cost. Please help me programming 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.
Pages: [1] 2