Here’s the updated step-by-step approach for the Robotic Arm for Automated Material Handling using Favoriot IoT Platform and Telegram Integration with the correct Favoriot API implementation based on the documentation.


Step 1: Define System Architecture

The system consists of:

  1. Robotic Arm – Controlled by a PLC (Programmable Logic Controller) and Servo Motors.
  2. Sensors – IR sensors to detect object position and AI Vision for intelligent material handling.
  3. IoT Communication – Favoriot IoT platform to monitor and control remotely.
  4. Telegram Integration – Notify users about errors, task completion, and manual control.

Step 2: Hardware Components

  1. Robotic Arm Kit (6-DOF for better flexibility)
  2. PLC (e.g., Siemens S7-1200 or Arduino-based PLC)
  3. Motor Driver & Servo Motors (MG996R or DS3225)
  4. IR Sensors for object detection
  5. Camera for AI Vision (Optional, Raspberry Pi Camera or OpenMV)
  6. Microcontroller (ESP32/ESP8266) for IoT connectivity
  7. Power Supply (12V, 5A)

Step 3: Hardware Wiring

Basic Connections

  • Servo motors connect to the PLC or ESP32 PWM pins.
  • IR sensors connect to the microcontroller’s GPIO.
  • AI Vision Camera connects to Raspberry Pi.
  • ESP32 communicates with the Favoriot IoT platform via WiFi.

Step 4: Setting Up Favoriot IoT Platform

Step 4.1: Favoriot Account Setup

  1. Sign up/Login at Favoriot.
  2. Create a Device under “My Devices”.
  3. Note down Device Developer ID and API Key.

Step 5: Programming the Microcontroller (ESP32)

Install Required Libraries

In Arduino IDE, install:

  • WiFiClientSecure
  • ArduinoJson
  • Servo.h

Step 5.1: ESP32 Code for Favoriot Data Upload

#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Servo.h>

const char* ssid = "Your_SSID";
const char* password = "Your_WIFI_PASSWORD";

String favoriot_api = "YOUR_FAVORIOT_API_KEY";
String device_developer_id = "YOUR_DEVICE_DEVELOPER_ID";
String favoriot_url = "https://apiv2.favoriot.com/v2/streams";

Servo servo1, servo2, servo3; // Servo for robotic arm movement
int irSensor = 4; // IR sensor pin

void setup() {
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to WiFi...");
    }
    Serial.println("Connected to WiFi");

    servo1.attach(5);
    servo2.attach(18);
    servo3.attach(19);

    pinMode(irSensor, INPUT);
}

void sendToFavoriot(String status) {
    if (WiFi.status() == WL_CONNECTED) {
        HTTPClient http;
        http.begin(favoriot_url);
        http.addHeader("Content-Type", "application/json");
        http.addHeader("Apikey", favoriot_api);

        StaticJsonDocument<200> jsonDoc;
        jsonDoc["device_developer_id"] = device_developer_id;
        jsonDoc["data"]["status"] = status;

        String jsonString;
        serializeJson(jsonDoc, jsonString);

        int httpResponseCode = http.POST(jsonString);
        Serial.println("Data sent to Favoriot: " + status);
        http.end();
    }
}

void loop() {
    if (digitalRead(irSensor) == HIGH) {
        Serial.println("Object detected!");
        sendToFavoriot("Object detected, moving robotic arm.");

        servo1.write(90);
        delay(1000);
        servo2.write(45);
        delay(1000);
        servo3.write(90);
        delay(1000);

        sendToFavoriot("Task completed.");
    }
    delay(500);
}


Step 6: Telegram Bot Integration

Step 6.1: Create Telegram Bot

  1. Open Telegram and search for BotFather.
  2. Type /newbot and follow the instructions.
  3. Save the BOT TOKEN.

Step 6.2: ESP32 Code for Telegram Notifications

#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

const char* telegramBotToken = "YOUR_TELEGRAM_BOT_TOKEN";
const char* telegramChatID = "YOUR_TELEGRAM_CHAT_ID";

WiFiClientSecure client;
UniversalTelegramBot bot(telegramBotToken, client);

void sendTelegramMessage(String message) {
    bot.sendMessage(telegramChatID, message, "");
}

void loop() {
    int irValue = digitalRead(irSensor);
    if (irValue == HIGH) {
        sendTelegramMessage("Object detected! Robotic Arm is moving.");
    }
    delay(1000);
}


Step 7: AI Vision Integration (Optional)

If you want AI-based movement:

  1. Use OpenCV on Raspberry Pi to detect object position.
  2. Send coordinates to ESP32 via MQTT.
  3. Modify movement based on AI feedback.

Example Python code for object detection using OpenCV:

import cv2

cap = cv2.VideoCapture(0)
while True:
    ret, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
    
    cv2.imshow("Frame", thresh)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()


Step 8: Testing & Deployment

  1. Power on the system.
  2. Check if ESP32 connects to WiFi.
  3. Confirm data is received in Favoriot IoT Dashboard.
  4. Verify Telegram messages.
  5. Optimize AI movement if applicable.

Conclusion

This project integrates Favoriot IoT, Telegram, and AI Vision into a Robotic Arm Automation System. The combination of sensors, AI, and remote monitoring provides efficient material handling in production lines.

Would you like an additional dashboard for real-time monitoring?

Reference

Favoriot Documentation

Disclaimer

This article provides a step-by-step guide. The source code may need adjustments to fit the final project design.

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Share this post with your friends!

Discover more from IoT World

Subscribe now to keep reading and get access to the full archive.

Continue reading