| NFC Maglock fridge with colour changing led lights | |
|
|
Author | Message |
---|
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: NFC Maglock fridge with colour changing led lights Thu 9 Mar - 15:30 | |
| ![NFC Maglock fridge with colour changing led lights Whatsa10](https://i.servimg.com/u/f58/19/64/19/68/whatsa10.jpg) 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 | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
MrStein KeyDuino TEAM
![MrStein](https://2img.net/u/3617/14/19/74/avatars/1-89.png)
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 30 Localisation : Lille, FRANCE
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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 | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights Fri 10 Mar - 15:19 | |
| so... here we are at prototype stage ![NFC Maglock fridge with colour changing led lights Da46d210](https://i.servimg.com/u/f58/19/64/19/68/da46d210.jpg) 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; | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
MrStein KeyDuino TEAM
![MrStein](https://2img.net/u/3617/14/19/74/avatars/1-89.png)
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 30 Localisation : Lille, FRANCE
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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. | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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); }
| |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
MrStein KeyDuino TEAM
![MrStein](https://2img.net/u/3617/14/19/74/avatars/1-89.png)
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 30 Localisation : Lille, FRANCE
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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); }
| |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 12:13 | |
| | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 12:23 | |
| | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights Mon 13 Mar - 18:42 | |
| | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
MrStein KeyDuino TEAM
![MrStein](https://2img.net/u/3617/14/19/74/avatars/1-89.png)
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 30 Localisation : Lille, FRANCE
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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? | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights Tue 14 Mar - 15:10 | |
| | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
MrStein KeyDuino TEAM
![MrStein](https://2img.net/u/3617/14/19/74/avatars/1-89.png)
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 30 Localisation : Lille, FRANCE
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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? | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
rabbidruss beginner
![beginner beginner](https://2img.net/i/itest/ranks/default/default2.gif)
![rabbidruss](https://2img.net/u/3617/14/19/74/avatars/55-23.jpg)
Messages : 10 Reputation : 0 Date d'inscription : 2017-03-01 Localisation : UK
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | 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... | |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
Sponsored content
![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/empty.gif) | Subject: Re: NFC Maglock fridge with colour changing led lights ![NFC Maglock fridge with colour changing led lights Empty](https://2img.net/i/fa/empty.gif) | |
| |
|
![Go down](https://2img.net/i/fa/empty.gif) | |
| NFC Maglock fridge with colour changing led lights | |
|