I made some new stuff on this project. Now it has a «working» pre-prototype that can do Wifi+RFID+WS2812 Led ring.

The principle

The system connects to Wifi, and use the leds to display the status. When an RFID tag is scanned, the color of the led ring changes. That’s simple, and stupid because not recognized cards don’t do anything. But this step wasn’t meant to really have functionality. When a TAG is recognized, the ESP send UDP packets to a specific server. I’ll use TCP later, but UDP was better for some tests I did (didn’t worry the server was accessible or not for example).

The realization

I had a small polypropylene case in which the initial project was already. So I just did lasercut a circular hole in the front the size of the led ring, lasercut a translucent acrylic disc that did fit exactly in that hole (same settings, polypropylene expands a bit when cut). At the same time I did cut and etch a small metallic/acrylic for the front because why not.

A little bit of soldering (I’ll give a schematic one day) and some magic hot glue, the prototype is ready to roll. As you can see on the first picture and the second one, I did put the rfid antenna around the led ring, it fits perfectly. I did loose a little bit in range, but that’s still perfectly fine (and a 2 layer acrylic panel would resolve that issue).

The inside The led and the rfid The front

Here is a video of the device working (with a little addon to test the speed of animation of the leds). I didn’t debounce the cards, so you can see the second card is detected twice.

Computer side

On the server, I just did run a netcat.

nc -luvp 1234

Source code

This is a really ugly source code. I didn’t plan to make anything well written. I just wanted to test each modules together see if the ESP was able to do it.

#include <ESP8266WiFi.h>
#include <SPI.h>
#include <NeoPixelBus.h>
#include <WiFiUdp.h>

// No I'm not going to give you my tags IDs, IPs and so on
IPAddress server(10, 0, 0, 1); // IP adress of your computer
short int udpport = 1234;

const char *goodcard = "000000000"; // ID of the good card
const char *badcard = "000000001"; // ID of the bad card
const char *lyncard = "000000002"; // ID of the lyn's tag

const char *message_good = "GOOD";
const char *message_bad = "BAD";
const char *message_lyn = "LYN";

const char *ssid =  "foo";     // change according to your Network - cannot be longer than 32 characters!
const char *pass =  "bar"; // change according to your Network


const uint16_t PixelCount = 8; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 2;  // make sure to set this to the correct pin, ignored for Esp8266

#define colorSaturation 128

NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(PixelCount, PixelPin);

RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor purple(64, 0, 64);
RgbColor blue(0, 0, colorSaturation);

WiFiUDP UDP;
int  val = 0; 
char code[10]; 
int bytesread = 0; 

void setup() {
	Serial.begin(9600);    // Initialize serial communications
	delay(250);
	WiFi.begin(ssid, pass);

	int retries = 0;
	while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
		retries++;
		delay(500);
		Serial.print(".");
	}
	if (WiFi.status() == WL_CONNECTED) {
		Serial.println(F("WiFi connected"));
	}
	strip.Begin();
	strip.Show();
	Serial.println(F("Ready!"));
}
 
void good_card() {
	strip.ClearTo(green);
	strip.Show();
}

void bad_card() {
	strip.ClearTo(red);
	strip.Show();
}

void wait_card() {
	strip.ClearTo(blue);
	strip.Show();
}

void purple_card() {
	strip.ClearTo(purple);
	strip.Show();
}

int pos=0;
void loop() { 
// Part of that is coming from
// http://playground.arduino.cc/Learning/PRFID
	if(Serial.available() > 0) {          // if data available from reader 
		if((val = Serial.read()) == 2) {   // check for header 
			bytesread = 0; 
			while(bytesread<10) {              // read 10 digit code 
				if( Serial.available() > 0) { 
					val = Serial.read(); 
					if((val == 2)||(val == 3)) { // if header or stop bytes before the 10 digit reading 
						break;                       // stop reading 
					} 
					code[bytesread] = val;         // add the digit           
					bytesread++;                   // ready to read next digit  
				} 
			} 
			if(bytesread == 10) {              // if 10 digit read is complete 
				Serial.print("TAG code is: ");   // possibly a good TAG 
				UDP.beginPacket(server,udpport);
				Serial.println(code);            // print the TAG code 
				if (strncmp(code,badcard,10)==0) {
					bad_card();
					UDP.write(message_bad,sizeof(message_bad));
          
				}
				if (strncmp(code, goodcard, 10)==0) {
					good_card();
					UDP.write(message_good,sizeof(message_good));
				}
				if (strncmp(code, lyncard, 10)==0) { // Lyn Tag
					purple_card();
					UDP.write(message_lyn,sizeof(message_lyn));
				}
          
				UDP.endPacket();
				UDP.stop();
			} 
			bytesread = 0; 
     
		} 

	} 
	pos+=1;
	if (pos>50) {
		wait_card();
		pos=0;
	}
}