Categories
Statistics
Flag Counter
Since 08.08.2014
Counts only, if "DNT = disabled".

Your IP is 54.225.42.99
ec2-54-225-42-99.compute-1.a
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
Your valuable opinion :
5 stars

Avg. 5.00 from 3 votes.



Marry You by Bruno Mars
Arduino-Project-MrBean.php   12369 Bytes    04-04-2017 18:47:44


Arduino/Genuino Project : Coffee Tally Sheet


Project : "MR. BEAN"



This is the second version of our "Coffee Tally Sheet". It uses an Arduino/Genuino together with an RFID antenna from Big C. (TowiTek TWT2021) It uses the Software Serial Library together with an ETHernet 2 shield to monitor coffee consumption and billing. The overview mayst be seen her : www.nesweb.ch


Arduino/Genuino RFID Reader






✈ Motivation




Managing the coffee consumption and billing is burdensome. This project handles the payments as well as the consumption. Whenever someone takes a coffee, he/she is expected to "make a dash on the tally sheet". Yes, the success rate is similiar to the "classic" system with that pencil. And yes, our "customers" are curious and try to trick the system or "forget" to pay for their coffee. But, we believe, that this system facilitates the life of the barista. Instead of going around every end of the month to collect the payments, we encourage our students to show up and pay when they have money and feel like paying. Sometimes empty coffee pads boxes are necessary to remind them of that ...




✈ System




The system consists of an Arduino/Genuino, an ETHernet2 shield and an antenna (TowiTek TWT2021) from Big C. Happily the antenna already does some error correction and does deliver only valid RFID-SerialNumbers. If a user swipes his/her rfid-tag, the counter is incremented by one. For that, the Arduino/Genuino (UNO) makes a http-request to the website. With GET, the user-id and a very secret password is handed over. If the user-id file is found, the counter is incremented. If not, the counter in an error-file is incremented. By that, you can keep track of the 'failures'. In case the coffee-drinker makes a payment, the amount is added to the file user-money. Another file is user-nickname, as we don't want the real name to appear on the overview in order to make any correlation between a person and their coffee-consumption harder. After an rfid-tag has been read, a piezo beeper beeps for approx. 0.5 sec to indicate the user, that the card/tag has been read successfully. After that a delay of 5 sec is introduced, in order to avoid multiple chargeing :-)




✈ Sketch for Arduino/Genuino • TRANSMITTER



Double click on code to select ...

/* ///////////////////////////////////////////////////////////// 
ARDUINO/Genuino (UNO) Test/Demo Sketch for RFID ANTENNA 
MODEL "TOWI TEK" FROM BIG C, #191553
Software Version 1.0, 
04.04.2017, Alexander C. Frank
Pin 10 on the ethernet shield is CS for the W5500, and pin 4 
is CS for the micro SD card reader.
//////////////////////////////////////////////////////////////*/

#include <SoftwareSerial.h>
#include <SPI.h>
#include <Ethernet2.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xB4, 0x13} ;
char server[] = "www.nesweb.ch";
IPAddress ip(192, 168, 0, 177);
EthernetClient client;
SoftwareSerial RFID(9, 8); // RX, TX

byte data ;
byte RingBuffer[5] ;
unsigned int RingBufferPointer = 0 ;
boolean NewTag = false ;
String UserId = "";
const char EndOfString = '\0' ;
String TopSecretPassWord ="HIGHSECURITYULTRALONGPASSWORDGOESHERE" ;
String Answer = "" ;
const int BEEP = A0 ;


void setup() 
{
  Serial.begin(57600);
  pinMode( 4, OUTPUT );
  digitalWrite( 4, HIGH );
  pinMode( BEEP, OUTPUT );
  digitalWrite( BEEP, HIGH );
  delay(2000);
  digitalWrite( BEEP, LOW );
  // set the data rate for the SoftwareSerial port
  RFID.begin(9600);
  delay(3000);
  Serial.println("Setup Software Serial Port @ 9600 : DONE.");
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) 
  {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
    Serial.println("Try to configure using IP address instead of DHCP");
  }
  // give the Ethernet shield a second+ to initialise:
  delay(10000);
  Serial.println("Setup finished.");  
}

