Skip to main content

IOT DISPENSER

#handsanitizer #covid #masker #dirumahaja #coronavirus #sanitizer #handsanitizermurah #corona #staysafe #handsanitizers #stayathome #stayhome #maskerkain #jualhandsanitizer #socialdistancing #facemask #skincare #viruscorona #washyourhands #handgel #handsanitizerspray #newnormal #maskersensi #disinfectant #handsanitizergel #ml #antiseptic #virus #antiseptik #iot #technology #internetofthings #ai #tech #arduino #raspberrypi #robotics #automation #engineering #artificialintelligence #innovation #electronics #programming #bigdata #machinelearning #smarthome #datascience #cybersecurity #security #coding #blockchain #b #business #arduinoproject #python #electrical #arduinouno #robot #bhfyp



Corona virus (Covid 19) is spreading all around the world. Hence it's very important to keep our hands sanitized. Here is the simple project to build an electronic hand sanitizer that can be operated using smartphone via bluetooth. IoT projects have gained immense popularity due to their ability to leverage the power of interconnected devices and data to create innovative solutions across various domains. IoT projects involve integrating sensors, actuators, and communication technologies to enable the seamless exchange of data between physical devices and the internet. These projects range from simple DIY experiments to complex industrial applications, each offering unique opportunities to transform our lives and improve efficiency. Whether it's creating a smart home automation system, monitoring environmental conditions, optimizing energy usage, or developing intelligent transportation systems, applications of IoT open up a world of possibilities for innovation and connectivity. By harnessing the potential of IoT, we can build intelligent and interconnected systems that revolutionize industries, enhance daily life, and pave the way for a more efficient and sustainable future. In this project we will be using nodemcu to as a controller for the project.



 




Circuit diagram:




Code: 




DESCRIPTION :

Arduino code:

  1. #include <ESP8266WiFi.h>

  2. #include <Servo.h>

  3. Servo servo;

  4. //Static IP address configuration

  5. IPAddress staticIP(192, 168, 225, 81); //ESP static ip

  6. IPAddress gateway(192, 168, 225, 1);   //IP Address of your WiFi Router (Gateway)

  7. IPAddress subnet(255, 255, 255, 0);  //Subnet mask


  8. //Define wifi configuration

  9. const char* ssid = "YOUR_SSID";

  10. const char* password = "YOUR_WIFI_PASSWORD";


  11. // Create an instance of the server

  12. WiFiServer server(80);


  13. void setup() { 

  14.   Serial.begin(9600);

  15.  

  16. // prepare GPIO 4

  17.    servo.attach(4);

  18.     

  19.   //Motor in home position

  20.   servo.write(90);

  21.   servo.detach();

  22.   delay(100);

  23.   

  24.   // Connect to WiFi network

  25.   Serial.println();

  26.   Serial.println();

  27.   Serial.print("Connecting to ");

  28.   Serial.println(ssid);

  29.   

  30.   WiFi.begin(ssid, password);

  31.   //Configuring Static IP

  32.   WiFi.config(staticIP,gateway,subnet);

  33.   while (WiFi.status() != WL_CONNECTED) {

  34.     delay(500);

  35.     Serial.print(".");

  36.   }

  37.   Serial.println("");

  38.   Serial.println("WiFi connected");

  39.   

  40.   // Start the server

  41.   server.begin();

  42.   Serial.println("Server started");


  43.   // Print the IP address

  44.   Serial.println(WiFi.localIP());

  45. }


  46. void loop() {

  47.   // Check if a client has connected

  48.   WiFiClient client = server.available();

  49.   if (!client) {

  50.     return;

  51.   }

  52.   

  53.   // Wait until the client sends some data

  54.  // Serial.println("new client");

  55.   while(!client.available()){

  56.     delay(1);

  57.   }

  58.   

  59.   // Read the first line of the request

  60.   String req = client.readStringUntil('\r');

  61.   //Serial.println(req);

  62.   //Serial.println("req");

  63.   client.flush();

  64.   

  65.   // Match the request

  66.   int val;

  67.   if (req.indexOf("/gpio/0") != -1)

  68.     val = 0;

  69.   else if (req.indexOf("/gpio/1") != -1)

  70.     val = 1;

  71.    else if(req.indexOf("ON1") != -1)

  72.   {

  73.       servo.attach(4); // No . 4 is GPIO 4 means servo is attached to pin D2 of NODE MCU.

  74.       

  75.       servo.write(140);

  76.       delay(1000);

  77.       servo.write(90);

  78.       

  79.       delay(300);

  80.       servo.detach();


  81.    }

  82. //   else if(req.indexOf("OFF1") != -1)

  83. //  {

  84. //      digitalWrite(D0, HIGH);

  85. //  }


  86.   else {

  87.     client.stop();

  88.     return;

  89.   }

  90.   client.flush();


  91.   // Prepare the response

  92.   String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";

  93.   s += (val)?"high":"low";

  94.   s += "</html>\n";


  95.   // Send the response to the client

  96.   //client.print(s);

  97.   delay(1);

  98.   Serial.println("Client disconnected");


  99.   // The client will actually be disconnected 

  100.   // when the function returns and 'client' object is destroyed

  101. }








Description:

Most of the code is commented. Some of the important points to highlight

  1. In this code we need to change the gateway according to our network.

  2. Simple method - (For windows) 

    1. Open command prompt - type “ipconfig”

    2. Look for “default gateway”. A set of four numbers will be displayed. In my case its 192.168.xxx.1

    3. Note this “xxx” number, goto line in the code where “staticIP” is defined and replace the 3rd number  with this number you just found.   

    4. Ex: default gateway is 192. 169. 255 .1

So in my code  -

IPAddress staticIP (192, 168, 225, 81); //ESP static ip

IPAddress gateway (192, 168, 225, 1);


  1. Next step is changing SSID and password

    1. Replace  YOUR_SSID in this line - const char* ssid = "YOUR_SSID" with your wifi name.

    2. Replace YOUR_WIFI_PASSWORD in the line const char* password = "YOUR_WIFI_PASSWORD"; with your wifi password


ANDROID APP SETTINGS:


  1. To test the project , open the android app “LINK HERE” , type IP address of the device and same gateway .

  2. Now type “ON1” keyword into send section and hit send.

In the receive section of the app you will be able to see the response from the arduino device.



Project arrangement:


Android app : Link to app store