KeyDuino forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Un échange d'information autour de la carte KeyDuino
 
HomeHome  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 NFC Maglock fridge with colour changing led lights

Go down 
2 posters
AuthorMessage
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyThu 9 Mar - 15:30

NFC Maglock fridge with colour changing led lights Whatsa10

here is the fridge, I will be using the large antenna on the top of the unit the fridge is located in.

More photos tomorrow when I have received all the parts

I may need a little help with code as I am an arduino/keyduino newbie!

Thanks guys

Russell

Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyThu 9 Mar - 15:43

Wo cool project, no problem to help you with the code!

Just be carefull, as NFC works with magnetics fields, any metal part can decrease the reading range Wink

Back to top Go down
https://keyduino.forumsactifs.com
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyFri 10 Mar - 15:19

so... here we are at prototype stage
NFC Maglock fridge with colour changing led lights Da46d210
I just cant get the reader to read one id in the relay shield code...
This bit i just dont understand...

uint8_t RIGHT_UID[] = {0xFF, 0xFF, 0xFF, 0XFF, 0XFF, 0XFF, 0XFF }; //The tag UID you want to activate relays with.

uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;
Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptySat 11 Mar - 8:23

For the RIGHT_UID, you have to change the FF values by your unique uid from the implant.
If you don't know the uid, program the default exemple (tag identification) and open the serial monitor (on the top right of the arduino IDE).

See getting started with your keyduino here: https://github.com/CITCEuraRFID/KeyDuino/blob/master/getting%20started_english.pdf
We currently work to improve the english tutorial, to add the smarphone communication, and the relay shield.


Back to top Go down
https://keyduino.forumsactifs.com
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptySun 12 Mar - 9:33

So I have cut bits out of the NFC box code and chopped in some Relay code.

It does nothing.

Here is the code... Could someone highlight where I have gone wrong?

Code:

/*
 The goal of this sketch is to unlock a "giftbox" with KeyDuino and a NFC tag, via a servomotor.
 Get the ID of your tag, put it in NFC_KEY below.
 When you scan the right tag with KeyDuino, the servo will unlock the box.
 More information in the video of the project: https://www.youtube.com/watch?v=cIedvE9mYfM
 Author: Mr Stein
 Revised by Raymond Borenstein - CITC-EuraRFID
 Compatible with KeyDuino 5.1
 Join http://keyduino.forumsactifs.com/ to ask your questions, suggest your ideas, and show your projects!
 */

#include <KeyDuino.h>

//Define relay pins
#define RELAY_1 12

KeyDuino keyDuino;

uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;

String NFC_KEY_1 = "";
String NFC_KEY_2 = "04998662ca4880";

//Function to open the relay
void changeRelaysState(int state);

