| NFC Maglock fridge with colour changing led lights | |
|
|
Author | Message |
---|
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: NFC Maglock fridge with colour changing led lights Thu 9 Mar - 15:30 | |
| 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 | |
|
| |
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: NFC Maglock fridge with colour changing led lights Thu 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 | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Fri 10 Mar - 15:19 | |
| so... here we are at prototype stage 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; | |
|
| |
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: NFC Maglock fridge with colour changing led lights Sat 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.pdfWe currently work to improve the english tutorial, to add the smarphone communication, and the relay shield. | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Sun 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); }
| |
|
| |
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: NFC Maglock fridge with colour changing led lights Sun 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); }
| |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 12:13 | |
| | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 12:23 | |
| | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 18:42 | |
| | |
|
| |
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: NFC Maglock fridge with colour changing led lights Tue 14 Mar - 14:57 | |
| Hi Russell; I can't see your video from my computer, have you another link? | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Tue 14 Mar - 15:10 | |
| | |
|
| |
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: NFC Maglock fridge with colour changing led lights Tue 14 Mar - 15:13 | |
| Nice job! The lights are really cool, where does they come from? | |
|
| |
rabbidruss beginner
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
| Subject: Re: NFC Maglock fridge with colour changing led lights Tue 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... | |
|
| |
Sponsored content
| Subject: Re: NFC Maglock fridge with colour changing led lights | |
| |
|
| |
| NFC Maglock fridge with colour changing led lights | |
|