Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

IoT-based smart remote classrooms

By EG Projects

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:


  • 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
  • Python Basics
    RPi Python Programming 06: Python basics

  • An IoT-enabled smart helmet that may save lives

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

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!


Featured Tutorials

  • Adjustable 0 to 30V 2A DC Power Supply Circuit (Part 1/13)
  • Adjustable +/- 1.25V to +/-22V 1A Power Supply Circuit (Part 2/13)
  • Adjustable 0 to 15V 1A Mini Power Supply (Part 3/13)
  • Constant 12V Power Supply for LED Circuits (Part 4/13)
  • Constant +/-9V DC Symmetrical Power Supply Circuit (Part 5/13)
  • Making a Circuit Breaker (Part 6/13)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • STMicroelectronics and MACOM announce successful RF GaN-on-Si prototypes
  • Infineon expands its CoolSiC portfolio
  • STMicroelectronics and AWS collaborate for secure IoT connections
  • Pet feeding system using WhatsApp (protocol bridging with MQTT)
  • STMicroelectronics launches new MDmesh MOSFETs

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Space Vector PWM Help Needed
  • RFIC LNA cascode base and ground layout problem
  • Unable to launch virtuoso: libvisadev.so error
  • DIY test leads - source for lead ends?
  • P-Channel MOSFET always on

RSS Electro-Tech-Online.com Discussions

  • How to get lots of PCBs made cheap?
  • Adding Current Limit Feature to a Buck Converter
  • 24v dc relays not de-energising
  • How do I test amplifier speaker output polarity?
  • XOR Gate Circuit From Diodes
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering