Coin change machine - overview via internet?

Hi!

I’m building a coin change machine. Besides the arduino uno, it will use a note/bill mech and a coin hopper to pay out the coins. I already have the code ready for the project, but when I saw the arduino ethernet ( http://store.arduino.cc/index.php?main_page=product_info&products_code=A000068 ) that basically is a arduino uno with ethernet connection, I started thinking…

What I want is to be able to remotely over internet view the activity of the arduino. The only thing I need to see is the counter/activity, just to see that the machine is working (no activity means that a coin is jammed, the note mech don’t work etc.) I don’t need the ability to change code over internet, just to view the activity.

Is this something that is easy to do, without changing the original code a lot?

thanks!

You need to turn the arduino into a simple web server to report the activities of its functions in html format for a browser to see.

This should get you started http://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/

Consider using a Yun which has a a small Linux PC with WiFi and Ethernet and a Leonardo all on one board. You can program the Linux side with Python using, for example, the Bottle web framework.

...R

Hi!

I’m not that skilled in coding (coding newbie, but I’m trying) so I’m going to use craynerd’s (here on the forums) code:

// Raynerd Change Machine ****
/* This code controls both a coin hopper which dispences 10 pence coins and a 6 coin acceptor. The 6 coins acceptor pulses on coinSelectorPin"2" - 1 pulse = £1, 2 pulse = 2p, 3pulses = 5p...
The arduino reads which code has been inserted and dispences the appropriate number of 10 pence coins. e.g. £1 = 10x10p    50p = 5x10p
*/

//**************Variables ****************
volatile byte coinPulseCount=0;    // a counter to see how many times the pin has changed - which coin inserted
volatile byte hopperPulseCount = 0;  // a counter to she how many coins have been ejected 
volatile unsigned long pulseTime;  //this stores the time of the last pulse.
byte newCoinInserted; // a place to put our last coin pulse count
byte coinValue = 0;      // number of pulses required to dispence each coin type.
byte twoPence = 0;       // count 5x 2 pences to dispence 10p
byte fivePence = 0;      // count 2x 5 pences to dispence 10p
//***********************************************************************************************
byte pulseThreshold = 500;  //EDIT THIS VALUE TO CHANGE DELAY BETWEEN DETECTING BANK OF PULSES
//***********************************************************************************************

//************Pins Used *******************
int hopperPin = 2;  // pin2 as optical count input 
int coinSelectorPin = 3;  // pin3 as optical count input
int relayPin = 7;  // pin7 output relay



void setup() 
{
  Serial.begin(9600);

  //**** pinModes *************
  pinMode(hopperPin, INPUT_PULLUP);       //hopper optical count is an input
  pinMode(coinSelectorPin, INPUT_PULLUP); //coin selector optical input
  pinMode (relayPin, OUTPUT);      //relay pin output
  digitalWrite(relayPin, HIGH);   //turn off relay - active LOW.
  digitalWrite(hopperPin, HIGH); //use the internal pullup resistor on the hopper optical input  

  attachInterrupt(1, coinacceptor, FALLING); // CoinAcceptor - attach a PinChange Interrupt to our on the rising edge - link to coinacceptor function
  attachInterrupt(0, hopper, FALLING); // Hopper - attach a PinChange Interrupt to our pin on the falling edge - link to hopper function

}

void loop()
{  
  //CHECK NOW TO SEE WHICH COIN IS INSERTED 
  if (coinPulseCount >0 && millis()- pulseTime > pulseThreshold)    //if there is a coin count & the time between now and the last pulse is greater than 1/4 of a second - THE END OF BANK OF PULSES
  {
    newCoinInserted = coinPulseCount;  //new variable to free up coinPulseCount on the interrupt.
    Serial.print("newCoinInserted pulses ");
    Serial.println(newCoinInserted);         // print the pulses of the new coin inserted.
    
    coinPulseCount = 0;                // clear pulse count ready for a new pulse on the interrupt.
   
  }

  //Proccess the coin inserted

  switch (newCoinInserted) {

  case 1:  
    Serial.println("£1 inserted");   //1 pulse from validator - £1 INSERTED
    newCoinInserted = 0;   //reset - ALTHOUGH DO I NEED TO DO THIS?
    coinValue = 10;        //hopper dispense 10 pulses/coins
    dispence();
    break; 

    case 2:      //2 pulses from Validor - 2p INSERTED    
     Serial.println("2p inserted");
     newCoinInserted = 0;
     twoPence++;                    //variable to hold two pence count - twoPence needs to get to 5 to dispence
     if (twoPence == 5)
     { 
     coinValue = 1;
     dispence();
     twoPence = 0;     // reset twoPence variable 
     }   
     break;
     
     case 3:    
     Serial.println("5p inserted");
     Serial.print("How many fives = ");
     Serial.println(fivePence);
     newCoinInserted = 0;
     fivePence++;
     if (fivePence == 2)
     {
     coinValue = 1;   
     dispence();
     fivePence = 0;
     }
     break;
     
  case 4:    
    Serial.println("10p inserted");
    newCoinInserted = 0;
    coinValue =1; 
    coinPulseCount = 0;                // clear pulse count ready for a new pulse on the interrupt.
    dispence();  
    
    break;

  case 5:    
    Serial.println("20p inserted");
    newCoinInserted = 0;
    coinValue = 2;  
    dispence(); 
    break;

  case 6:  
    Serial.println("50p inserted");
    newCoinInserted = 0;   
    coinValue = 5;
    dispence();
    break;
  } 
}
//*****INTERUPT detecting pulses from the coin acceptor
void coinacceptor()      //Function called when coin enters coin acceptor
{
  coinPulseCount++;
  pulseTime = millis();   //store current time in pulseTime
}

//******INTERUPT detecting pulses from the hopper
void hopper()           //function called when a coin is ejected from the hopper
{
  hopperPulseCount++ ;
}

void dispence()
{
  digitalWrite(relayPin, LOW);   //turn on relay - active LOW.
  delay(50);  
  hopperPulseCount =0;

  while (hopperPulseCount < coinValue)     
  {
    //do nothing and wait with the relay on dispencing coins until it hits the "coinValue"
  }
  
  delay(50);    //wait to ensure the coin has enough momentum to leave hopper but not long enough for another coins to dispence!
  digitalWrite(relayPin, HIGH);   //turn off relay - active LOW.  

//**************************************************************************************  
  delay(180);
  coinPulseCount = 0;   // ERROR IN SPIKES - hopper pulsing effects coin acceptor pulse line!
  //************************************************************************************** 
  
}

Therefore I don’t want to write a new code, just add some so that I can connect to the arduino and view the activity :slight_smile:

mistergreen:
You need to turn the arduino into a simple web server to report the activities of its functions in html format for a browser to see.

This should get you started
http://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/

Thanks! Looking at it now :slight_smile: Looks promising!

I looked through most of the guide now, and I found out how I can get it to display if a button/input (the note mech) is pressed right now. However that require me to be on the computer exactly when a note is inserted, which is not ideal. I would like to see a counter/history that I has been pressed previously. For instance I log in today, it is pressed (notes inserted) 10 times. Tomorrow when I log in I can see that the button has been pressed (notes inserted) 12 times. Then I now that 2 notes have been inserted since yesterday, and the machine works..

If you want a history of something, you'll need to keep a log whether a simple text file or a database. The database route is another technology you'll have to figure out.

mistergreen: If you want a history of something, you'll need to keep a log whether a simple text file or a database. The database route is another technology you'll have to figure out.

A simple text file would be more then enough. I do not need anything to be advanced or pretty, I just want to be able to read if the machine is working :)

You can keep a simple text log with time stamp on an SD card and then have the web server read the text file and serve it up as html or a simple link for you to download the file directly. You'll need an RTC if you'll need a time stamp.

Hi!

To have a log with dates would be great, but it is not necessary. If I can see that "the button has been pressed 10 times" on monday and when I check on tuesday and it says that "the button has been pressed 12 times" then I understand that the machine is operating and working. Do anyone have any pointers to any guide to make a log file?

So I found a guide to make a text log on the SD-card: http://makecourse.weebly.com/sd-card-data-logging.html

Then I guess the rest will be fairly easy, just need a way to get it displayed on the web page on the arduino :)

Hi Twarr, I think your nick is from russian language :) but I would like to ask have you build the coin change mashine?

Can someone teach me how to make coin changer step by step, parts by parts. im not good at programming