Alarm, temp regeling met internet

I have now combined an alarm and a temperature control. now the intention is that I can view my temperature via the internet. but also that in the event of an alarm I also receive an alarm notification on my phone. I have there for an ENC28J60 in my schematic. but despite several examples with this module I still can't get anything done. can you help me with this?

//temp
#include "DHT.h"//DHT sensor Library
#define DHTfanPIN 11 //Define sensor pin(pin 11)
#define DHTfanTYPE DHT22 //What sensor use
#define DHTklepPIN 12 //Define sensor pin(pin 12)
#define DHTklepTYPE DHT22 //What sensor use

DHT dhtfan(DHTfanPIN, DHTfanTYPE);//Create sensor object
DHT dhtklep(DHTklepPIN, DHTklepTYPE);//Create sensor object

boolean a=LOW,b=LOW;
float h=0,t=0;         //fan sensor
float h1=0,t1=0;       //klep sensor
const int fanPin = 49; //fan pins for temperature control 
const int klepPin = 47; 
//long previousMillis = 0;
//long interval = 1000; //Read sensor each 3 seconds

//Alarm
#include <SPI.h> 
#include <MFRC522.h>
#define SDA_pin 9
#define RESET_pin 8

// Alarm strobe
int alarmLight = A3;
// Screamer or horn
int alarmRelay = A2;
// Valid card indicator
int cardOkLight = A1;
// Entry/exit indicator
int armLight = A0;
int alarmSirene = A4;
// LED flash variable, 0 is off, 1 is on
int pulseOn = 1;
// PIR sensor
int zone1 = 10;
// alarm status, 1 = disarmed, 2 = exiting, 3 = entering, 4 = armed
int alarm_state = 1;
// Counter for entry and exit time when arming and disarming
int entryExitLimit = 30;
int entryExit = 0;
// Counter to turn alarm siren off
int alarmCountLimit = 900;
int alarmCount = 0;

MFRC522 mfrc522(SDA_pin, RESET_pin);


void setup()
{ //temp
  // set the digital pin as output:
pinMode(fanPin, OUTPUT);//Change to output my pins
pinMode(klepPin, OUTPUT);
dhtfan.begin();//Start DHT22 sensor
dhtklep.begin();//Start DHT22 sensor
digitalWrite(fanPin,LOW);//Turn off fan
digitalWrite(klepPin,LOW);//open klep
Serial.begin(9600);

//alarm  
  pinMode(cardOkLight, OUTPUT);
  pinMode(armLight, OUTPUT);
  pinMode(alarmLight, OUTPUT);
  pinMode(alarmRelay, OUTPUT);
  pinMode(zone1, INPUT); 
  pinMode (alarmSirene, OUTPUT); 
  SPI.begin(); 
  mfrc522.PCD_Init();
}

// Get the UID number from the reader output
unsigned long getCardUID(){
  if ( ! mfrc522.PICC_ReadCardSerial()) { 
    return -1;
  }
  unsigned long card_num;
  card_num =  (uint32_t)mfrc522.uid.uidByte[0] << 24;
  card_num += (uint32_t)mfrc522.uid.uidByte[1] << 16;
  card_num += (uint32_t)mfrc522.uid.uidByte[2] <<  8;
  card_num += (uint32_t)mfrc522.uid.uidByte[3];
  mfrc522.PICC_HaltA(); // Stop reading
  return card_num;
}

