Vertical button with arduino WEMOS
Model details
- Platform
MakerWorld
- Price
- Free
- License
- PRIVATE-USE
- Personal use only: print for yourself, no selling or sharing.
- Formats
- STL
- 13 Likes
- 33 Downloads
- 15 Makes
- 32 Collected
- 2 Boosts
- 2 Comments
- 0 Views
Description
Materials needed:
- Wemos d1 mini - Servo motor ( ebay ) Others:
- Telegram Bot ( YouTube ) The code:
#include #include #include #include
// Wifi network station credentials #define WIFI_SSID "WIFINAME" #define WIFI_PASSWORD "WifiPassword" // Telegram BOT Token (Get from Botfather) #define BOT_TOKEN "BotToken" #define BOT_ID "BotID"
const unsigned long BOT_MTBS = 1000; Servo servoMotor;
X509List cert(TELEGRAM_CERTIFICATE_ROOT); WiFiClientSecure secured_client; UniversalTelegramBot bot(BOT_TOKEN, secured_client); unsigned long bot_lasttime;
void handleNewMessages(int numNewMessages) { for (int i = 0; i < numNewMessages; i++) {
if(bot.messages[i].text == "/start" && bot.messages[i].chat_id == BOT_ID){ bot.sendMessage(bot.messages[i].chat_id, "Bones!", ""); servoMotor.write(0); } if(bot.messages[i].text == "/on" && bot.messages[i].chat_id == BOT_ID){ servoMotor.write(0); servoMotor.write(180); delay(1000); servoMotor.write(90);
bot.sendMessage(bot.messages[i].chat_id, "Pressed ON!", ""); } if(bot.messages[i].text == "/hardreset" && bot.messages[i].chat_id == BOT_ID){ servoMotor.write(90); servoMotor.write(180); delay(10000); servoMotor.write(90);
bot.sendMessage(bot.messages[i].chat_id, "Pressed 10s!", ""); }
} }
void setup() { Serial.begin(115200); Serial.println();
servoMotor.attach(2);//Declaram es servo a des pin 2
// attempt to connect to Wifi network: Serial.print("Connecting to Wifi SSID "); Serial.print(WIFI_SSID); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); secured_client.setTrustAnchors(&cert); // Add root certificate for api.telegram.org
while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.print("\nWiFi connected. IP address: "); Serial.println(WiFi.localIP());
Serial.print("Retrieving time: "); configTime(0, 0, "pool.ntp.org"); // get UTC time via NTP time_t now = time(nullptr); while (now < 24 * 3600) { Serial.print("."); delay(100); now = time(nullptr); } Serial.println(now); }
void loop() { if (millis() - bot_lasttime > BOT_MTBS) { int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
while (numNewMessages) { Serial.println("got response"); handleNewMessages(numNewMessages); numNewMessages = bot.getUpdates(bot.last_message_received + 1); }
bot_lasttime = millis(); } }
Guides and print profiles
Print profiles and steps
Servo wemos
Similar models
Soil moisture sensor - ESP32
Hühner Klappe ESP8266
Secret RFID Iphone box
PET V1 (The Ultimate Gadget for Pets)
Brazo Robótico - Robotic Arm
ESP 8266 Relay Box - WiFi and Local on / off
DIY Garden or Greenhouse Watering controller
Aquarium temperature sensing wemos d1arduino
Haustierfütterautomat für Wellensittiche, Hamster, Meerschweinchen usw. mit Zeitsteuerung und Arduino oder ESP mit PET-Flasche als Behälter
6th Finger Prosthetic V2- POWERED
arduino digital clock
Names are used only to indicate the source of a result. Polyzon is not affiliated with the listed sites.





Comments