Condiment Dispenser Control with Low Level Notification 2
Condiment Dispenser Control with Low Level Notification 2
Hardware Connections
1. NodeMCU V3:
Connect the VCC pin to a 3.3V output on NodeMCU (e.g., 3V3 or VIN).
Connect the VCC pin to a 3.3V output on NodeMCU (e.g., 3V3 or VIN).
Connect one terminal of the DC motor to one of the relay's common (COM)
terminals.
Connect the other terminal of the DC motor to one of the relay's normally open (NO)
terminals.
Connect the relay's coil terminals (usually labeled as Coil+ and Coil-) to an
appropriate power source. This may vary based on the relay's voltage and type.
Connect the relay's control pin (relayPin) to one of the digital pins on NodeMCU
(e.g., D3).
5. Power Supply:
Provide power to NodeMCU through its micro USB port or an external power source,
depending on your setup.
Ensure the NodeMCU has a stable Wi-Fi connection for sending Telegram messages.
You may need to connect it to your Wi-Fi router using the appropriate credentials.
Rosedi 29/9/23
Coding
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <WiFi.h>
#include <UniversalTelegramBot.h>
// Telegram Chat ID (get this by messaging the Bot directly and checking the updates)
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
connectToWiFi();
AFMS.begin();
pinMode(relayPin, OUTPUT);
pinMode(cupSensorPin, INPUT);
pinMode(sauceLevelSensorPin, INPUT);
void loop() {
if (digitalRead(cupSensorPin) == HIGH) {
digitalWrite(relayPin, HIGH);
} else {
// Cup is not present, turn off the relay to deactivate the motor
digitalWrite(relayPin, LOW);
if (digitalRead(sauceLevelSensorPin) == LOW) {
}
// Add any additional logic or sensors as needed
void connectToWiFi() {
// Connect to Wi-Fi
WiFi.begin(ssid, password);
delay(1000);
Serial.println("Connecting to WiFi...");
Serial.println("Connected to WiFi");
WiFiClient client;