void loop() {
  // Check if card is present, get UID number and compare to white-listed numbers
  if (mfrc522.PICC_IsNewCardPresent()) {
  unsigned long uid = getCardUID();
  if(uid != -1){
    if (uid == 596879928 || uid == 3877232071) {
      digitalWrite(cardOkLight, HIGH);
      Serial.print("Valid card, UID: ");
      Serial.println(uid); 
      // If alarm_state is disarmed, start exit-timer for arming
      if (alarm_state == 1) {   
        alarm_state = 2;
        entryExit = entryExitLimit;
        Serial.println("Exiting");
      }
      // Disarm apon valid card
      else {
        digitalWrite(armLight, LOW);
        digitalWrite(cardOkLight, HIGH);
        alarm_state = 1;
        entryExit = 0;
        alarmCount = 0;
        digitalWrite(alarmLight, LOW);
        digitalWrite(alarmRelay, LOW);
        Serial.println("Disarmed");
      } 
      delay(500);
      }   
    else {
      digitalWrite(armLight, HIGH);
      Serial.print("Invalid card, UID: ");
      Serial.println(uid); 
      // Pause to allow card indicator LED to show
      delay(500);     
    }
    Serial.println("_");
  }
    
  }
  // Manage indicator LEDs
  else {
     digitalWrite(cardOkLight, LOW);
     if (entryExit == 0 && alarm_state != 4) { // If not armed
     digitalWrite(armLight, LOW);
     digitalWrite(cardOkLight, HIGH);
     }
     if (alarmCount == 0 && alarm_state != 5) { // If not in alarm
     //  digitalWrite(alarmLight, LOW);
     }
  }
  delay(1000);
  // Check entry and exit counters and react
  if (entryExit > 0) {
    if (entryExit == 1 && alarm_state == 2) { // End exit countdown, arm system
      alarm_state = 4; // Armed
      entryExit = 0;
      digitalWrite(alarmLight, HIGH);
      digitalWrite(armLight, LOW);
      Serial.println("System armed");
    }
    else if (entryExit == 1 && alarm_state == 3) { // Entry time expired, activate alarm
      alarm_state = 5;
      Serial.println("ALARM!!!");
      alarmCount = alarmCountLimit;
      entryExit = 0;
      digitalWrite(alarmLight, HIGH);
      digitalWrite(cardOkLight, LOW);
      
    }    
    else {   // Control flashing Exit/Entry indicator LED
    Serial.println(entryExit);
    if (pulseOn == 1) {
      digitalWrite(armLight, LOW);
      pulseOn = 0;
    }   
    else {
      digitalWrite(armLight, HIGH);
      pulseOn = 1;
    }  
    entryExit--;
    }

  } 
  // If system is in alarm, manage flashing alarm light and horn
  if (alarmCount > 0) {  
    Serial.println(alarmCount);    
    if (pulseOn == 1 && alarmCount > 1) {
      digitalWrite(alarmLight, LOW);
      digitalWrite(alarmRelay, LOW);
      digitalWrite(cardOkLight, LOW);
      digitalWrite(alarmSirene, LOW);
      pulseOn = 0;
    }   
    else {
      digitalWrite(alarmLight, HIGH);
      digitalWrite(alarmRelay, HIGH);
      digitalWrite(cardOkLight, LOW);
      digitalWrite(alarmSirene, HIGH);
      pulseOn = 1;
    }
    if (alarmCount == 1) { // Set alarm to silent, leave alarm LED solid
        digitalWrite(alarmLight, HIGH);
        digitalWrite(alarmRelay, LOW);
        Serial.println("Silent");
    }
    alarmCount--;    
  }
  
  // Check PIR sensors for movement if armed and start entry counter
  if (alarm_state == 4 && digitalRead(zone1) == HIGH) {
    entryExit = entryExitLimit;
    pulseOn = 1;
    alarm_state = 3;
    digitalWrite(alarmLight, HIGH);
    digitalWrite(cardOkLight, LOW);
    }
  {
// temp regeling
     h = dhtfan.readHumidity();//humidity value
     t = dhtfan.readTemperature();//temperature value centigrades if you want farenheit change to
     h1 = dhtklep.readHumidity();//humidity value
     t1 = dhtklep.readTemperature();//temperature value centigrades if you want farenheit change to
     //t = dht.readTemperature(true);
     //Below is for print data sensors in lcd 
     Serial.println ("                     ");
     Serial.print("fan temperatuur     "  );
     Serial.print(t  );
     Serial.print("          luchtvochtigheid    ");
     Serial.print(h );
     Serial.println ("                     ");
     Serial.print("klep temperatuur    "  );
     Serial.print(t1  );
     Serial.print("         luchtvochtigheid    " );
     Serial.print(h1 );
    
    if(t>=25 && a==LOW)//if temperature above of 25 degrees
    {
      digitalWrite(fanPin,HIGH);//Active air conditioner
      a=HIGH;
     
    }
    else if(t<=23&&a==HIGH)//if temperature is under 23 degrees
    {
      digitalWrite(fanPin,LOW);//Turn off air conditioner
      a=LOW;
        }

     if(t1>=25 && b==LOW)//if temperature above of 25 degrees
    {
      digitalWrite(klepPin,HIGH);//Active air conditioner
      b=HIGH;
        
    }
    else if(t1<=23 && b==HIGH)//if temperature is under 23 degrees
    {
      digitalWrite(klepPin,LOW);//Turn off air conditioner
      b=LOW;
    }
    
  }
}

The ENC28J60 is a very simple Ethernet interface. To use TCP/IP you will have to put the entire TCP/IP 'stack' in the Arduino and that makes the ENC28J60 library very large. Running on an Arduino UNO or Nano you won't have much memory left for your sketch.

Modern Ethernet cards with Wiznet chips can do all the TCP/IP operations in the network ghip, saving lots of room on the Arduino.

I have the mega for this project.

this is what i have.
I will unfortunately have to deal with that too. due to circumstances there is no money available for hobby now. only for urgently needed groceries and hospital visits. otherwise I would have ordered a GSM shield instead of using the internet controller.
and I still can't get this to work unfortunately

Have you tried this library?

ga ik eens naar kijken. volgens mij nog niet

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.