Data not displaying on crystal screen


hello guys, im trying implement ethernet code code able transmit data (humidity, temp , distance) carriots. on havent figured out how yet first things first , getting arduino connected internet.

the system thesis project , opens valve x seconds every y minutes , transmits data dht22 on crystal screen. have implemented distance sensor should measure amount of water left in reservoir, although im still working on that.
purpose broadcasting data internet(carriots) can follow system home.

whenever add  ethernet.begin(mac,ip); in void setup() data dht22 doesn't displayed on creen. when delete line works again.

how can solve this? im not computer scientist


#include <spi.h>
#include <ethernet.h>
#include <sendcarriots.h>         // must include library here in order use in sketch

const string apikey="562b38cc4b43742bbaebxxxxxxxxxxxxxxa9029fdd008a3cc3952401";     // replace carriots apikey
const string device="dht22@aeroponicsugent.aeroponicsugent";    // replace id_developer of device
     
const int numelements=3;        // specify number of rows in array, in case 3

// enter mac address controller below.
// newer ethernet shields have mac address printed on sticker on shield
byte mac[] = {  0x00, 0x11, 0x32, 0x03, 0x5f, 0x0f };
ipaddress ip(192,168,1,11);       // ip address

sendcarriots sender;              // instantiate instance of sendcarriots library

int trig = 7;
int echo = 6;

#include <dht.h>

#define dhtpin 9
#define dhttype dht22

dht dht(dhtpin, dhttype);

int chk;
float h; // slaat de vochtigheid op (humidity)
float t; // slaat de temperatuur op (temperature)

#include <liquidcrystal.h>

liquidcrystal lcd(12, 11, 5, 4, 3, 2);

int valve = 8;  // io number of valve

unsigned long intervaltime = 90000; //the interval of valve opening in milliseconds
unsigned long opentime = 4000; // time valve has open on milliseconds

unsigned long lastopenorclose = 0;
unsigned long updatesensor = 0;

void setup(){
  lcd.begin(16, 2);
  dht.begin();

  ethernet.begin(mac,ip);
 
  pinmode(valve, output);
  if(opentime > intervaltime){   // illegal state limit opentime intervaltime
    opentime = intervaltime;
  }
 
  serial.begin(9600);
  serial.println(f("aan het opstarten"));
  digitalwrite(valve, high);
  lastopenorclose = millis();

  pinmode(trig, output);
  pinmode(echo, input);
}

void loop(){

  if (digitalread(valve)==high && millis() - lastopenorclose >= opentime) {
    digitalwrite(valve, low);
    lastopenorclose = millis();
  }
 
  if (digitalread(valve)==low && millis() - lastopenorclose >= intervaltime) {
    digitalwrite(valve, high);
    lastopenorclose = millis();
  }

  if (millis() - updatesensor > 2000)
  {
    updatesensor = millis();
    serial.println("\n"); // makes space between reading on serial monitor

    h = dht.readhumidity();
    t = dht.readtemperature();
 
    serial.print("read sensor: ");
    switch (chk)
    {
      case 0: serial.println("ok"); break;
      case -1: serial.println("checksum error"); break;
      case -2: serial.println("time out error"); break;
      default: serial.println("unknown error"); break;
    }
 
    serial.print("vochtigheid (%): ");
    serial.print(h, 1);
 
    serial.print("  temperatuur (oc): ");
    serial.println(t, 1);
 
    lcd.setcursor(0, 0);
    lcd.print("temp: ");
    lcd.print(t, 1);
    lcd.print("c");
 
    lcd.setcursor(0, 1);
    lcd.print("rv: ");
    lcd.print(h, 1);
    lcd.print("%");

    long t = 0, h = 0, d = 0, v = 25; // met t = time, h = height, d= distance, v = volume

    digitalwrite(trig, low); //transmitting pulse
    delaymicroseconds(2);
    digitalwrite(trig, high);
    delaymicroseconds(10);
    digitalwrite(trig, low);

    t = pulsein(echo, high); // waiting pulse

    h = t / 58; // afstand berekenen
    h = h - 6; // correctie van verschil sensor en max water niveau
    h = 50 - h; // water niveau van 0 - 50 cm

    d = 2 * h; // afstand in %, 0 - 100%

    v = (v * d) / 100 ; // volume water resterend in reservoir

    serial.print("afstand sensor en waterniveau: ");
    serial.print(d); // versturen naar computer
    serial.println("cm");

    serial.print("volume water in het reservoir: ");
    serial.print(v); // versturen naar computer
    serial.print(" liter");
  }
 
  delay(2000);
}


code: [select]
liquidcrystal lcd(12, 11, 5, 4, 3, 2);
the communication between arduino , ethernet shield happens via spi, uses pins 10, 11, 12, , 13. can't connect lcd of pins.


Arduino Forum > Using Arduino > Programming Questions > Data not displaying on crystal screen


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'