void setup(void) {
  Serial.begin(115200);
 
  pinMode(RELAY_1, OUTPUT);


  Serial.println("/!\\ Warning! /!\\");
  Serial.println("Before going on, please check that all relay switches are OFF on the board, then press a key.");
  Serial.println("Otherwise, you may risk to harm the relay shield ...");
  Serial.println("/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\");

  changeRelaysState(LOW);
  Serial.println("Waiting for a tag.");
}

void loop(void) {
  uint8_t success;
  String readID;
  success = keyDuino.readTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
  if (success){
    readID = keyDuino.convertUintToString(uid, uidLength);

    if (readID == NFC_KEY_1 || readID == NFC_KEY_2){
      Serial.println("This is the right tag. Activating relays.");
      changeRelaysState(HIGH);
      delay(2000);
      changeRelaysState(LOW);
      delay(1000);
    }
    else {
      Serial.println("This is not the right tag.");
      delay(500);
    }
  }
}
void changeRelaysState(int state) {
  digitalWrite(RELAY_1, state);
 
}

Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptySun 12 Mar - 11:46

Try this:
Code:
#include "KeyDuino.h"

//Define relay pins
#define RELAY_1 7
#define RELAY_2 6
#define RELAY_3 5
#define RELAY_4 4

#define CHECK_ID true //Change to "true" if you want to check the good ID. If false, every tag will be accepted.
String NFC_KEY_1 = "04df7e2a763c80"; //The tag n°1 UID you want to activate relays with.
String NFC_KEY_2 = "04998662ca4880"; //The tag n°2 UID you want to activate relays with.


uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;

KeyDuino keyDuino;

void changeRelaysState(int state);
boolean UintArrayCompare(uint8_t a[], uint8_t b[], int array_size);

void setup() {
  Serial.begin(115200);
  keyDuino.begin();

  pinMode(RELAY_1, OUTPUT);
  pinMode(RELAY_2, OUTPUT);
  pinMode(RELAY_3, OUTPUT);
  pinMode(RELAY_4, OUTPUT);

  Serial.println("/!\\ Warning! /!\\");
  Serial.println("Before going on, please check that all relay switches are OFF on the board, then press a key.");
  Serial.println("Otherwise, you may risk to harm the relay shield ...");
  Serial.println("/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\/!\\");

  changeRelaysState(LOW);
  Serial.println("Waiting for a tag.");
}

void loop() {
  uint8_t success;
 success = keyDuino.readTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);


  if (success) {
    String readID = keyDuino.convertUintToString(uid, uidLength);
    Serial.print("Tag found: ");
    Serial.println(readID);
   

  if (readID == NFC_KEY_1 || readID == NFC_KEY_2) {
      Serial.println("This is the right tag. Activating relays.");
      changeRelaysState(HIGH);
      delay(2000);
      changeRelaysState(LOW);
      delay(1000);
    }
    else {
      Serial.println("This is not the right tag.");
      delay(500);
    }
  }
}

void changeRelaysState(int state) {
  digitalWrite(RELAY_1, state);
  digitalWrite(RELAY_2, state);
  digitalWrite(RELAY_3, state);
  digitalWrite(RELAY_4, state);
}

boolean UintArrayCompare(uint8_t a[], uint8_t b[], int array_size)
{
  for (int i = 0; i < array_size; i++)
    if (a[i] != b[i])
      return (false);
  return (true);
}
Back to top Go down
https://keyduino.forumsactifs.com
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyMon 13 Mar - 12:13

Perfect! thank you!!
Back to top Go down
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyMon 13 Mar - 12:23

NFC Maglock fridge with colour changing led lights 20170312
NFC Maglock fridge with colour changing led lights 20170311
NFC Maglock fridge with colour changing led lights 20170310
Progress!
Back to top Go down
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyMon 13 Mar - 18:42

Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyTue 14 Mar - 14:57

Hi Russell;
I can't see your video from my computer, have you another link? Smile

Back to top Go down
https://keyduino.forumsactifs.com
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyTue 14 Mar - 15:10

Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 30
Localisation : Lille, FRANCE

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyTue 14 Mar - 15:13

Nice job! The lights are really cool, where does they come from?
Back to top Go down
https://keyduino.forumsactifs.com
rabbidruss
beginner
beginner
rabbidruss


Messages : 10
Reputation : 0
Date d'inscription : 2017-03-01
Localisation : UK

NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights EmptyTue 14 Mar - 15:16

$1 each from india... my little brother brought back 10 or so. They need heatsinks as they get very very hot!
It was just to test the relay and the code you kindly provided me.
Next step is to fit it on the fridge and rig up some lights to flash green or red dependant on the NFC chip used...
Back to top Go down
Sponsored content





NFC Maglock fridge with colour changing led lights Empty
PostSubject: Re: NFC Maglock fridge with colour changing led lights   NFC Maglock fridge with colour changing led lights Empty

Back to top Go down
 
NFC Maglock fridge with colour changing led lights
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
KeyDuino forum :: KeyDuino projects & tutorial :: Projects :: Idea / proposition of project-
Jump to: