maheshyadav216
Published © CC BY-NC-SA

Smart Waiter - Intelligent Voice Assistant in Restaurant

Restaurant/Hotel Food ordering System using Voice Assistant. Using DFRobot Offline Language Learning Voice Recognition Sensor

IntermediateFull instructions provided12 hours1,012
Smart Waiter - Intelligent Voice Assistant in Restaurant

Things used in this project

Story

Read more

Schematics

Table 1 Hardware

Table 2 Hardware

Manager Desk Hardware

Chef's (Kitchen) Hardware

All Schematics

Code

Code for Table 1 Hardware

C/C++
//=============================================================================================================//
// Project                 - Smart Waiter : Intelligent Voice Assistant in Restaurant 
// Author                  - https://www.hackster.io/maheshyadav216
// Hardware                - SKU_SEN0539-EN_Gravity_Voice_Recognition_Module, NodeMCU ESP32s, Nextion Display
//                           FireBeetleESP32, NodeMCUESP8266, DFplayer Mini
// Softare                 - Arduino IDE 1/ PLatformIO with VSCode, Nextion Editor
// GitHub Repo of Project  - https://github.com/maheshyadav216/Project-Intelligent-Voice-Assistant-in-restaurant
// Code last Modified on   - 20/09/2023
//==============================================================================================================//

// Code of Hardware At table 1 (with NodMCU ESP32S dev Board). Refer Circuit diagram for more details

//Include Important Libraries
#include <Arduino.h>
#include "Nextion.h"
#include "DFRobot_DF2301Q.h"
#include <WiFi.h>
#include <esp_now.h>

//Peripherals pin definitions
#define buzzer 32
#define statLED 33

//Menu codes
uint8_t T1menu[6] = {11, 12, 13, 14, 15, 16};

// REPLACE WITH YOUR ESP RECEIVER'S (managers and Chefs) MAC ADDRESS
uint8_t broadcastAddress1[] = {0x60, 0x01, 0x94, 0x0E, 0xE2, 0xD7};
uint8_t broadcastAddress2[] = {0x80, 0x7D, 0x3A, 0x6E, 0x82, 0xF7};

typedef struct tmenu_struct {
  uint8_t x;
} tmenu_struct;

tmenu_struct t1order;

esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  char macStr[18];
  Serial.print("Packet to: ");
  // Copies the sender mac address to a string
  snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
           mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
  Serial.print(macStr);
  Serial.print(" send status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}

NexPage page0    = NexPage(0, 0, "page0");
NexPage page1    = NexPage(1, 0, "page1");
NexPage page2    = NexPage(2, 0, "page2");
NexPage page3    = NexPage(3, 0, "page3");
NexPage page4    = NexPage(4, 0, "page4");
NexPage page5    = NexPage(5, 0, "page5");
NexPage page6    = NexPage(6, 0, "page6");


//I2C communication
DFRobot_DF2301Q_I2C asr;


void shortBeep(){
  digitalWrite(buzzer, HIGH);
  delay(100);
  digitalWrite(buzzer, LOW);
}

void longBeep(){
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
}

void setup() {
  Serial.begin(115200);
  nexInit();
  page0.show(); 

// Peripherals pin definitions
  pinMode(buzzer, OUTPUT);
  pinMode(statLED, OUTPUT);
  digitalWrite(buzzer, LOW);
  digitalWrite(statLED, LOW);
  
  // Init the sensor
  while (!(asr.begin())) {
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }
  Serial.println("Begin ok!");

  /**
   * @brief Set voice volume
   * @param voc - Volume value(1~7)
   */
  asr.setVolume(7);

  /**
     @brief Set mute mode
     @param mode - Mute mode; set value 1: mute, 0: unmute
  */
  asr.setMuteMode(0);

  /**
     @brief Set wake-up duration
     @param wakeTime - Wake-up duration (0-255)
  */
  asr.setWakeTime(8);

  /**
     @brief Get wake-up duration
     @return The currently-set wake-up period
  */
  uint8_t wakeTime = 0;
  wakeTime = asr.getWakeTime();
  Serial.print("wakeTime = ");
  Serial.println(wakeTime);

  // asr.playByCMDID(1);   // Wake-up command

  /**
     @brief Play the corresponding reply audio according to the ID
     @param CMDID - command word ID
  */
  //asr.playByCMDID(23);  // Command word ID

  WiFi.mode(WIFI_STA);
 
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  esp_now_register_send_cb(OnDataSent);

  // register peer
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;

  // register first peer - The Manager
  memcpy(peerInfo.peer_addr, broadcastAddress1, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
  // register second peer - The Chef/cook
  memcpy(peerInfo.peer_addr, broadcastAddress2, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
}

void sendOrder(uint8_t value){
//ESPnow order sent to man-and-chef
  t1order.x = value;
  esp_err_t result = esp_now_send(0, (uint8_t *) &t1order, sizeof(tmenu_struct));
  
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
}

void loop() {
  /**
     @brief Get the ID corresponding to the command word 
     @return Return the obtained command word ID, returning 0 means no valid ID is obtained
  */
  page0.show();
  uint8_t CMDID = asr.getCMDID();
  switch (CMDID) {
    case 5:                                                               //If the command is “Order Vada Pav”
      page1.show();                                                       //Show page 1
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[0]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Vada Pav',command flag'5'");         //Serial transmits "received"Order Vada pav",command flag"5
      digitalWrite(statLED, LOW);
      break;

    case 11:                                                               //If the command is “Order Vada Pav”
      page1.show();                                                       //Show page 1
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[0]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Vada Pav',command flag'11'");         //Serial transmits "received"Order Vada pav",command flag"11
      digitalWrite(statLED, LOW);
      break;

    case 6:                                                               //If the command is “Order IDLI Sambar”
      page2.show();                                                       //Show page 2
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[1]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order IDLI Sambar',command flag'6'");      //Serial transmits "received"Order IDLI Sambar",command flag"6
      digitalWrite(statLED, LOW);
      break;

    case 12:                                                               //If the command is “Order IDLI Sambar”
      page2.show();                                                       //Show page 2
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[1]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order IDLI Sambar',command flag'12'");      //Serial transmits "received"Order IDLI Sambar",command flag"12
      digitalWrite(statLED, LOW);
      break;
      

    case 7:                                                               //If the command is “Order Rice Plate”
      page3.show();                                                       //Show page 3
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[2]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Rice Plate',command flag'7'");       //Serial transmits "received"Order Rice Plate",command flag"7
      digitalWrite(statLED, LOW);
      break;

    case 13:                                                               //If the command is “Order Rice Plate”
      page3.show();                                                       //Show page 3
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[2]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Rice Plate',command flag'13'");       //Serial transmits "received"Order Rice Plate",command flag"13
      digitalWrite(statLED, LOW);
      break;

    case 8:                                                               //If the command is “Order Butter Chicken”
      page4.show();                                                       //Show page 5
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[3]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Samosa',command flag'8'");           //Serial transmits "received"Order Samosa",command flag"8
      digitalWrite(statLED, LOW);
      break;
      
    case 14:                                                               //If the command is “Order Butter Chicken”
      page4.show();                                                       //Show page 5
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[3]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Samosa',command flag'14'");           //Serial transmits "received"Order Samosa",command flag"14
      digitalWrite(statLED, LOW);
      break;

    case 9:                                                               //If the command is “Order Butter Chicken”
      page5.show();                                                       //Show page 4
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[4]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Butter Chicken',command flag'9'");   //Serial transmits "received"Order Butter Chicken",command flag"9
      digitalWrite(statLED, LOW);
      break;

    case 15:                                                               //If the command is “Order Butter Chicken”
      page5.show();                                                       //Show page 4
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[4]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Butter Chicken',command flag'15'");   //Serial transmits "received"Order Butter Chicken",command flag"15
      digitalWrite(statLED, LOW);
      break;
      
    case 10:                                                              //If the command is “Order Biryani”
      page6.show();                                                       //Show page 6
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[5]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Biryani',command flag'10'");          //Serial transmits "received"Order Biryani",command flag"10
      digitalWrite(statLED, LOW);
      break;

    case 16:                                                              //If the command is “Order Biryani”
      page6.show();                                                       //Show page 6
      digitalWrite(statLED, HIGH);
      sendOrder(T1menu[5]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Biryani',command flag'16'");          //Serial transmits "received"Order Biryani",command flag"16
      digitalWrite(statLED, LOW);
      break;

    default:
      if (CMDID != 0) {
        Serial.print("CMDID = ");  //Printing command ID
        Serial.println(CMDID);
      }
  }
  delay(300);
}

//=======================================================================================================================================//

Code for Table 2 Hardware

C/C++
//=============================================================================================================//
// Project                 - Smart Waiter : Intelligent Voice Assistant in Restaurant 
// Author                  - https://www.hackster.io/maheshyadav216
// Hardware                - SKU_SEN0539-EN_Gravity_Voice_Recognition_Module, NodeMCU ESP32s, Nextion Display
//                           FireBeetle 2 ESP32-E, NodeMCUESP8266, DFplayer Mini
// Softare                 - Arduino IDE 1/ PLatformIO with VSCode, Nextion Editor
// GitHub Repo of Project  - https://github.com/maheshyadav216/Project-Intelligent-Voice-Assistant-in-restaurant
// Code last Modified on   - 20/09/2023
//==============================================================================================================//

// Code of Hardware At table 2 (with FireBeetle 2 ESP32-E dev Board). Refer Circuit diagram for more details

//Include Important Libraries
#include <Arduino.h>
#include "DFRobot_DF2301Q.h"
#include "Nextion.h"
#include <WiFi.h>
#include <esp_now.h>

//Peripherals pin definitions
#define buzzer 25
#define statLED 26

//Menu codes
uint8_t T2menu[6] = {21, 22, 23, 24, 25, 26};

// REPLACE WITH YOUR ESP RECEIVER'S MAC ADDRESS
uint8_t broadcastAddress1[] = {0x60, 0x01, 0x94, 0x0E, 0xE2, 0xD7};
uint8_t broadcastAddress2[] = {0x80, 0x7D, 0x3A, 0x6E, 0x82, 0xF7};

typedef struct tmenu_struct {
  uint8_t x;
} tmenu_struct;

tmenu_struct t2order;

esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  char macStr[18];
  Serial.print("Packet to: ");
  // Copies the sender mac address to a string
  snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
           mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
  Serial.print(macStr);
  Serial.print(" send status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}

NexPage page0    = NexPage(0, 0, "page0");
NexPage page1    = NexPage(1, 0, "page1");
NexPage page2    = NexPage(2, 0, "page2");
NexPage page3    = NexPage(3, 0, "page3");
NexPage page4    = NexPage(4, 0, "page4");
NexPage page5    = NexPage(5, 0, "page5");
NexPage page6    = NexPage(6, 0, "page6");


//I2C communication
DFRobot_DF2301Q_I2C asr;


void shortBeep(){
  digitalWrite(buzzer, LOW);
  delay(500);
  digitalWrite(buzzer, HIGH);
  
}

void longBeep(){
  digitalWrite(buzzer, LOW);
  delay(1000);
  digitalWrite(buzzer, HIGH);
}

void setup() {
  Serial.begin(115200);
  nexInit();
  page0.show(); 

// Peripherals pin definitions. Buzzer module is at Active LOW logic
  pinMode(buzzer, OUTPUT);
  pinMode(statLED, OUTPUT);
  digitalWrite(buzzer, HIGH);
  digitalWrite(statLED, LOW);
  
  // Init the sensor
  while (!(asr.begin())) {
    Serial.println("Communication with device failed, please check connection");
    delay(3000);
  }
  Serial.println("Begin ok!");

  /**
   * @brief Set voice volume
   * @param voc - Volume value(1~7)
   */
  asr.setVolume(7);

  /**
     @brief Set mute mode
     @param mode - Mute mode; set value 1: mute, 0: unmute
  */
  asr.setMuteMode(0);

  /**
     @brief Set wake-up duration
     @param wakeTime - Wake-up duration (0-255)
  */
  asr.setWakeTime(8);

  /**
     @brief Get wake-up duration
     @return The currently-set wake-up period
  */
  uint8_t wakeTime = 0;
  wakeTime = asr.getWakeTime();
  Serial.print("wakeTime = ");
  Serial.println(wakeTime);

  //asr.playByCMDID(1);   // Wake-up command

  /**
     @brief Play the corresponding reply audio according to the ID
     @param CMDID - command word ID
  */
  //asr.playByCMDID(23);  // Command word ID

  WiFi.mode(WIFI_STA);
 
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  esp_now_register_send_cb(OnDataSent);

  // register peer
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;

  // register first peer - The Manager
  memcpy(peerInfo.peer_addr, broadcastAddress1, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
  // register second peer - The Chef/cook
  memcpy(peerInfo.peer_addr, broadcastAddress2, 6);
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
}

void sendOrder(uint8_t value){
//ESPnow order sent to man-and-chef
  t2order.x = value;
  esp_err_t result = esp_now_send(0, (uint8_t *) &t2order, sizeof(tmenu_struct));
  
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
}

void loop() {
  /**
     @brief Get the ID corresponding to the command word 
     @return Return the obtained command word ID, returning 0 means no valid ID is obtained
  */
  page0.show();
  uint8_t CMDID = asr.getCMDID();
  switch (CMDID) {
    case 5:                                                               //If the command is “Order Vada Pav”
      page1.show();                                                       //Show page 1
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[0]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Vada Pav',command flag'5'");         //Serial transmits "received"Order Vada pav",command flag"5
      digitalWrite(statLED, LOW);
      break;

    case 11:                                                               //If the command is “Order Vada Pav”
      page1.show();                                                       //Show page 1
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[0]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Vada Pav',command flag'11'");         //Serial transmits "received"Order Vada pav",command flag"11
      digitalWrite(statLED, LOW);
      break;

    case 6:                                                               //If the command is “Order IDLI Sambar”
      page2.show();                                                       //Show page 2
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[1]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order IDLI Sambar',command flag'6'");      //Serial transmits "received"Order IDLI Sambar",command flag"6
      digitalWrite(statLED, LOW);
      break;

    case 12:                                                               //If the command is “Order IDLI Sambar”
      page2.show();                                                       //Show page 2
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[1]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order IDLI Sambar',command flag'12'");      //Serial transmits "received"Order IDLI Sambar",command flag"12
      digitalWrite(statLED, LOW);
      break;
      

    case 7:                                                               //If the command is “Order Rice Plate”
      page3.show();                                                       //Show page 3
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[2]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Rice Plate',command flag'7'");       //Serial transmits "received"Order Rice Plate",command flag"7
      digitalWrite(statLED, LOW);
      break;

    case 13:                                                               //If the command is “Order Rice Plate”
      page3.show();                                                       //Show page 3
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[2]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Rice Plate',command flag'13'");       //Serial transmits "received"Order Rice Plate",command flag"13
      digitalWrite(statLED, LOW);
      break;

    case 8:                                                               //If the command is “Order Butter Chicken”
      page4.show();                                                       //Show page 5
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[3]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Samosa',command flag'8'");           //Serial transmits "received"Order Samosa",command flag"8
      digitalWrite(statLED, LOW);
      break;
      
    case 14:                                                               //If the command is “Order Butter Chicken”
      page4.show();                                                       //Show page 5
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[3]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Samosa',command flag'14'");           //Serial transmits "received"Order Samosa",command flag"14
      digitalWrite(statLED, LOW);
      break;

    case 9:                                                               //If the command is “Order Butter Chicken”
      page5.show();                                                       //Show page 4
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[4]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Butter Chicken',command flag'9'");   //Serial transmits "received"Order Butter Chicken",command flag"9
      digitalWrite(statLED, LOW);
      break;

    case 15:                                                               //If the command is “Order Butter Chicken”
      page5.show();                                                       //Show page 4
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[4]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Butter Chicken',command flag'15'");   //Serial transmits "received"Order Butter Chicken",command flag"15
      digitalWrite(statLED, LOW);
      break;
      
    case 10:                                                              //If the command is “Order Biryani”
      page6.show();                                                       //Show page 6
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[5]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Biryani',command flag'10'");          //Serial transmits "received"Order Biryani",command flag"10
      digitalWrite(statLED, LOW);
      break;

    case 16:                                                              //If the command is “Order Biryani”
      page6.show();                                                       //Show page 6
      digitalWrite(statLED, HIGH);
      sendOrder(T2menu[5]);
      shortBeep();
      delay(3000);
      Serial.println("received'Order Biryani',command flag'16'");          //Serial transmits "received"Order Biryani",command flag"16
      digitalWrite(statLED, LOW);
      break;

    default:
      if (CMDID != 0) {
        Serial.print("CMDID = ");  //Printing command ID
        Serial.println(CMDID);
      }
  }
  delay(300);
}

//========================================================================================================================================//

Code for Manager Desk Hardware

C/C++
//=============================================================================================================//
// Project                 - Smart Waiter : Intelligent Voice Assistant in Restaurant 
// Author                  - https://www.hackster.io/maheshyadav216
// Hardware                - SKU_SEN0539-EN_Gravity_Voice_Recognition_Module, NodeMCU ESP32s, Nextion Display
//                           FireBeetle 2 ESP32-E, NodeMCUESP8266, DFplayer Mini
// Softare                 - Arduino IDE 1/ PLatformIO with VSCode, Nextion Editor
// GitHub Repo of Project  - https://github.com/maheshyadav216/Project-Intelligent-Voice-Assistant-in-restaurant
// Code last Modified on   - 20/09/2023
//==============================================================================================================//

// Code of Hardware At Managers Desk (with NodeMCU ESP8266 dev Board). Refer Circuit diagram for more details

//Include Important Libraries
#include <Arduino.h>
#include "Nextion.h"
#include <ESP8266WiFi.h>
#include <espnow.h>

// Peripheral Pin Definitions
#define buzzer D5
#define statLED D6

// put function declarations here:
NexPage page0    = NexPage(0, 0, "page0");
NexPage page1    = NexPage(1, 0, "page1");


/*
 * Declare a number object [page id:0,component id:3, component name: "n0"]. 
 */
NexNumber n01 = NexNumber(0, 2, "n01");
NexNumber n02 = NexNumber(0, 3, "n02");
NexNumber n03 = NexNumber(0, 4, "n03");
NexNumber n04 = NexNumber(0, 5, "n04");
NexNumber n05 = NexNumber(0, 6, "n05");
NexNumber n06 = NexNumber(0, 7, "n06");

NexNumber n11 = NexNumber(1, 2, "n11");
NexNumber n12 = NexNumber(1, 3, "n12");
NexNumber n13 = NexNumber(1, 4, "n13");
NexNumber n14 = NexNumber(1, 5, "n14");
NexNumber n15 = NexNumber(1, 6, "n15");
NexNumber n16 = NexNumber(1, 7, "n16");


//Structure example to receive data
//Must match the sender structure
typedef struct tmenu_struct {
  uint8_t mcode;
} tmenu_struct;

tmenu_struct myOrder;

//Menu codes
uint8_t T1vada = 0;
uint8_t T1idli = 0;
uint8_t T1rice = 0;
uint8_t T1samosa = 0;
uint8_t T1butter = 0;
uint8_t T1biryani = 0;

uint8_t T2vada = 0;
uint8_t T2idli = 0;
uint8_t T2rice = 0;
uint8_t T2samosa = 0;
uint8_t T2butter = 0;
uint8_t T2biryani = 0;


uint8_t menu_code;


//callback function that will be executed when data is received
void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
  memcpy(&myOrder, incomingData, sizeof(myOrder));
  menu_code = myOrder.mcode;
  //Serial.print("Bytes received: ");
  //Serial.println(len);
  //Serial.print("menu Code: ");
  //Serial.println(myOrder.mcode);
}

void shortBeep(){
  digitalWrite(buzzer, HIGH);
  delay(100);
  digitalWrite(buzzer, LOW);
}

void longBeep(){
  digitalWrite(buzzer, HIGH);
  delay(500);
  digitalWrite(buzzer, LOW);
}

void blinkStat(){
  digitalWrite(statLED, HIGH);
  delay(1000);
  digitalWrite(statLED, LOW);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  nexInit();
  page0.show();

// Peripheral Pin Definitions
  pinMode(buzzer, OUTPUT);
  digitalWrite(buzzer, LOW);
  pinMode(statLED, OUTPUT);
  digitalWrite(statLED, LOW);

  //Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);
  //Init ESP-NOW
  if (esp_now_init() != 0) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  
  // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
  esp_now_register_recv_cb(OnDataRecv);
}

void loop() {
  // put your main code here, to run repeatedly:
  // Check for which code received and Identifiy the food item ordered
  switch(menu_code) {
    case 11:
      shortBeep();
      blinkStat();
      T1vada +=1;
      page0.show();
      n01.setValue(T1vada);
      menu_code = 0;
      break;
    
    case 12:
      shortBeep();
      blinkStat();
      T1idli +=1;
      page0.show();
      n02.setValue(T1idli);
      menu_code = 0;
      break;

    case 13:
      shortBeep();
      blinkStat();     
      T1rice +=1;
      page0.show();
      n03.setValue(T1rice);
      menu_code = 0;
      break;

    case 14:
      shortBeep();
      blinkStat();     
      T1samosa +=1;
      page0.show();
      n04.setValue(T1samosa);
      menu_code = 0;
      break;

    case 15:
      shortBeep();
      blinkStat();
      T1butter +=1;
      page0.show();
      n05.setValue(T1butter);
      menu_code = 0;
      break;

    case 16:
      shortBeep();
      blinkStat();
      T1biryani +=1;
      page0.show();
      n06.setValue(T1biryani);
      menu_code = 0;
      break;   

    case 21:
      shortBeep();
      blinkStat();
      T2vada +=1;
      page1.show();
      n11.setValue(T2vada);
      menu_code = 0;
      break;
    
    case 22:
      shortBeep();
      blinkStat();
      T2idli +=1;
      page1.show();
      n12.setValue(T2idli);
      menu_code = 0;
      break;

    case 23:
      shortBeep();
      blinkStat();
      T2rice +=1;
      page1.show();
      n13.setValue(T2rice);
      menu_code = 0;
      break;

    case 24:
      shortBeep();
      blinkStat();
      T2samosa +=1;
      page1.show();
      n14.setValue(T2samosa);
      menu_code = 0;
      break;

    case 25:
      shortBeep();
      blinkStat();
      T2butter +=1;
      page1.show();
      n15.setValue(T2butter);
      menu_code = 0;
      break;

    case 26:
      shortBeep();
      blinkStat();
      T2biryani +=1;
      page1.show();
      n16.setValue(T2biryani);
      menu_code = 0;
      break;   

    default:
      if (menu_code != 0) {
        Serial.print("menu_code = ");  //Printing command ID
        Serial.println(menu_code);
      }
  }
  delay(300);
}
//==============================================================================================================//

Code for Chef's (Kitchen) Hardware

C/C++
//=====================================================================================================================//
// Project                 - Smart Waiter : Intelligent Voice Assistant in Restaurant 
// Author                  - https://www.hackster.io/maheshyadav216
// Hardware                - SKU_SEN0539-EN_Gravity_Voice_Recognition_Module, NodeMCU ESP32s, Nextion Display
//                           FireBeetle 2 ESP32-E, NodeMCUESP8266, DFplayer Mini
// Softare                 - Arduino IDE 1/ PLatformIO with VSCode, Nextion Editor
// GitHub Repo of Project  - https://github.com/maheshyadav216/Project-Intelligent-Voice-Assistant-in-restaurant
// Code last Modified on   - 20/09/2023
//======================================================================================================================//

// Code of Hardware at Chef's cabin(Kitchen) (with NodeMCU ESP8266 dev Board). Refer Circuit diagram for more details

//Include Important Libraries
#include <Arduino.h>
#include "Nextion.h"
#include <ESP8266WiFi.h>
#include <espnow.h>
#include "DFRobotDFPlayerMini.h"

#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266))   // Using a soft serial port
#include <SoftwareSerial.h>
SoftwareSerial softSerial(/*rx =*/4, /*tx =*/5);
#define FPSerial softSerial
#else
#define FPSerial Serial1
#endif

DFRobotDFPlayerMini myDFPlayer;

#define statLED D5

// put function declarations here:
NexPage page0    = NexPage(0, 0, "page0");
NexPage page1    = NexPage(1, 0, "page1");


/*
 * Declare a number object [page id:0,component id:3, component name: "n0"]. 
 */
NexNumber n01 = NexNumber(0, 2, "n01");
NexNumber n02 = NexNumber(0, 3, "n02");
NexNumber n03 = NexNumber(0, 4, "n03");
NexNumber n04 = NexNumber(0, 5, "n04");
NexNumber n05 = NexNumber(0, 6, "n05");
NexNumber n06 = NexNumber(0, 7, "n06");

NexNumber n11 = NexNumber(1, 2, "n11");
NexNumber n12 = NexNumber(1, 3, "n12");
NexNumber n13 = NexNumber(1, 4, "n13");
NexNumber n14 = NexNumber(1, 5, "n14");
NexNumber n15 = NexNumber(1, 6, "n15");
NexNumber n16 = NexNumber(1, 7, "n16");


//Structure example to receive data
//Must match the sender structure
typedef struct tmenu_struct {
  uint8_t mcode;
} tmenu_struct;

tmenu_struct myOrder;

//Menu codes
uint8_t T1vada = 0;
uint8_t T1idli = 0;
uint8_t T1rice = 0;
uint8_t T1samosa = 0;
uint8_t T1butter = 0;
uint8_t T1biryani = 0;

uint8_t T2vada = 0;
uint8_t T2idli = 0;
uint8_t T2rice = 0;
uint8_t T2samosa = 0;
uint8_t T2butter = 0;
uint8_t T2biryani = 0;

uint8_t menu_code;


//callback function that will be executed when data is received
void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
  memcpy(&myOrder, incomingData, sizeof(myOrder));
  menu_code = myOrder.mcode;
  //Serial.print("Bytes received: ");
  //Serial.println(len);
  //Serial.print("menu Code: ");
  //Serial.println(myOrder.mcode);
}

void blinkStat(){
  digitalWrite(statLED, HIGH);
  delay(1000);
  digitalWrite(statLED, LOW);
}


void setup() {
  // put your setup code here, to run once:
  FPSerial.begin(9600);
  Serial.begin(115200);
  nexInit();
  page0.show();

  pinMode(statLED, OUTPUT);
  digitalWrite(statLED, LOW);

  if (!myDFPlayer.begin(FPSerial, /*isACK = */true, /*doReset = */true)) {  //Use serial to communicate with mp3.
  Serial.println(F("Unable to begin:"));
  Serial.println(F("1.Please recheck the connection!"));
  Serial.println(F("2.Please insert the SD card!"));
  while(true){
    delay(0); // Code to compatible with ESP8266 watch dog.
    }
  }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.volume(26);  //Set volume value. From 0 to 30
  //myDFPlayer.play(1);  //Play the first mp3
  delay(1000);

  //Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);
  //Init ESP-NOW
  if (esp_now_init() != 0) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  
  // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
  esp_now_register_recv_cb(OnDataRecv);
}

void loop() {
  // put your main code here, to run repeatedly:
  // Check for which code received and Identifiy the food item ordered
  switch(menu_code) {
    case 11:
      blinkStat();
      T1vada +=1;
      page0.show();
      n01.setValue(T1vada);
      myDFPlayer.play(2);
      menu_code = 0;
      break;
    
    case 12:
      blinkStat();
      T1idli +=1;
      page0.show();
      n02.setValue(T1idli);
      myDFPlayer.play(3);
      menu_code = 0;
      break;

    case 13:
      blinkStat();      
      T1rice +=1;
      page0.show();
      n03.setValue(T1rice);
      myDFPlayer.play(4);
      menu_code = 0;
      break;

    case 14:
      blinkStat();    
      T1samosa +=1;
      page0.show();
      n04.setValue(T1samosa);
      myDFPlayer.play(5); 
      menu_code = 0;
      break;

    case 15:
      blinkStat();
      T1butter +=1;
      page0.show();
      n05.setValue(T1butter);
      myDFPlayer.play(6);
      menu_code = 0;
      break;

    case 16:
      blinkStat();
      T1biryani +=1;
      page0.show();
      n06.setValue(T1biryani);
      myDFPlayer.play(7);
      menu_code = 0;
      break;   

    case 21:
      blinkStat();
      T2vada +=1;
      page1.show();
      n11.setValue(T2vada);
      myDFPlayer.play(8);
      menu_code = 0;
      break;
    
    case 22:
      blinkStat();
      T2idli +=1;
      page1.show();
      n12.setValue(T2idli);
      myDFPlayer.play(9);
      menu_code = 0;
      break;

    case 23:
      blinkStat();
      T2rice +=1;
      page1.show();
      n13.setValue(T2rice);
      myDFPlayer.play(10);
      menu_code = 0;
      break;

    case 24:
      blinkStat();
      T2samosa +=1;
      page1.show();
      n14.setValue(T2samosa);
      myDFPlayer.play(11);
      menu_code = 0;
      break;

    case 25:
      blinkStat();
      T2butter +=1;
      page1.show();
      n15.setValue(T2butter);
      myDFPlayer.play(12);
      menu_code = 0;
      break;

    case 26:
      blinkStat();
      T2biryani +=1;
      page1.show();
      n16.setValue(T2biryani);
      myDFPlayer.play(1);
      menu_code = 0;
      break;   

    default:
      if (menu_code != 0) {
        Serial.print("menu_code = ");  //Printing command ID
        Serial.println(menu_code);
      }
  }
  delay(300);
}

//======================================================================================================================//

Project - Smart Waiter : Intelligent Voice Assistant in Restaurant

Credits

maheshyadav216

maheshyadav216

15 projects • 30 followers
Electronics and Embedded Systems Engineer, Maker, Tech Content Creator and Web Designer

Comments