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

Your IP is 18.220.137.164
ec2-18-220-137-164.us-east-2
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
27. April 2024
Your valuable opinion :
5 stars

Avg. 6 from 43 votes.



28. April 1950
Arduino-Project-MrBean.php    14080 Bytes    31-05-2023 08:13:17


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.


PLEASE NOTE THAT ARDUINO AND HTTPS DO NOT WORK TOGETHER. THIS PROJECT RAN FINE AT THE HTTP AGE.


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 2.0, 
18.08.2020, 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[] = { 0x99, 0x99, 0x99, 0x99, 0x99, 0x99} ;
char server[] = "www.nesweb.ch";
IPAddress ip(199,199,199,199);
EthernetClient client;
SoftwareSerial RFID(9, 8); // RX, TX

byte data ;
byte RingBuffer[7] ;
unsigned int RingBufferPointer = 0 ;
boolean NewTag = false ;
String UserId = "";
String LastUserId = "580034a7ae";
const char EndOfString = '\0' ;
String TopSecretBuzzWord ="HIGHSECURITYULTRALONGPASSWORDGOESHERE" ;
String Answer = "" ;
unsigned int looping = 0;
const int BEEP = A0 ;
unsigned long FlushTime = 9999 ;
int bytes_from_RFID = 5;


void setup() 
{
  Serial.begin(9600);
  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.");  
 
}
 
boolean GET_RFID() 
{ 
  boolean got_something = false ;
  RingBufferPointer = 0 ;
  if (RFID.available() > 4) 
  {
    RingBuffer[0] = RFID.read();
    RingBuffer[1] = RFID.read();
    RingBuffer[2] = RFID.read();
    RingBuffer[3] = RFID.read();
    RingBuffer[4] = RFID.read();
    got_something = true ;
  }
  UserId = "";
  for (int i=0; i<5; i++)
  {
    if (RingBuffer[i] < 0x10) UserId += "0" ;
    UserId += String(RingBuffer[i],HEX);
  }
  if (got_something)
  {
    Serial.println(UserId);
    digitalWrite( BEEP, HIGH );
    delay(200);
    digitalWrite( BEEP, LOW );
    
    delay(400);
    
    digitalWrite( BEEP, HIGH );
    delay(200);
    digitalWrite( BEEP, LOW );
    
    delay(400);
    
    digitalWrite( BEEP, HIGH );
    delay(200);
    digitalWrite( BEEP, LOW );
    
    delay(400);
    
    digitalWrite( BEEP, HIGH );
    delay(1200);
    digitalWrite( BEEP, LOW );
  }
   
  return got_something ;
}

void FLUSH_RFID() 
{ 
  unsigned long StartTime = millis();
  unsigned long UsedTime = 0 ;
  unsigned long NowTime ;
  byte dummy ;
  delay(1) ;    // StartTime != NowTime
  while (UsedTime < FlushTime)
  {
    if (RFID.available()) dummy = RFID.read();
    // TAKE CARE OF THE OVERFLOW !!!
    NowTime = millis();
    // //////////////////////////////////////////
    if (StartTime > NowTime) 
    {
      UsedTime = 4294967295 - StartTime ;
      UsedTime += NowTime ;
    }
    else 
    {
    UsedTime = NowTime - StartTime ;
    }
    // //////////////////////////////////////////
  }
}

void MES_RFID() 
{ 
  // HTTP REQUEST //
  if (client.connect(server, 80))
  {
    delay(10);
    // Make a HTTP request:
    Answer = "GET /machstrich.php?user-id="; Answer += UserId ;
    Answer += "&buzzword="; Answer += TopSecretBuzzWord ; 
    Answer += " HTTP/1.1";
    client.println(Answer);
    client.println("Host: www.nesweb.ch");
    client.println("Connection: close");
    client.println();
    client.stop();
    Serial.println(Answer);
  }
  else 
  {
  // if you didn't get a connection to the server:
  // STORE THE DATA ON THE SD CARD ...
  Serial.println("connection failed"); 
  }
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) 
  {
    char c = client.read();
    Serial.print(c);
  }
  
  if (!client.connected()) 
  {
    Serial.println("disconnecting.\n");
    client.stop();
  }
}


void loop() 
{  

  if (GET_RFID() )
  {
    MES_RFID() ;
    FLUSH_RFID() ;
  }

  delay(200);
 
}
 
// ///////////////////////////////////////////////////////////// 
// 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



The webmaster does not read these comments regularely. Urgent questions should be send via email. Ads or links to completely uncorrelated things will be removed.


Your Browser says that you allow tracking. Mayst we suggest that you check that DNT thing ?

 
t1 = 6498 d

t2 = 391 ms

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

Impressum