void loop() 
{  
  if (RFID.available()) 
  {
    data = RFID.read();
    RingBuffer[RingBufferPointer] = data ;
    RingBufferPointer += 1 ;
    if (RingBufferPointer > 4) RingBufferPointer = 0; 
    if (RingBufferPointer == 4) NewTag = true ;  
  }
  else
  {
    if (NewTag) 
      {
      // HACK & PASTE TOGETHER THAT USER-ID THING
      UserId = "";
      for (int i=0; i<5; i++)
      {
        if (RingBuffer[i] < 0x10) UserId += "0" ;
        UserId += String(RingBuffer[i],HEX);
      }
      // UserId += EndOfString ;
      Serial.println(UserId);
      digitalWrite( BEEP, HIGH );
      delay(500);
      digitalWrite( BEEP, LOW ); 
      delay(7500);
      // HTTP REQUEST //
      if (client.connect(server, 80))
      {
      delay(10);
      // Make a HTTP request:
      Answer = "GET /mes.php?user-id="; Answer += UserId ;
      Answer += "&password="; Answer += TopSecretPassWord ; 
      Answer += " HTTP/1.1";
      client.println(Answer);
      client.println("Host: www.nesweb.ch");
      client.println("Connection: close");
      client.println();
      client.stop();
      Serial.println(Answer);
      }
      if (!client.connected()) 
      {
        Serial.println("disconnecting.\n");
        client.stop();
      }
      UserId = "";
      NewTag = false ;
      RingBufferPointer = 0;

    }
    delay(20);
  }

}

// ///////////////////////////////////////////////////////////// 
// END OF FILE.
// ///////////////////////////////////////////////////////////// 




✈ PHP Script for the website • RECEIVER



Double click on code to select ...

		
<?php
/*******************************************************************************
*  Title: mes.php (part of COCO)
*  Mach En Strich
*  Version: 1.0 May 28, 2013
*  Version: 2.0 August 17, 2015 : if user_id unknown >> use "error"
*  Author: Alexander C. Frank
*  Website: http://www.nesweb.ch
*******************************************************************************/

// GET USER-ID
$user = $_GET["user-id"];
// AND PASSWORD :-)
$check = $_GET["password"];

if ($check == 'HIGHSECURITYULTRALONGPASSWORDGOESHERE') 

	{

	$filename = ('PATHTODATAFILES/' . $user . '_cups.txt');

	if (file_exists($filename)) 
		{
		// OPEN FILE
		$datei = fopen($filename,'r');
		
		// WE ASSUME MAXIMUM 10 DIGITS
		$cups = fgets($datei, 10);
		
		// CLOSE FILE
		fclose($datei);
		
		// INCREMENT COUNTER
		$cups = $cups + 1 ;
	
		// OPEN FILE
		$datei = fopen($filename,'w');
		fwrite($datei, $cups. "\n");
		fclose($datei);
		}
	 	
	else 
	
		{
		// COLLECT UNKNOWN RFID SOMEWHERE ELSE
		$filename = ('PATHTODATAFILES/error_cups.txt');
		// OPEN FILE
		$datei = fopen($filename,'r');
		
		// WE ASSUME MAXIMUM 10 DIGITS
		$cups = fgets($datei, 10);
		
		// CLOSE FILE
		fclose($datei);
		
		// INCREMENT COUNTER
		$cups = $cups + 1 ;
	
		// OPEN FILE
		$datei = fopen($filename,'w');
		fwrite($datei, $cups. "\n");
		fclose($datei);
		
		// EMAIL TO BARISTA
		$empfaenger = 'YOUREMAILGOESHERE';
		$betreff = 'COFFEE ALARM';
		$nachricht = 'COFFEE ALARM : ' . $user ;
		$header = 'From: barista@nesweb.ch' . "\r\n" .
		    'Reply-To: barista@nesweb.ch' . "\r\n" .
		    'X-Mailer: PHP/' . phpversion();
		
		mail($empfaenger, $betreff, $nachricht, $header);
		}
	} 
?>




Arduino/Genuino RFID Reader

The second version now accepts almost everything - talking at 125 kHz




✈ Share your thoughts


✈ Nothing more to be seen below this point ? Maybe your browser blocks the facebook iframe.
The webmaster does not read the comments regularly. Urgent questions should be send via email.








 
t1 = 3943 d

t2 = 551 ms

★ ★ ★  Copyright © 2006 - 2017 by changpuak.ch  ★ ★ ★

PRchecker.info Impressum