Posts in TIPS

[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.

Unlocking the Potential of IoT: How Favoriot’s Platform and IoT Kits Can Transform Education

March 23rd, 2023 Posted by BLOG, HOW-TO, Internet of Things, IOT PLATFORM, PARTNER, TIPS 0 thoughts on “Unlocking the Potential of IoT: How Favoriot’s Platform and IoT Kits Can Transform Education”

Favoriot, a leading IoT platform provider, offers a subscription service that enables individuals and businesses to build and manage IoT projects quickly. But how can universities benefit from using an IoT kit in teaching, learning, and developing IoT projects?

An IoT kit can benefit universities and their students, including hands-on learning and accessibility to affordable components. Additionally, it can prepare students for a career in IoT, a rapidly growing field with high demand for skilled professionals.

Incorporating IoT into the curriculum can help universities stay up-to-date with the latest trends and technologies. Furthermore, using Favoriot’s platform with an IoT kit can provide a comprehensive and effective solution for teaching, learning, and developing IoT projects.

Favoriot’s platform offers many features, including real-time data visualization, data analytics, and data management, making it easier for students and professors to manage and analyze their IoT projects. The platform is also user-friendly, with an intuitive interface allowing even beginners to learn and use it quickly.

In conclusion, using an IoT kit and Favoriot’s platform can provide a powerful tool for teaching, learning, and developing university IoT projects. It can make learning IoT more accessible and affordable, provide hands-on experience with the latest IoT technologies and tools, and help universities stay up-to-date with the latest trends and technologies in the field of technology. By incorporating this technology into their curriculum, universities can prepare students for a successful career in this exciting and rapidly growing field.

How to Subscribe FAVORIOT Bundle Plan

  1. Go to – Favoriot Subscription Page
  2. Click Sign Up Here.
  3. Enter profile details
  4. Choose the Bundle Plan as shown below and click Submit.
  5. Enter your details (including delivery address) and make payment.

Hibiscus Sense – The IoT Kit

The Hibiscus Sense is an Internet of Things (IoT) development board powered by the mighty and popular dual-core ESP32 microcontroller, embedded with 3 sensors (APDS9960, BME280 & MPU6050) and 2 actuators (Buzzer & LED / RGB LED), makes it easy for you to kick start your awesome IoT project. Since the microcontroller is the mighty ESP32, this development board is compatible to be programmed using tools such as Arduino IDE (for Arduino programming language), Thonny IDE (Micropython programming language) or ESP-IDF (C, C++ programming language), simply use the latest USB Type-C to program the microcontroller, which has built-in USB-to-Serial converter (Silicon Labs CP2104) with automatic bootloader reset, so you don’t have to press the RESET button each time to upload the program into the microcontroller.

The ESP32 microcontroller comes with 4 MB of SPI Flash running at 240MHz, support both WiFi and BLE connectivity and also the ESP-NOW protocols, which develop by Espressif for low-power 2.4GHz wireless connectivity. The variety of connectivity gives you the freedom and flexibility to develop wireless sensor platform using Hibiscus Sense to be connected to other wireless connectivity such as the BLE on your smartphone, to visualise the data on the mobile app. It’s indeed perfect for your wireless or IoT projects.

Hibiscus sense comes with pre-assembled header makes it easy for you to plug the board on top of the breadboard or on the female header on your DIY PCB projects. There are plenty open GPIOs for you to work with digital inputs and outputs, analog inputs and outputs and multiple extra peripherals, such as UART the RX/TX, I2C and SPI.

Hibiscus Sense is the best board for those who work out for data science and data exploration, as it can easily generate real-time data from rich profusion of sensors on board. The sensors, enables you to sense the physical movement and environment around the board, which total of 13 parameters can be measured:

  • APDS9960 – An environment sensor, which sense proximitycolour and gesture.
  • MPU6050 – 6 Degree of Freedom (DoF) IMU (Inertial Measurement Unit), the accelerometer and gyroscope.
  • BME280 – An environment sensor, which measure the altitudebarometric pressurehumidity and temperature.

FEATURES

  • ESP32 running at 240MHz
  • 4MB SPI flash and 520 KB SRAM
  • USB Type-C with Silicon Labs CP2014 USB-to-Serial converter with automatic bootloader reset.
  • Integrated WiFi, Bluetooth and ESP-NOW wireless protocols
  • FCC / CE / IC & others certified module
  • RESET and GPIO 0 pushbuttons
  • 25 GPIOs, including ADC, DAC, UART, I2C and SPI
  • Blue LED connected to ESP32 GPIO2
  • RGB LED connected to ESP32 GPIO16
  • Buzzer connected to ESP32 GPIO13
  • APDS9960, BME280 and MPU6050 connected to ESP32 I2C
  • Board measurement including header in mm – 58.7 x 27 x 13.3 (length x width x height)
  • Package measurement in mm: 71.8 x 35.5 x 20.4 (length x width x height)

DOCUMENTATION

The comprehensive tutorial for Hibiscus Sense is provided on Github:

SHIPPING LIST

  • 1x Hibiscus Sense
  • 1x USB Type C

How Do I Start My IoT Project Without High Investment?

July 5th, 2017 Posted by HOW-TO, NEWS, TIPS 0 thoughts on “How Do I Start My IoT Project Without High Investment?”

ipad-820272_1920.jpg

Start Your IoT Journey

#AskIoTWorld Question #4:

How do I start my IoT Project?

Response:

Simple answer – it depends on where do you stand? Assuming that you have the necessary knowledge and skills to develop an IoT project, take the following steps:

  1. Go out there and find a business case. Good market research report can give an indication but the market can be different in different countries. Thus, you need to be out there and find a real business case. Talk to the industry, talk to the customers and listen to their pain points.
  2. The low hanging fruit is to replace manual labor with remote monitoring. Costs can be greatly reduced. No more traveling costs and time-consuming data gathering. By doing this, you are also benchmarking their operations.
  3. The best part of benchmarking is that you can now introduce more sensors, actuators, analytics to gain better insights and thus ROI can be easily seen and predict.

This is just the beginning of your IoT journey. Take a simple step forward, understand their business case, learn, change if it doesn’t work, expand if it begins to show the ROI.

You can DOWNLOAD the eBook – HERE.

[Note: You can #AskIoTWorld with any IoT-related questions and we will try to answer in this Blog]

Copyright © 2025 All rights reserved