Arduino at a car wash, part 2

    We continue to review the use of Arduino for self-service car washes. Consider working on a network and communicating with a Cashcode bill acceptor. Start see here .

    Internet client

    We immediately activate the client and server:

    EthernetServer server(80);
    byte mac[] = { 0xDE, 0x23, 0xBE, 0xEF, 0xFE, 0xED };
      IPAddress ip(192, 168, 1, 100);
      Ethernet.begin(mac, ip);

    We send information to the server, for example, about the accepted bill:

    int sendInfo(string pay)
    EthernetClient client;
      if (client.connect(domenip, 80) )
        client.println("GET /get_money.php?pay="+pay+" HTTP/1.1");  
        client.println("Connection: keep-alive");
      } else  { Serial.println("connection failed"); return 0; }
      char c;  
      while (client.available())
      return (1);


    Activated in the previous section. Check for requests.

    for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
        EthernetClient sclient = server.available_(sock);

    We fulfill the request. In the response, we display the current value of the cost of a minute of equipment (timers).

    void myserver(EthernetClient client)
      if (!client) return;
      char clientline[100]; 
      int index = 0;
      while (client.available()) {
          char c =;
          if(index<99) clientline[index] = c;
      if(strstr(clientline, "water")!=NULL) digitalWrite(2, LOW); //вода
      if(strstr(clientline, "pena")!=NULL) digitalWrite(3, LOW); //пена
      if(strstr(clientline, "vosk")!=NULL) digitalWrite(4, LOW); //воск
      client.println("HTTP/1.1 200 OK");  client.println("Content-Type: text/html");  client.println("Connection: close"); client.println();
      client.println(""); client.println("");
      for (int j = 1; j < 6; j++) {
             client.print("timer "); client.print(j);  client.print(" is "); client.print(;  client.println("
    "); } client.println(""); delay(100); client.stop(); }

    Bill acceptor Cashcode

    It works through the serial port at TTL levels using the SoftwareSerial library.

    SoftwareSerial mySerial(14, 15); // RX, TX
    uint8_t poll[] = {0x02, 0x03, 0x06, 0x33, 0xDA, 0x81};
    uint8_t ack[] = {0x02, 0x03, 0x06, 0x00, 0x0C2, 0x82};

    As I already said, Cashcode works under the CCNET protocol. There are options, you need to check with the seller. The essence of the protocol is that the system periodically (several times per second is enough) asks the bill acceptor for its status (POOL command). He answers. If the response contains information, you need to confirm its receipt by the appropriate command (ACK).

    Command format: SYNC ADR LNG CMD DATA CRC

    SYNC: 1 byte code [02H]
    ADR: 1 byte address of the bill acceptor
    LNG: 1 byte * data length
    CMD: 1 byte command
    DATA 0 to 250 bytes
    CRC data : 2 bytes checksum

    Send a command.

    void sendCCNET(uint8_t *com)
      for(char i=0; i

    Если купюроприёмник прислал нам в ответе команду 0x81, значит он принял купюру. В данных содержится номинал. У меня это: 2=10 рублей, 3=50 рублей, 4=100 рублей, 5=500 рублей, 6=1000 рублей, 7=5000 рублей. Возможны варианты, зависит от прошивки.

    Also popular now: