Posts in Internet of Things

[Tutorial] : Automated Quality Inspection System Using AI & FAVORIOT

April 6th, 2025 Posted by BLOG, HOW-TO, Internet of Things, IOT PLATFORM, TIPS 0 thoughts on “[Tutorial] : Automated Quality Inspection System Using AI & FAVORIOT”

This guide will show you how to build an AI-powered quality inspection system using a camera and send inspection results to the FAVORIOT IoT platform in real time.


šŸ”§ Step 1: What You Need

Hardware:

  • Raspberry Pi (or any computer with a camera)
  • Camera (USB or Pi Camera)
  • Internet connection

Software:

  • Python 3
  • Libraries: opencv-python, tensorflow, numpy, requests

šŸ› ļø Step 2: Install the Required Software

Open Terminal and run:

sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip -y
pip3 install opencv-python numpy requests tensorflow

šŸ§  Step 3: Train an AI Model to Detect Defects

Create a folder called dataset_defects with 2 subfolders: defect and normal.

Now, use this Python code to train the model:

import tensorflow as tf
from tensorflow.keras.preprocessing.image import ImageDataGenerator

dataset_path = "dataset_defects"
batch_size = 32
img_size = (224, 224)

datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)

train_data = datagen.flow_from_directory(
    dataset_path,
    target_size=img_size,
    batch_size=batch_size,
    class_mode="binary",
    subset="training"
)

val_data = datagen.flow_from_directory(
    dataset_path,
    target_size=img_size,
    batch_size=batch_size,
    class_mode="binary",
    subset="validation"
)

base_model = tf.keras.applications.MobileNetV2(input_shape=(224, 224, 3), include_top=False, weights="imagenet")
base_model.trainable = False

model = tf.keras.Sequential([
    base_model,
    tf.keras.layers.GlobalAveragePooling2D(),
    tf.keras.layers.Dense(1, activation="sigmoid")
])

model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.fit(train_data, validation_data=val_data, epochs=10)

model.save("defect_detection_model.h5")

šŸŽ„ Step 4: Real-Time Defect Detection Using Camera

Once the model is trained and saved, run this script:

import cv2
import numpy as np
import tensorflow as tf

model = tf.keras.models.load_model("defect_detection_model.h5")
cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    if not ret:
        break

    img = cv2.resize(frame, (224, 224))
    img = np.expand_dims(img, axis=0) / 255.0
    prediction = model.predict(img)[0][0]

    label = "Defect Detected!" if prediction > 0.5 else "Product OK"
    color = (0, 0, 255) if prediction > 0.5 else (0, 255, 0)

    cv2.putText(frame, label, (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, color, 2)
    cv2.imshow("Quality Inspection", frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

šŸŒ Step 5: Send Defect Results to FAVORIOT

āœ… 1. Set Up a Device in FAVORIOT

  1. Log in to Favoriot Platform
  2. Go to Devices ā†’ Add Device
  3. Note down your Device Developer ID and API Key

āœ… 2. Add Code to Send Data

Below is the function to send results:

import requests
import json

DEVICE_ID = "YOUR_DEVICE_ID"
API_KEY = "YOUR_FAVORIOT_API_KEY"
URL = "https://apiv2.favoriot.com/v2/streams"

def send_data_to_favoriot(status):
    payload = {
        "device_developer_id": DEVICE_ID,
        "data": {
            "status": status
        }
    }

    headers = {
        "Content-Type": "application/json",
        "Apikey": API_KEY
    }

    response = requests.post(URL, data=json.dumps(payload), headers=headers)
    print("Response from Favoriot:", response.json())

āœ… 3. Combine with Real-Time Detection

Add this snippet inside your prediction logic:

if prediction > 0.5:
    send_data_to_favoriot("Defect Detected!")
else:
    send_data_to_favoriot("Product OK")

šŸ“Š Step 6: View Data on FAVORIOT Dashboard

  • Go to your device on the FAVORIOT Dashboard
  • Click on Streams to view defect data
  • You can also create graphs or alert rules for monitoring

šŸš€ Bonus Tips

  • Add Telegram Alerts using Telegram Bot API
  • Add Dashboard Charts using Favoriotā€™s visualization
  • Improve accuracy with better dataset or model tuning

āœ… Summary

With this project, you have:

āœ… Built a real-time defect detection system
āœ… Displayed results on screen
āœ… Sent reports to FAVORIOT cloud platform

References

Disclaimer

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

Favoriot Edge Gateway Service

March 4th, 2025 Posted by BLOG, HOW-TO, Internet of Things, IOT PLATFORM 0 thoughts on “Favoriot Edge Gateway Service”

Favoriot Edge Gateway is a service that connects IoT gateways directly to the Favoriot Platform. It bridges the ā€œedgeā€ (local devices) and the Favoriot Platform, enabling data from local devices to be processed, managed, and stored. Additionally, it allows for the selection of specific parameters in the payload to be stored, providing greater control over transmitted data.

Key References

IoT Firmware Updates with Favoriot OTA

March 4th, 2025 Posted by BLOG, HOW-TO, Internet of Things, IOT PLATFORM 0 thoughts on “IoT Firmware Updates with Favoriot OTA”

šŸš€ Stay Ahead with Seamless Firmware Updates!

In the fast-paced world of IoT, keeping your devices updated is crucial for security, performance, and functionality. But imagine having to manually update thousands of devices deployed across different locationsā€”tedious, costly, and highly inefficient, right?

Thatā€™s where Firmware Over-the-Air (OTA) updates come in, and in this video, weā€™ll show you how the Favoriot Platform makes firmware updates effortless!

Why do Firmware OTA Updates Matter?

1ļøāƒ£ Security First šŸ”’ ā€“ Cyber threats evolve rapidly, and outdated firmware is a prime target. OTA updates allow you to patch vulnerabilities quickly, ensuring your IoT network remains secure.

2ļøāƒ£ Cost & Time Efficiency ā³šŸ’° ā€“ No need for on-site visits or manual intervention. Update thousands of devices remotely with a single click, reducing operational costs.

3ļøāƒ£ Feature Enhancements šŸš€ ā€“ Want to roll out new features? OTA updates let you upgrade device functionalities without recalling hardware, keeping your devices innovative and competitive.

4ļøāƒ£ Bug Fixes & Performance Optimization šŸ› ļø ā€“ Ensure smooth performance by addressing software glitches before they impact users. A quick OTA update can resolve issues instantly.

5ļøāƒ£ Scalability & Future-Proofing šŸ“” ā€“ As your IoT ecosystem grows, maintaining a fleet of devices becomes challenging. OTA ensures easy scalability, allowing remote updates as your network expands.

Introducing Favoriot OTA

The Favoriot platform supports OTA (Over-the-Air) capabilities for IoT devices, enabling seamless remote updates of firmware, software, and configurations. This ensures devices remain secure, functional, and up-to-date without physical intervention. Key features include:

  1. Firmware and Software Updates: Delivering updates to fix bugs, enhance features, or patch vulnerabilities.
  2. Configuration Management: Pushing new settings to devices remotely.
  3. Security: Quickly deploying patches to address vulnerabilities.
  4. Scalability: Managing updates across large fleets of IoT devices efficiently.

Favoriot’s firmware OTA functionality is essential for maintaining the performance, security, and longevity of IoT deployments in applications such as smart homes, industrial IoT, and connected vehicles.

This powerful feature eliminates the hassle of manual updates, ensuring your IoT infrastructure stays secure, efficient, and up to dateā€”no matter where your devices are deployed!

(NOTE: Favoriot Firmware OTA is only available in the Developer Plan)

šŸŽ„ Watch this video to see Favoriot OTA in action and learn how to update your IoT devices remotely!

Key References

Copyright Ā© 2025 All rights reserved