Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

IoT-based smart remote classrooms

By EG Projects October 31, 2022

This project will show how we can use the IoT to create cheap and smart remote classrooms for rural areas using Raspberry Pi and its camera module. If a teacher teaches in a distant city, that session can be streamed live to rural areas. By such applications, children from rural areas can get quality education from a remote place by paying a small fee.

Such applications are already available in the market, but they are costly, so we need a cheap solution that those childrens’ families can afford.

Components required

Required tools and libraries
Tools

  1. Python IDE 3.0
  2. VNC viewer
  3. Any Web Browser for client

Python libraries

  1. Socketserver – link
  2. Picamera – can be installed by following commands in terminal
    $ sudo apt-get install python-picamera python3-picamera

Technical Insights
Our device can be implanted anywhere, and it will record and stream live on its address. This application works on the client-server model using TCP/HTTP as a communications protocol. Therefore, the stream can be accessed from anywhere (If the firewall allows) on a web browser.

We will use Raspberry Pi for processing and as a server which will stream the incoming media data from the camera on a particular IP address of the Raspberry Pi. For internet connectivity, we can use Wi-Fi or any internet modem.

We will write a Python script that will handle all the technical processes such as enabling networking and setting the Raspberry Pi as a media streaming server.

Block Diagram / Algorithm

Figure 1 Client-Server Communication

Raspberry pi is directly connected to the camera model using its cable connector, and the modem provides the raspberry pi a valid IP address with internet connectivity. A TCP/HTTP connection is sharing all the media data between the Raspberry Pi and the modem.

Clients access the Raspberry Pi (streaming server) using internet-enabled devices such as cellphones and laptops. Raspberry Pi has a good web browser because the stream is an HTTP stream.

How it works
When all the connections are in place and working, we start our script which will stream on the IP address of the Raspberry Pi. To understand this, follow the points giving below.

  1. The camera starts to record and save pictures in an “mjpg” file when the script is on.
  2. The camera is continually replacing the stream inside only one file.
  3. A server is created inside the system using a function, and that image file is passed inside that function. The server also opens a port in the system so clients can access the server through the network.
  4. An HTML code/page is written to handle the image file on web pages. This HTML page displays that image and keeps refreshing to show that changes in images can be seen as videos.
  5. Now, if a client gets to connect to the server, it is welcomed with that HTML page, and thus, the client can see the image as a video.
  6. If multiple clients are connected, then multithreading is used,  and a fresh new page is opened for each client.
  7. When a client gets disconnected, the stream for that particular client is stopped.
  8. The server always listens for the client on the port which it opened.

Understanding the source code

Let’s understand the source code and its essential functions.

There are three handler functions, one primary function, and an HTML page template in our code.

HTML page template
The title tag shows the main title on the page when a client is connected.
<title>picamera MJPEG streaming demo</title>
The tag <h1> is a heading in our main page.
<h1>PiCamera MJPEG Streaming Demo</h1>
“<img src” line handles the streaming file and displays inside a 640 X 460-pixel size window on the main page.
<img src=”stream.mjpg” width=”640″ height=”480″ />

StreamingOutput(object)
This function creates enough data buffer to save the stream file. It also provides a new frame on client connection.
return self.buffer.write(buf)

StreamingHandler(server.BaseHTTPRequestHandler)
This function handles the clients on HTTP requests. It writes the main header with the following information.

If a client is trying to access the server by its address only, it shows the complete page to the client.
self.send_header(‘Location’, ‘/index.html’)
If the index.html page is accessed, it writes the page with the content and displays what was written in the page part.
It also specifies the content type on the main page so clients (browsers) can understand the type of the content and act accordingly.
self.send_header(‘Content-Type’, ‘multipart/x-mixed-replace; boundary=FRAME’)
This stream is a frame-type stream with multipart (multimedia) content.

StreamingServer(socketserver.ThreadingMixIn, server.HTTPServer)
This server function deals with the networking part and creates a new socket for each client. It also enables multiple client connections by using multithreading.

Main Function
The main function script is the code for recording the stream and passing it to the above functions.
camera.start_recording(output, format=’mjpeg’)
The camera starts recording and writes it to the mjpeg format file.

The address is the object which passes the server port and the IP address which means that it will support the availability of the server on every IP address the system is assigned to.
address = (”, 8000)

The server is binding itself to the object address and the content, which is the “StreamingHandler” function
server = StreamingServer(address, StreamingHandler)

This line tells the server to keep serving the service until the script is not terminated.
server.serve_forever()

So this is how we can find a cheap and easy solution for smart remote classrooms for rural areas.

https://www.engineersgarage.com/wp-content/uploads/2021/09/video.mp4

You may also like:

  • Python Basics
    RPi Python Programming 06: Python basics

  • RPi Python Programming 05: Introduction to Python

  • How to program an IoT-based coffee machine

  • 14 IoT Boards to Quick Start Prototyping

  • Getting started with Raspberry Pi

  • An IoT-enabled smart helmet that may save lives

Filed Under: Electronic Projects
Tagged With: IoT, python, Raspberry Pi
 

Next Article

← Previous Article
Next Article →

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • What is the reason for using the -allow_path option in set_clock_groups?
  • Mean offset increase in post-layout simulation of clocked comparator
  • LED driver using PWM
  • dc-dc converter in series
  • Why Use Virtual Serial Ports and Serial Port Assistants in Communication?

RSS Electro-Tech-Online.com Discussions

  • IoT: Transforming Businesses with Digital Engineering
  • PIC KIT 3 not able to program dsPIC
  • Fun with AI and swordfish basic
  • Is AI making embedded software developers more productive?
  • Microinverters and storeage batteries?

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • How to design a weather station using ESP8266
  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe