0% found this document useful (0 votes)
99 views52 pages

Vikash Intership 12

This document is an internship report detailing Vikash Banwari's experience at DRMZ System Innovations, focusing on embedded systems and IoT projects. It covers project objectives, technologies used, and specific projects such as a robotic arm and a GSM-based alert system, highlighting skills gained in real-time monitoring, wireless communication, and PCB design. The report also discusses challenges faced and the results achieved during the internship period.

Uploaded by

vikashem33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views52 pages

Vikash Intership 12

This document is an internship report detailing Vikash Banwari's experience at DRMZ System Innovations, focusing on embedded systems and IoT projects. It covers project objectives, technologies used, and specific projects such as a robotic arm and a GSM-based alert system, highlighting skills gained in real-time monitoring, wireless communication, and PCB design. The report also discusses challenges faced and the results achieved during the internship period.

Uploaded by

vikashem33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Vikash Banwari

B.Tech - ECE
Sagar Institute of Science and Technology, Gandhi Nagar, Bhopal.

+91 9171740862
[email protected]
July 24, 2024 – March 21, 2025

DRMZ SYSTEM INNOVATIONS


First Floor, Plot 69-B, Kasturba Nagar, Near Chetak bridge, Bhopal
DrmzTech System Innovations Pvt. Ltd.

TABLE OF CONTENTS
TITLE PAGE NO.
1. EXECUTIVE SUMMARY 1
1.1 Introduction 1
1.2 Project Objectives 2
1.3 Features and Functionalities 2
2. TECHNOLOGIES OVERVIEWS 2
2.1 Firebase Cloud 2
2.2 Arduino IDE 3
2.3 Morey OS 4
2.4 PCB Design 5
2.5 BMP581 Sensor 7
2.6 SX1278 Lora Module 8
2.7 SC Servo Driver with ESP32 9
3. INTERNSHIP GOAL 11
3.1 Role and Responsibilities 11
3.2 Learning Goals 12
3.3 Thanks Giving 13
4. PROJECT DESCRIPTIONS 14
4.1 Scope and Objectives 14
4.2 Robotic Arm 14
4.3 Adicine Box 16
4.4 Gateway 18
5. TESTING PROCESS 19
5.1 Nokia5110 19
5.2 TFT9341 LCD 20
6. CHALLENGES FACED 22
6.1 Technical Challenges 22
6.2 Troubleshooting and Problem-Solving 23
6.3 Communication and Collaboration 24
7. PROJECT RESULTS 24
7.1 Automation 24
7.2 Reminder 24
7.3 Monitoring 24
7.4 Short Range Communication 24
8. PROTOCOLS USED 26
8.1 I2C 26
8.2 UART 26
8.3 SPI 26
8.4 HTTP/HTTPS 26
8.5 LoraWAN 27
8.6 Firebase REST API 27
8.7 RF Communication Customer Protocol 27
9. CONCLUSION 27
10. MONTH-WISE DETAILED WORK REPORT 28
DrmzTech System Innovations Pvt. Ltd.

1. EXECUTIVE SUMMARY
INTRODUCTION
This internship report provides an in-depth overview of my professional journey at DRMZ
SYSTEM INNOVATIONS PVT. Ltd., where I had the opportunity to apply and expand my
technical knowledge through real-world projects in the domain of embedded systems and IoT.
Throughout the duration of the internship, I was actively involved in designing and developing
IoT-based solutions using microcontrollers such as ESP8266 and ESP32, where I
implemented wireless connectivity and integrated Firebase Realtime Database for monitoring
and controlling data in real time. I gained substantial experience working with serial
communication protocols using modules like CP2102 and CP1310, which enabled seamless
data exchange between devices and allowed me to understand the fundamentals of UART
communication in embedded systems.
One of the key aspects of my internship involved developing logic to control and automate
GPIO operations based on received inputs and acknowledgment patterns, contributing to
efficient device-state management. I also contributed to RF communication projects using
LoRa (SX1278) and standard RF transmitter/receiver modules, which strengthened my
understanding of long-range wireless communication in IoT networks. In addition to coding
and hardware integration, I engaged in troubleshooting and debugging tasks, where I learned
how to identify and resolve real-time issues in hardware setups and firmware logic.
My work further extended to supporting PCB-level testing and verification, which allowed
me to become familiar with the practical considerations in circuit design and implementation.
The internship provided a collaborative environment where I worked alongside experienced
engineers, helping me understand the standard product development lifecycle, from concept
and design to implementation and validation. Overall, this experience has been instrumental in
enhancing my technical capabilities, sharpening my problem-solving skills, and preparing me
to confidently tackle challenges in embedded systems and IoT development in a professional
setting.
Project Objectives
The main objectives of the internship included:
• Skill Development: Building expertise in emerging technologies such as
Firebase Integration, PCB design, robotics, Embedded System and Testing.
• Project Implementation: Applying theoretical concepts to develop
practical, real-world solutions.

1
DrmzTech System Innovations Pvt. Ltd.

• Technology Integration: Seamlessly combining multiple systems and


devices into cohesive workflows and products.
Features and Functionalities
The internship covered several innovative projects, each with unique features:
Real-Time Control and Monitoring
• Implemented two-way communication between embedded devices
(ESP8266/ESP32) and Firebase for real-time state control.
• Designed systems to remotely monitor and switch devices (e.g., smart switches) via
mobile applications.
Wireless Communication Using LoRa and RF
• Developed long-range and short-range communication solutions using SX1278
LoRa modules and RF modules.
• Established reliable data exchange between gateways and end-nodes using custom
RF protocols.
Sensor Data Acquisition
• Integrated BMP581 pressure sensors to collect environmental data for use in
health-related and automation projects.
• Used I2C and SPI protocols for interfacing various sensors and modules.
Custom Serial Communication Protocols
• Designed and implemented UART-based protocols to send and receive
acknowledgment data for state validation.
• Created logic to parse, verify, and act on formatted serial data across devices.
SC Servo Motor Driver Control
• Developed control logic for servo motors using SC Servo Drivers with ESP32,
enabling accurate motion control for robotic arms and mechanisms.
GSM-Based Alert Systems
• Contributed to GSM PCB-based Physicure Medical Box, capable of sending
automated alerts/reminders via SMS.

2. TECHNOLOGY OVERVIEW

2.1 Firebase
During my internship, I utilized Firebase Cloud services to enable real-time
communication between IoT devices (ESP8266/ESP32) and a cloud-based
platform. Firebase, developed by Google, is a powerful Backend-as-a-Service
2
DrmzTech System Innovations Pvt. Ltd.

(BaaS) that provides real-time data synchronization, cloud storage, and


authentication without managing a dedicated backend server.
Firebase Cloud played a critical role in storing and updating GPIO states from the
ESP module, allowing bidirectional data flow between the device and mobile/web
applications.
Key Features

Firebase Realtime Database


• Used to store and update GPIO pin states in real-time.
• Provided live synchronization between the ESP module and the cloud.
• Efficient NoSQL database using a JSON tree structure.
Firebase Authentication (Optional)
• Can be used to securely access the database.
• Supports multiple sign-in providers (Email, Google, etc.).
Cloud Functions (Future Scope)
• Could be used to trigger automated responses based on database changes, like sending
alerts or controlling other modules.
Integration with ESP8266/ESP32
• Direct integration using the Firebase ESP8266 or Firebase ESP32 libraries.
• Enabled real-time control and monitoring of devices via the internet.
Firebase Console
• Provided an intuitive interface for monitoring data changes.
• Easy debugging and testing of device interactions
2.2 ARDUINO IDE
the Arduino Integrated Development Environment (IDE) was used as the primary platform for
writing, compiling, and uploading code to ESP8266 and ESP32 microcontrollers. Arduino IDE
supports C/C++ programming and provides an easy-to-use interface with a wide range of
libraries, making it ideal for rapid prototyping of IoT-based applications.
The combination of Arduino IDE and Firebase Cloud enabled real-time device communication,
control, and monitoring, forming a core part of my IoT-based project.

Code Development for ESP Modules

• Arduino IDE was used to write logic for GPIO control, serial communication, and
Firebase integration.

3
DrmzTech System Innovations Pvt. Ltd.

• Libraries like FirebaseESP8266.h, ESP8266WiFi.h, and ArduinoJson.h were included


to support cloud functionality.

Library Management

• Utilized Arduino’s Library Manager to install essential libraries for Firebase and Wi-
Fi connectivity.
• Ensured compatibility with ESP boards through proper versioning.

Board Manager Configuration

• Added ESP8266 and ESP32 board support through Board Manager URLs.
• Enabled flashing of firmware directly to the modules via USB or CP2102 USB-to-
Serial adapter.

Serial Monitor & Debugging

• Used the built-in Serial Monitor to view real-time logs, debug data flow, and verify
acknowledgments from the RF module or Firebase server.

Uploading & Flashing Code

• Code was uploaded via USB to the ESP module using CP2102 interface.
• Configured baud rates and COM ports as per the module’s specifications.

2.3 Morey OS
Morey OS is a lightweight, modular operating system designed specifically for resource-
constrained embedded platforms (e.g., AVR- or ARM-based microcontrollers). It provides just
enough structure and abstraction to enable responsive, multitasking firmware without the
complexity or overhead of a full-fledged desktop or server OS. Embedded in your custom IDE
alongside headers like Digital.h, Serial.h, and util/delay_blocking.h, Morey OS serves as the
backbone for task scheduling, hardware abstraction, and timing services in your projects.
Key Features
• Preemptive Task Scheduler
o Supports multiple concurrent “threads” (tasks), each with its own priority.
o Time-slice or priority-based preemption ensures high-priority tasks (e.g., sensor
sampling) meet real-time deadlines.
• Lightweight Footprint
o Minimal RAM and Flash usage—ideal for small MCUs.
o Configurable kernel size: include only the services you need.

4
DrmzTech System Innovations Pvt. Ltd.

• Tick-Based Timing Services


o System tick timer for millisecond (or configurable) resolution.
o APIs for blocking delays (util/delay_blocking.h) and non-blocking timeouts.
• Inter-Task Communication & Synchronization
o Semaphores and mutexes for safe access to shared resources.
o Message queues for passing data between tasks without busy-waiting.
• Hardware Abstraction Layer (HAL)
o Digital.h: Unified digital I/O interface (pin configuration, read/write,
interrupts).
o Serial.h: Buffered UART driver with interrupt-driven transmit/receive, making
serial comms straightforward.
• Modular Build System
o Selectively compile kernel components (e.g., omit networking if not needed).
o Header-only or library-based modules for easy integration.
• Deterministic Behavior
o Predictable worst-case execution times thanks to simple data structures (e.g.,
fixed-size task lists).
o Helps guarantee real-time responsiveness for critical control loops.
• Portability & Extensibility
o Core kernel is board-agnostic; port layers isolate architecture-specific code.
o Easily add custom device drivers or communication stacks.
• Error Handling & Diagnostics
o Hooks for idle, tick, and fault handlers let you implement watchdog resets,
logging, or safe shutdown.
o Optional trace macros to log task switches and system events.
• Power-Saving Support
o Idle hook can place the MCU in low-power or sleep modes when no tasks are
runnable.
o Tick suppression modes to extend battery life.

2.4 PCB Design

PCB (Printed Circuit Board) Design is a crucial part of electronics design, as it serves as the
foundation for building and connecting electronic components. The design of a PCB involves
creating the layout and connections for electrical components that will be mounted on the

5
DrmzTech System Innovations Pvt. Ltd.

board. This ensures that electrical signals can flow properly between components and that the
overall system functions as expected.

Key Steps in PCB Design


1. Schematic Design:
o The first step in PCB design is creating a schematic diagram, which represents
the electrical connections between components like resistors, capacitors, ICs,
connectors, etc.
o The schematic shows how each component is connected and serves as a
blueprint for the layout of the PCB.
o Popular schematic design tools include KiCad, Eagle, Altium Designer, and
OrCAD.
2. Component Selection:
o Choose components based on the design requirements, such as voltage, current,
power ratings, and form factor.
o Ensure compatibility with other components (e.g., choosing an appropriate
microcontroller or sensor for the application).
3. PCB Layout:
o Translate the schematic into a physical layout, arranging components on the
board.
o Decide on the board dimensions, placing components in a way that minimizes
the signal interference and optimizes the routing.
o Organize components based on their function—group components that work
together or are part of the same subsystem.
4. Routing:
o Connect the components by routing the electrical traces that form the
interconnections.
o The design should minimize trace lengths to reduce resistance, avoid crossing
traces when possible, and ensure proper grounding and power distribution.
o Via holes (through-hole or blind vias) may be used for routing between different
layers.
o Ensure the use of the correct trace widths based on the current ratings for each
path.
5. Design Rule Check (DRC):

6
DrmzTech System Innovations Pvt. Ltd.

o Perform a DRC to ensure that all traces, pads, vias, and other elements comply
with the design rules (e.g., minimum trace width, clearance between traces,
etc.).
o This check helps to prevent manufacturing errors and ensures that the board will
be functional and manufacturable.
6. Gerber File Generation:
o After completing the layout and design verification, generate Gerber files,
which are industry-standard files used by PCB manufacturers to produce the
board.
o Gerber files include information about the layers (copper, solder mask,
silkscreen), drill files (for vias and component holes), and other necessary
manufacturing details.
7. Bill of Materials (BOM):
o A BOM is a list of all components used in the PCB design, including part
numbers, quantities, and descriptions.
o The BOM helps with component procurement and ensures that all parts are
available for assembly.
8. Assembly and Testing:
o After manufacturing, the PCB goes through assembly where components are
soldered to the board.
o After assembly, perform testing to ensure the board functions correctly. This
could include visual inspection, electrical testing (e.g., continuity checks), and
functional testing (e.g., verifying signal paths).
3.5 BMP581 Sensor
The BMP580/BMP581/BMP585 is an absolute barometric pressure sensor. Its small
dimensions, its low power consumption and the highend performance allow the
implementation in a wide range of applications.
Target Application
• Enhancement of GPS navigation (e.g. dead-reckoning, slope detection)
• Indoor navigation (floor detection, elevator detection)
• Outdoor navigation
• Sports applications like calorie counting, fitness activity identification
• Emergency caller location
• Weather forecast
7
DrmzTech System Innovations Pvt. Ltd.

• Vertical velocity indication (e.g. rise/sink speed)


• Altitude control of drones and flying toys
Feature
• Pressure data
• Temperature data

Figure 3.6 BMP581

3.6 SX1278 Lora Module


The Ra-02 is a wireless transmission module based on SEMTECH’s SX1278 wireless
transceiver, incorporating LoRa™ spread spectrum technology. This advanced technology
enables a communication distance of up to 10,000 meters, offering high anti-jamming
capabilities and low power consumption with features like air wake-up functionality.
The SX1278 module is designed primarily for long-range spread spectrum communication,
offering high reliability and minimizing current consumption. It has a high sensitivity of -148
dBm and a power output of +20 dBm, ensuring long-distance transmission with excellent
performance even in challenging conditions.
Features:
1. LoRa ™ Spread Spectrum modulation technology
2. Constant RF power output at + 20dBm-100mW voltage change
3. Half-duplex SPI communication
4. Supports FSK, GFSK, MSK, GMSK, LoRa ™ and OOK modulation modes
5. Automatic RF signal detection, CAD mode and very high speed AFC
6. Packet engine with CRC up to 256 bytes
7. Small footprint dual-row stamp-hole patch package
8. Shielded housing
9. Patch Antenna

8
DrmzTech System Innovations Pvt. Ltd.

Lora -Transmitter

Lora-Receiver

Figure 3.7 Lora-02 SX1278

3.7 SC Servo Driver with ESP32

9
DrmzTech System Innovations Pvt. Ltd.

This ESP32-based bus servo control board is designed for versatile robotic applications. It
supports the control of up to 253 bus servos via a web interface, enabling servo programming
to modify IDs and modes (servo/motor). The board provides real-time feedback on servo
parameters such as angle, load, voltage, and mode. It features a serial communication interface
for integration with higher-level systems and an onboard OLED screen to display essential
information. This makes it ideal for robotics projects like robotic arms, hexapods, humanoids,
and wheeled robots that require precise servo control and feedback.

Figure 3.8 ESP Board with Servo Driver

Features

• Allows controlling up to 253 SC, ST series serial bus servos at the same time (adequate
power supply required).

• Wide range voltage input 6-12V (the input voltage and the servo voltage must be
matched).

• Built-in WiFi and Bluetooth, as well as ESP-NOW support, for remote control and
servo debugging.

• Open source web application and various robot structures.

• Compact size and space-saving, suitable for integration into sorts of space-limited
projects.

10
DrmzTech System Innovations Pvt. Ltd.

3. INTERNSHIP OVERVIEW
Role and Responsibilities
1. Embedded Systems Development:
• Programmed microcontrollers (ESP8266, ESP32, Arduino Uno) using
Arduino IDE.
• Developed and debugged real-time embedded applications involving sensor
data processing and GPIO control.
2. Wireless Communication Implementation:
• Worked with LoRa (SX1278) and LoRaWAN (Dragino LA66) modules for
long-range communication.
• Designed and tested custom protocols for serial data exchange using RF
modules (e.g., RW630 and RW54).
3. IoT Integration with Firebase:
• Integrated ESP8266/ESP32 modules with Firebase Realtime Database using
HTTPS/REST protocols.
• Created structured JSON paths for controlling GPIO states and updating
real-time data from sensors.
4. Serial Communication Protocol Design:
• Developed custom communication formats for acknowledgment and data
handling (e.g., #FE80...{(M1,AbcdeFGH)}).
• Handled UART communication with modules like CP2102, CP1310 for
real-time data transfer.
5. Sensor and Actuator Interface:
• Interfaced various peripherals including PIR sensors, ultrasonic sensors, and
relays.
• Created logic for GPIO control based on sensor input and remote command
reception.
6. Real-Time Monitoring & Control:
• Designed systems to send sensor data (temperature, humidity, etc.)
wirelessly and display/control remotely.
• Implemented feedback mechanisms and data logging via Firebase.
7. Debugging and Optimization:
• Performed troubleshooting of hardware and software issues during data
transmission.
11
DrmzTech System Innovations Pvt. Ltd.

• Optimized embedded code for reliability and long-term use.


3.2 Learning Goals
1. Gain Hands-On Experience in Embedded Systems:
• Understand microcontroller programming and interfacing with real-
world hardware components like sensors, relays, and communication
modules.
2. Master Wireless Communication Protocols:
• Learn to implement and troubleshoot LoRa, LoRaWAN, RF, and UART
communication protocols in real-time applications.
3. Explore IoT Cloud Integration:
• Acquire practical knowledge of connecting embedded systems to cloud
platforms like Firebase for remote data monitoring and control.
4. Develop Protocol Design & Serial Communication Skills:
• Create and manage custom serial data formats for device-to-device
communication and acknowledgments.
5. Improve Embedded C/C++ Programming Skills:
• Write efficient and modular code for microcontrollers using Arduino IDE
and custom libraries.
6. Understand System-Level Debugging and Optimization:
• Learn to debug hardware-software interactions and improve code reliability
for long-term deployments.
7. Strengthen Project Management and Documentation Abilities:
• Document technical workflows, maintain proper version control, and
contribute effectively to team-based IoT projects.

12
DrmzTech System Innovations Pvt. Ltd.

DRMZ Team:

I would like to extend my heartfelt thanks to the entire DRMZ team for the incredible
opportunity to join as an intern. This journey has been nothing short of amazing—a truly
enriching learning experience that has contributed immensely to my personal and professional
growth. I’m deeply appreciative of the trust, encouragement, and guidance you’ve offered me
throughout my time here. Being part of such a dynamic, skilled, and forward-thinking team has
been both inspiring and fulfilling. Thank you for welcoming me and for making this internship
so memorable.

For My Colleagues and Senior: A heartfelt thank you to my amazing colleagues for your
constant guidance, collaboration, and encouragement. Your support and willingness to share
knowledge have made this internship both enjoyable and enriching. I have learned so much
from working alongside all of you, and I deeply appreciate the positive and welcoming
environment you’ve created.
Thank you all for making my internship experience truly memorable!

13
DrmzTech System Innovations Pvt. Ltd.

4. PROJECT DESCRIPTIONS And TESTING

Scope and Objectives

Each project was designed to address specific real-world challenges. The scope
included:

• Robotic Arm: Designed and developed a robotic arm using SC servos for precise
movement control.
• Smart Switch Board : Enhancing ease of control for household appliances.
• Adicine medical box : A Medical Reminder and Carry box with
Apk.

4.1 ROBOTIC ARM :

RoArm-M1 is a versatile robotic arm based on the ESP32 architecture, designed for precision
and flexibility. It has 5 degrees of freedom, including a gripper for holding objects, and uses
high-torque ST3215 serial bus servos (30kg.cm capacity) for smooth and powerful movement.
The arm provides real-time feedback on position, voltage, current, and temperature, ensuring
precise control and safety.

It comes with built-in WiFi, an OLED display, and RGB-LED lights, making it easy to monitor
and control. RoArm-M1 supports multiple control modes, such as angle control, inverse
kinematics, motion replay, and leading-following via ESP-NOW. It can connect to PCs,
Raspberry Pi, or Jetson Nano through USB, allowing for JSON-formatted serial
communication for accurate command execution.

With open-source support, RoArm-M1 is ideal for robotics research, AI-driven automation,
and education, offering an easy-to-use yet powerful robotic solution.

The scope of the project includes the end-to-end design, integration, and control of a robotic
arm system that demonstrates real-time servo coordination and programmable movements. The
major areas of focus are:

a) Mechanical Design and Assembly The robotic arm consists of a where each joint is driven
by a dedicated SC series servo motor. The mechanical structure was designed to ensure stability
and flexibility, with carefully selected materials to withstand the required payload and torque.

14
DrmzTech System Innovations Pvt. Ltd.

b) Actuation with SC Servos The system uses SC servos due to their reliable serial bus
communication, real-time feedback, and programmable motion modes (servo/motor mode).
Their ability to be daisy-chained simplifies the wiring and scalability of the system.
c) End Effector Development A [e.g., two-finger gripper] is developed as the arm’s end
effector. It is designed to handle light-to-medium weight objects, with a focus on grip precision
and adaptability to different shapes.
d) Control System Architecture The robotic arm is controlled via ESP32 platform. This
microcontroller handles communication with the SC servos over UART and runs the logic for
motion commands, feedback monitoring, and task sequences.
e) Software and Interface Control software is developed to operate the robotic arm manually
and through pre-defined sequences. Depending on the system, this may include:

f) Feedback Implementation The servo’s built-in feedback (position, load, speed) is utilized
for:
g) Power Management A robust power system is designed to supply consistent voltage and
current to the servos, considering peak loads and safety limits. Proper regulation and
distribution are ensured
to avoid brownouts or servo reset issues.

Figure 3.8 Robotic Arm.

The primary objectives of the robotic arm project are as follows:


• To design and fabricate a multi-joint robotic arm using SC series servo motors.
15
DrmzTech System Innovations Pvt. Ltd.

• To achieve accurate and synchronized control of servo motors through serial bus
communication.
• To develop a control system capable of executing pick-and-place operations.
• To utilize real-time feedback from the servos for precise joint movement and system
diagnostics.
• To create a user interface (manual or programmable) for controlling the arm’s
movement
• To implement basic automation tasks such as object manipulation or repeatable
movement sequences.
• To ensure safe operation with appropriate power management and overload
handling.
4.2 Adicine Medical Box
Smart Medical Box with Integrated Android Application In this project, a Smart Medical Box
has been designed and developed to support individuals—especially the elderly and chronically
ill—in managing their medication schedules more efficiently and safely. The system includes
both hardware and software components developed by me. System Overview: The hardware
features a microcontroller-based circuit with a real-time clock (RTC), display module
(LCD/OLED), buzzer, indicator LEDs, and support for Bluetooth and Wi-Fi communication.
The box stores different medicines in separate compartments, and each one is linked to a
scheduled time and name of the medicine. An Android application (APK) was developed to
allow users to set medicine reminders, connect to the box via Bluetooth/Wi-Fi, and update
medicine schedules.

Figure 3.6 Adicine PCB

Key Features:

16
DrmzTech System Innovations Pvt. Ltd.

• Real-Time Reminders: Alerts users with a buzzer and displays the medicine name at
the exact scheduled time.
• App Integration: Android application allows setting up medicine schedules, names,
dosages, and connecting via Bluetooth or Wi-Fi.
• Dual Connectivity: Works with both Bluetooth for local control and Wi-Fi for remote
monitoring or integration with Firebase/cloud storage.
• User-Friendly Interface: Simple, clean interface for both the hardware display and the
mobile app, suitable for elderly users.
• Missed Dose Notification: Optionally sends an alert if a scheduled dose is missed.
• Secure Compartment Control: Optional locking mechanism for compartments to
release only when it’s time for that specific medicine.

Figure 3.6 Medical Box

Benefits:
• Improved Medication Adherence: Ensures timely intake of prescribed medicine,
reducing health risks due to missed doses.
• Caregiver Support: Enables family members or healthcare providers to monitor or set
schedules remotely.
• All-in-One System: Combines scheduling, alerting, and real-time updates in one
system.

17
DrmzTech System Innovations Pvt. Ltd.

4.3 SMART SWITCH BOARD :

Smart Switch Board is an IoT-based system designed to control and monitor electrical
appliances remotely via the internet. This system uses a combination of microcontrollers,
Firebase Realtime Database, smart LEDs, and an optional gateway for centralized
management. It allows users to operate switches from a web interface and view the real-time
status of connected devices.

System Architecture

The core of the smart switch board is built around a microcontroller such as an ESP32 or
ESP8266, which connects to the internet over Wi-Fi. Each switch controls a relay that can
toggle an appliance (like a light or fan) ON or OFF. Smart LEDs are embedded alongside each
switch to visually indicate its current state.

The system is integrated with Google Firebase, a cloud-based real-time database that stores and
synchronizes the state of each switch. When a user toggles a switch from the web interface, the
new state is instantly updated in Firebase, and the microcontroller reflects this change by
actuating the corresponding relay and LED.

Figure 3.5 Gateway PCB

Gateway Integration gateway, dedicated ESP32 module, acts as a central controller for multiple
smart switch nodes. It aggregates data from different boards and communicates with Firebase
efficiently. The gateway also handles scenarios where internet connectivity is intermittent by
buffering data and pushing updates when the network is restored. This enhances system
reliability and scalability, especially in large deployments.

Features

18
DrmzTech System Innovations Pvt. Ltd.

• Real-time control: Switches can be controlled instantly from anywhere using a


web-based dashboard.

• Bi-directional sync: Changes made via hardware (manual press) or software


(web) are synchronized through Firebase.
• Visual feedback: Smart LEDs provide clear ON/OFF indication for each switch.
• Remote monitoring: The current state of all switches can be viewed from any
internet-connected device.
• Scalability via Gateway: Multiple switch boards can be managed under one
network, thanks to the centralized gateway.

5. TESTING

5.1 NOKIA5110 LCD

The Nokia 5110 LCD Display Module gets its name from the iconic Nokia 5110/3310 mobile
phones, where it was originally used as a display unit. Now, it has found a significant place
among electronics hobbyists and engineers for displaying graphics and text in embedded
systems and DIY projects.

Overview

The Nokia 5110 is a low-cost, monochrome graphic LCD module consisting of an 84x48 pixel
display. It is extremely easy to use and ideal for projects involving graphic output. The module
comes mounted on a solderable PCB and is controlled by the Philips PCD8544 LCD driver,
which integrates all the necessary functions for display control including internal generation of
supply and bias voltages.

Figure 5.1 NOKIA5110 LCD

19
DrmzTech System Innovations Pvt. Ltd.

Key Features

• Resolution: 84x48 dot matrix, capable of showing up to 4 lines of characters.


• Communication: SPI (Serial Peripheral Interface), using only 5 control pins.
• Wide MCU support: Compatible with Arduino, AVR, 8051 (MCS51), and other SPI-
capable controllers.
• High data transfer rate up to 4 Mbps.
• Low power consumption, typically under 200µA, and includes a power-down mode.
• Compact design, with the controller IC bonded to the display glass.
• Simple installation with metal hooks and the ability to mount using conductive glue.
• Backlight control via GND connection (“LIGHT” pin).
Pin Configuration

Example Arduino Pin Mapping:

RST — D3
CE — D4
DC — D5
DIN — D6
CLK — D7
BL — GND
Vcc — 5V
GND — GND
Operation at Different Voltages

3.3V Operation: Although designed for 3.3V, it can work with 5V MCUs by using simple 10kΩ
resistors as level shifters. Due to the PCD8544’s internal clamps, these resistors safely limit
current without needing complex level shifting circuits.5V Operation: The module can also
operate directly at 5V, which simplifies interfacing. However, using the same 10kΩ resistors is
recommended to reduce streaks or artifacts on the display.

Application and Usability

The Nokia 5110 LCD is widely adopted in embedded systems, offering a reliable and low-
power solution for visual outputs. It can be easily integrated and is backed by numerous
community tutorials and examples, making it a go-to display for beginners and experts alike.

5.2 TFT 9341 LED display


20
DrmzTech System Innovations Pvt. Ltd.

WF28ETLAJDNN0 is a 2.8-inch full-color ILI9341 TFT display module with a resolution of


240x320 pixels. This module is built-in with the ILI9341V IC, supporting an 8/16-bit 8080-
series Parallel MCU Interface. The module dimensions are 50.0 x 69.2 mm, with an active area
of 43.2 x 57.6 mm. It integrates the ILI9341 TFT display controller, with an analog supply
voltage ranging from 2.5V to 3.3V.

WF28ETLAJDNN0 is a portrait-mode ILI9341 TFT display module. If you require a


landscape-mode version, please contact us for further technical support. This 2.8-inch ILI9341
TFT LCD module features a typical brightness of 500 cd/m², a contrast ratio of 500:1, and an
operating temperature range from -20°C to +70°C. The storage temperature range is -30°C to
+80°C.

This 2.8-inch ILI9341 TFT display with a 6:00 o'clock viewing direction is well-suited for
devices that need to be easily readable above eye level without fading. It provides a reliable
solution for industrial applications, including

• Machine Automation: The display module can be used in machine automation


applications, such as control panels and HMIs.

• Temperature Control: The display module can be used in temperature control


applications, such as in ovens, furnaces, and heat exchangers. Its high resolution and
color accuracy make it ideal for displaying temperature readings and control settings.

• Testing Equipment: The high resolution and color accuracy of TFT LCD modules make
them ideal for visual inspection applications, such as quality control in manufacturing,
agricultural inspection, and surveillance.

• Medical Devices: The display module can be used in medical devices, such as in patient
monitoring systems, medical imaging systems, and medical laboratory equipment. Its
high resolution, color accuracy, and durability make it ideal for displaying critical
patient information and control settings.

Its compact size, low power consumption, and easy integration make it an ideal choice for
many applications.

21
DrmzTech System Innovations Pvt. Ltd.

Figure 5.1 TFT ILI9341 LCD

6. CHALLENGES FACED

6.1 TECHNICAL CHALLENGES

During the course of my internship, I encountered several technical challenges that helped me
grow both as a learner and as a problem-solver. Some of the key challenges are detailed below:

1. Interfacing and Compatibility Issues : One of the first hurdles I faced was interfacing
various modules such as the Nokia 5110 LCD with microcontrollers like the Arduino UNO and
ESP8266. Differences in operating voltages (3.3V vs. 5V) and SPI communication protocols
required careful handling and proper level shifting to ensure stable operation.

2. Display Distortion and Voltage Stability : While working with the Nokia 5110 LCD, I
observed screen flickering and display distortion. This issue was traced back to unstable supply

22
DrmzTech System Innovations Pvt. Ltd.

voltage and insufficient current limiting resistors. Solving it required experimenting with
various resistor values and improving the power supply configuration.

3. Serial Communication Errors : In projects involving RF modules and serial data


transmission, I encountered data corruption and unexpected characters during serial
communication. These were caused by mismatched baud rates and noise in transmission.
Troubleshooting involved fine-tuning the communication settings and implementing error-
checking mechanisms.

4. Firebase Integration Complexity : Integrating real-time databases like Firebase with


microcontrollers introduced challenges such as library compatibility issues, data structure
mismatches, and delay in data updates. Managing JSON parsing and ensuring efficient data
handling were crucial to achieving smooth two-way communication between the hardware and
cloud.

5. Debugging and Testing Time: Debugging real-time embedded systems is always time-
consuming. Errors in hardware connections, wrong pin configurations, and subtle logic bugs
often required a systematic approach of testing each component individually, monitoring serial
output, and using LEDs for state indication.

6. Hardware Instability : Loose jumper wires, poor soldering, or unstable breadboard


connections caused intermittent behavior in circuits. I had to repeatedly inspect and reinforce
connections to ensure consistent hardware performance throughout testing and demonstrations.

7. Documentation and Code Management : Maintaining clear and well-documented code


was initially a challenge due to the rapid pace of prototyping. However, I later adopted a
structured approach to code commenting, version control, and folder management which
significantly improved project clarity and reusability.

6.2 TROUBLESHOOTING AND PROBLEM SOLVING

1. Issue: Communication Failure Between ESP32 and Firebase


Problem: The ESP32 module was not able to update or retrieve data from Firebase during
testing.
Troubleshooting: Checked the Wi-Fi credentials and confirmed network connectivity.
Verified Firebase authentication and database URL.Used serial debugging to monitor data
transmission. Checked Firebase rules to ensure read/write permissions were enabled.

23
DrmzTech System Innovations Pvt. Ltd.

Solution: Fixed incorrect Firebase host URL and updated the authentication token. Ensured
the database path used in the code matched the Firebase structure.
2. Issue: Incorrect GPIO Pin Responses Based on Serial Acknowledgment
Problem: The ESP module was not accurately updating GPIO states based on received
acknowledgment data.Troubleshooting: Parsed and analyzed the serial string format for
anomalies. Verified logic conditions for uppercase (ON) and lowercase (OFF) values.Ensured
synchronization between sent and received acknowledgment patterns.
Solution: Optimized the parsing function using character-by-character comparison and
ensured array bounds were respected. Validated all 8 GPIO states before pushing to Firebase.
3. Issue: LoRa Module Not Receiving Data Problem: The SX1278 LoRa module wasn't
receiving data from the sender.
Troubleshooting: Verified wiring and power supply. Checked both sender and receiver were
set to the same frequency and bandwidth. Used LEDs and Serial.print to confirm the
transmission was happening.
Solution: Corrected mismatched frequency and enabled automatic gain control for better
reception. Data started flowing as expected.
4. Issue: Serial Data Containing Garbage Values
Problem: Received serial strings had unwanted characters, affecting data parsing.
Troubleshooting:Isolated the issue to incorrect baud rate settings.
Added buffer clearing and delay after reading serial data.
Solution: Set the correct baud rate on both modules and filtered non-printable characters in the
received string.
6.3 COMMUNICATION AND COLLABORATION
Collaborating with team members and receiving continuous support and feedback from our
team leader played a vital role in the smooth execution of our internship project. From the
beginning, we emphasized the importance of communication by conducting regular team
meetings to track progress, set short-term goals, and identify any technical or organizational
challenges. These meetings provided a platform to share individual insights, learn from one
another, and brainstorm innovative solutions. When faced with technical difficulties, our
collaborative approach enabled us to troubleshoot issues more efficiently by leveraging the
diverse skill sets and perspectives within the team. This collective problem-solving process not
only enhanced our technical knowledge but also strengthened our teamwork and adaptability.

7. PROJECT RESULTS
24
DrmzTech System Innovations Pvt. Ltd.

7.1 AUTOMATION
The implementation of automation in my internship project delivered efficient and reliable
results. Devices such as LEDs, motors, and relays were successfully controlled in real time
using Firebase cloud updates. The automated system responded instantly to user commands,
eliminating manual switching and reducing errors. The acknowledgment mechanism ensured
accurate execution and provided feedback for each action. Automation also enabled continuous
monitoring and logging of device states, improving transparency and enabling future analytics.
Overall, the project demonstrated how automation enhances performance, scalability, and user
convenience in IoT systems. It proved especially effective for applications in smart homes and
remote device management, showcasing the practical benefits of automated control in real-
world scenarios.
7.2 MONITORING
Monitoring was a crucial aspect of my internship project, ensuring real-time visibility and
control of connected devices. Using Firebase Realtime Database, the system continuously
tracked the status of each device, including GPIO outputs and acknowledgment responses. Any
change in the system—whether triggered manually or automatically—was instantly reflected
on the cloud interface, allowing users to view the live status from anywhere. This remote
monitoring capability reduced the need for physical inspections and enabled proactive
responses to faults or command failures. Historical data logging also supported future analysis
and system optimization. The monitoring feature enhanced system transparency, reliability, and
user trust, making the solution suitable for applications such as smart energy systems, home
automation, and industrial control.
7.3 SHORT RANGE COMMUNICATION
Short-range communication was implemented using RF modules like the SX1278 and RW630,
enabling wireless data exchange between devices without relying on the internet. This method
was useful for transmitting control commands and receiving acknowledgments over distances
up to several hundred meters. The system used serial communication protocols to ensure
reliable message delivery and low latency. Short-range communication added robustness to the
project, especially in scenarios with limited internet access, and proved effective for quick,
local control in smart automation setups.
7.4 REMINDER
The reminder functionality of the Smart Medical Box was successfully implemented and tested.
The system effectively provides timely alerts to users based on the schedule set through the
custom Android application. At the predefined time, the box triggers a buzzer sound, displays
25
DrmzTech System Innovations Pvt. Ltd.

the name of the medicine on the screen, and activates an LED indicator near the respective
compartment. This ensures that the user is clearly informed about which medicine to take and
when.
The synchronization between the mobile app and the hardware through Bluetooth/Wi-Fi
modules worked reliably, allowing real-time schedule updates and notifications. The reminder
system proved especially beneficial for elderly users and those on complex medication
routines, significantly reducing the chances of missed or incorrect dosages.
Overall, the reminder feature enhanced the usability and practicality of the Smart Medical Box,
making it a reliable solution for daily medicine management.

8. PROTOCOLS USED
• I2C (Inter-Integrated Circuit): I2C is a two-wire communication protocol used for
connecting low-speed devices like sensors, EEPROMs, and ADCs in embedded
systems. It supports multiple masters and slaves using a clock (SCL) and data (SDA)
line. Its simplicity and low pin count make it ideal for communication between ICs on
the same board.
• UART (Universal Asynchronous Receiver/Transmitter): UART is a hardware
communication protocol used for asynchronous serial communication between two
devices. It transmits data in a byte-wise fashion using only two lines: TX (transmit) and
RX (receive). Common in microcontroller systems, UART doesn't require a clock
signal, making it simple and reliable for point-to-point communication.
• SPI (Serial Peripheral Interface): SPI is a high-speed, full-duplex serial
communication protocol commonly used to interface microcontrollers with peripherals
like sensors, memory chips, and displays. It uses four lines: MISO, MOSI, SCLK, and
SS. SPI is faster than I2C but requires more pins, making it suitable for applications
needing high-speed data exchange.
• HTTP/HTTPS (Hypertext Transfer Protocol): HTTP is a protocol used for
communication between web clients and servers, mainly for accessing web pages.
HTTPS is the secure version that uses encryption via SSL/TLS. Both are stateless and
used widely in IoT to send sensor data or receive commands from cloud platforms using
RESTful APIs.

26
DrmzTech System Innovations Pvt. Ltd.

• LoRaWAN (Long Range Wide Area Network): LoRaWAN is a low-power, long-


range wireless communication protocol designed for IoT applications. Operating on
unlicensed ISM bands, it supports secure bi-directional communication and is ideal for
remote sensors in smart agriculture, cities, or industry. It structures data in
uplink/downlink packets managed via gateways and a central network server.
• Firebase REST API: The Firebase REST API allows real-time database interaction
using HTTP methods like GET, PUT, POST, and DELETE. It enables applications,
especially in IoT, to read/write data from Firebase over the internet. It's lightweight,
supports JSON format, and allows real-time sync across devices without needing full
SDKs.
• RF Communication Customer Protocol: RF Communication using a customer-
specific protocol involves transmitting data wirelessly over radio frequencies using a
proprietary format. These protocols are often designed for specific use-cases, such as
remote control or sensor networks, optimizing payload structure, addressing, and
reliability mechanisms based on the client’s unique requirements and hardware
constraints.
9. CONCLUSION
My internship has been an enriching experience that significantly contributed to both my
technical knowledge and personal development. Over the course of the internship, I had the
opportunity to apply theoretical concepts in real-world scenarios, enhancing my understanding
of embedded systems. I developed practical skills which will be invaluable in my future career.
Collaborating with experienced professionals allowed me to learn effective problem-solving
techniques, improve my communication skills, and adapt to a professional work environment.
The exposure to industry-standard tools and practices has broadened my perspective and
clarified my career goals. Overall, this internship has not only boosted my confidence but also
strengthened my commitment to pursue excellence in the field of Electronics and
Communication Engineering. I am grateful for this opportunity and the guidance provided
throughout the internship.

27
DrmzTech System Innovations Pvt. Ltd.

10. Month-wise Detailed Work Report


Name: Vikash Banwari

Internship Duration: 24th July 2024 to 21th March 2025

Leave Taken: July(2 d), Aug(4 d), Sept(3 d), Octo(6 d), Nov(8 d), Dec(11 d), Jan(3 d), Feb(3

d) Mar(4 d).

Detailed Work Summary


S.No. Task Description Start Date Completion Date
1 LCD testing 24-07-2024 24-07-2024
2 Learn About 25-07-2024 25-07-2024
Atmega328P
3 Morey_OS 27-07-2024 29-07-2024
Installation and run
Basic codes
4 Kicad Installation 30-07-2024 31-07-2024
and made basic PCB
5 PCB printing & 01-08-2024 01-08-2024
soldering
6 Firebase Integration 02-08-2024 03-08-2024
ESP32
7 Test ESP01 04-08-2024 08-08-2024
8 Firebase 05-08-2024 05-08-2024
Implementation
using ESP01
9 Implement for 06-08-2024 15-08-2024
Acknowledgement
10 Work with Moeen 16-08-2024 22-08-2024
on smart board PCB
11 Testing Lora module 25-08-2024 28-08-2024
12 Testing LED 29-08-2024 01-09-2024
9341ILI tft display
13 Work with curtain 02-09-2025 12-09-2024
PCB with Girraj
14 Helps Rahul sir to 13-09-2024 18-09-2024
manufacturing 30+
physicure pcb and
testing
15 Test Adicine app 20-09-2024 20-09-2024
and made a report
16 Made changes in the 21-09-2024 22-09-2024
curtain pcb

28
DrmzTech System Innovations Pvt. Ltd.

17 Manufactured to 23-09-2024 24-09-2024


Medical box PCB’s
18 Learn about 3D 24-09-2024 27-09-2024
modeling and made
basic design
19 Test nokia5114 28-09-2024 29-09-2024
though medical box
PCB’s
20 Main PCB testing 29-09-2024 29-09-2024
21 Work with moeen 30-09-2024 03-10-2024
on IR blaster
22 Code uploading on 04-10-2024 04-10-2024
Physicure PCB’s
23 Solving buzzer 05-10-2024 08-10-2024
problem into the
pcb’s
24 Making code of 08-10-2024 09-10-2024
curtain PCB with
girraj
25 Test all physicure 10-10-2024 13-10-2024
pcbs with IoT sims
26 Done wiring of 14-10-2024 17-10-2024
Physicure box
27 Packing of 18-10-2025 23-10-2024
Physicure boxs
28 Making challan of 24-10-2024 24-10-2024
physicure box and
list
29 Making and testing 26-10-2024 27-10-2024
of MPVE meter
cable
30 Communicate and 03-11-2024 03-11-2024
attend with Piyush
sir regarding adicine
app
31 Made report and 04-11-2024 04-11-2024
add screenshots,
videos on trello
32 Read 05-11-2024 06-11-2024
documentation of
human sensor and
work on it
33 R&D based on 07-11-2024 09-11-2024
microbit
34 Communicate with 11-11-2024 11-11-2024
robo.in for
nokia5114

29
DrmzTech System Innovations Pvt. Ltd.

35 Assemble medical 15-11-2024 19-11-2024


box and testing of
pcbs
36 Help Rahul sir for 20-11-2024 20-11-2024
manufactured two
IISC PCB’s
37 Learn about the 21-11-2024 21-11-2024
RS45 protocols
38 Manufactured new 22-11-2024 23-11-2024
two updated pcbs of
medical box
39 Tested three 23-11-2024 24-11-2024
nokia5110 and
make a adicine
report
40 Problem 25-11-2024 25-11-2024
identification into
the pcbs
41 Chip signature 26-11-2024 26-11-2024
problem
42 Data download 02-12-2024 02-12-2024
work
43 Work with bhunesh 05-12-2024 05-12-2024
in the industrial
project
44 Learn about 16-12-2024 16-12-2024
software serial
45 Communicate two 17-12-2024 17-12-2024
Arduino through
software serial
46 Communicate two 18-12-2024 18-12-2024
RS45 IC’s
47 Test 10 lora module 19-12-2024 19-12-2024
48 Test and made 20-12-2024 20-12-2024
report on adicine
app
49 Implementing and 21-12-2024 22-12-2024
testing LCD’s
through
atmega328P
50 Implement firebase 25-12-2024 26-12-2024
code for new
website

30
DrmzTech System Innovations Pvt. Ltd.

51 Learn tutorials of 27-12-2024 27-12-2024


morey os and
installed new
version
52 Tesing all the code 28-12-2024 28-12-2024
of morey os

53 Testing and making 29-12-2024 31-12-2024


pcb of BMP51
sensor
54 Learn about the SC 02-01-2025 03-01-2025
servo motors
55 Tried to runs basic 04-01-2025 07-01-2025
code
56 Made a user manual 08-01-2025 09-01-2025
for arm robot
57 Learn about 10-01-2025 12-01-2025
robotRX-01 for
basic codes
impletation like
feedback, ping, etc.
58 Communicate with 18-01-2025 18-01-2025
adicine group and
making a report
based on all bugs
59 Problem 19-01-2025 19-01-2025
identification into
the 4 ID motor
60 Solving gears 20-01-2025 24-01-2025
problem of arm
robot
61 Work with pravesh 25-01-2025 26-01-2025
sir on medical pcbs
62 Learn about 27-01-2025 28-01-2025
Zigbee in
coordinator, router
and device mode
for CC2530.
63 Manually calculate 29-01-2025 05-01-2025
the positioning of
arm robot and
implemented like no
damage will occure
64 Communicate with 06-02-2025 06-02-2025
pravesh sir, and
made changes
according to pcbs

31
DrmzTech System Innovations Pvt. Ltd.

65 Installed MATLAB 07-02-2025 07-02-2025


66 selfmade MATLAB 08-02-2025 08-02-2025
GUI for arm robot
67 Made a arm robot 09-02-2025 09-02-2025
user manual for
manit
68 Test matlab gui and 10-02-2025 13-02-2025
send the robot to
manit
69 Work on firebase to 14-02-2025 14-02-2025
tesing websocket
protocols
70 Installed Nokia5110 16-02-2025 17-02-2025
libraries into the
morey os
71 Learn I2C protocols 18-02-2025 19-02-2025
online video call
and implemented
72 Upload code and 21-01-2025 21-02-2025
test all
functionalities of
medical pcbs that
return from pravesh
sir
73 Tesing serials of 22-02-2025 26-02-2025
gateway and
implemented code
74 Test adicine and 27-02-2025 27-02-2025
serial app data on
LCD
75 Learn how to 28-02-2025 03-03-2025
implement software
serial into the
morey os and tried
76 Test data and time 04-03-2025 04-03-2025
code into the
medical pcbs
77 Tried and test 05-03-2025 06-03-2025
human sensor XAI0
78 Tesing of medical 07-03-2025 09-03-2025
box with adicine
app
79 Work with amit to 10-03-2025 11-03-2025
made string based
acknowledgment

32
DrmzTech System Innovations Pvt. Ltd.

80 Help girraj and 16-03-2025 16-03-2025


bhunesh to
assemble microbit
pcbs into the casing
81 Test for crash 17-03-2025 18-03-2025
sensor
82 Testing all the 18-03-2025 21-03-2025
functionalities of
medical box and
made a video

11. References
1. https://github.com/sudeshmoreyos/Morey_os-demo-1.0
2. https://www.waveshare.com/modbus-poe-eth-relay.htm1
3 https://www.bosch-sensortec.com/products/environmental-sensors/pressure-
sensors/bmp581
4. http://how2electronics.com/interfacing-sx1278-lora-module-with-arduino/
5. https://firebase.google.com/
6. https://docs.arduino.cc/libraries//
7. https://cdn-shop.adafruit.com/datasheets/ILI9341.pdf/
12 APPENDIX
12.1 Firebase Code for sending command and Acknowledged to Gateway
#include <ESP8266WiFi.h>
#include <Firebase_ESP_Client.h>
#include "addons/TokenHelper.h"
#include "addons/RTDBHelper.h"

// Wi-Fi credentials
#define WIFI_SSID "Iqoo"
#define WIFI_PASSWORD "11111111"

// Firebase project credentials


#define API_KEY "AIzaSyDP1jMbtsl9tB1hrlf-cIL0IBBmt5LrQ2s"
#define USER_EMAIL "[email protected]"

33
DrmzTech System Innovations Pvt. Ltd.

#define USER_PASSWORD "password"

// Firebase Database URL


#define DATABASE_URL "https://avatarbot-aff74-default-rtdb.asia-
southeast1.firebasedatabase.app/"

// Firebase objects
FirebaseData stream;
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

// Dynamic path for the RTDB stream


String userId = "n8HkTQd8ncYfbXDypCW4PCY8Ln72"; // Example user ID
String listenerPath = "/users/" + userId + "/reception/"; // Constructed path

// Initialize Wi-Fi
void initWiFi() {
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(100); // Faster retry intervals
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi.");
}

// Check Wi-Fi connection status


void checkWiFiConnection() {
if (WiFi.status() != WL_CONNECTED) {
initWiFi();

34
DrmzTech System Innovations Pvt. Ltd.

}
}

// Serial input handling


void handleSerialInput() {
static String incomingData;
bool hasUpdates = false; // Flag to track if there are any updates

while (Serial.available() > 0) {


char incomingChar = Serial.read();
incomingData += incomingChar;

if (incomingChar == '}') {
int startIndex = incomingData.indexOf("{(M1,") + 5;
int endIndex = incomingData.indexOf(")}");

if (startIndex != -1 && endIndex != -1) {


String subkeys = incomingData.substring(startIndex, endIndex);

// Update Firebase based on subkeys (A0 to A9)


for (int i = 0; i < 10 && i < subkeys.length(); i++) {
String path = "/users/" + userId + "/reception/" + String(i) + "/stateA" + String(i);

// Try to retrieve the current state to ensure the key exists


if (Firebase.RTDB.getInt(&fbdo, path)) {
int currentState = fbdo.intData();
Serial.println("Key " + path + " exists with value: " + String(currentState));

// Update the state based on whether the subkey is upper or lower case
int state = isUpperCase(subkeys.charAt(i)) ? 1 : 0;

35
DrmzTech System Innovations Pvt. Ltd.

// Update the key directly without JSON


if (Firebase.RTDB.setInt(&fbdo, path, state)) {
Serial.println("Updated " + path + " to value: " + String(state));
hasUpdates = true; // Set the flag if an update is made
} else {
Serial.println("Failed to update " + path + ". Error: " + fbdo.errorReason());
}
} else {
Serial.println("Key " + path + " does not exist. Error: " + fbdo.errorReason());
}
}

if (!hasUpdates) {
Serial.println("No updates were made.");
}
}
incomingData = ""; // Clear the incoming data after processing
}
}
}

void streamCallback(FirebaseStream data) {


String path = data.dataPath(); // Get the full path
Serial.println("Data path: " + path); // Print the data path for debugging
Serial.println("Listener Path: " + listenerPath); // Print the listener path

// Modify the logic to handle the incoming paths like "/5/A5"

36
DrmzTech System Innovations Pvt. Ltd.

if (path.startsWith("/")) {
path = "/users/" + userId + "/reception" + path; // Adjust the path to match the expected
structure
}

String expectedPathPrefix = "/users/" + userId + "/reception/";

// Check if the adjusted path starts with the correct prefix


if (path.startsWith(expectedPathPrefix)) {
Serial.println("Path is within the reception structure."); // Debugging

// Extract the integer part and subkey from the path


int receptionPathStartIndex = expectedPathPrefix.length();
int firstSlashIndex = path.indexOf('/', receptionPathStartIndex);

// If a slash is found, extract the integer part and the subkey


String integerPart, subKey;
if (firstSlashIndex != -1) {
integerPart = path.substring(receptionPathStartIndex, firstSlashIndex);
subKey = path.substring(firstSlashIndex + 1); // Get the remaining part after the first
slash
} else {
Serial.println("No further sub-path found after reception.");
return; // No further processing if the path structure is invalid
}

Serial.println("Integer Part: " + integerPart); // Debugging


Serial.println("SubKey: " + subKey); // Debugging

// Check if the subKey starts with 'A' (indicating a GPIO key or state key)
if (subKey.startsWith("A")) {

37
DrmzTech System Innovations Pvt. Ltd.

Serial.println("SubKey starts with A."); // Debugging

// Handle the state (stateAX) for the GPIO key (AX)


if (subKey.startsWith("A")) {
int gpioNum = subKey.charAt(1) - '0'; // Extract the GPIO number from "A0" to
"A9"
if (gpioNum >= 0 && gpioNum <= 9) {
Serial.println("GPIO Key: A" + String(gpioNum)); // Debugging

// Check if the incoming data type is integer and matches the GPIO state
if (data.dataTypeEnum() == fb_esp_rtdb_data_type_integer) {
int state = data.intData(); // Get the state (0 or 1)
Serial.println("State for A" + String(gpioNum) + ": " + String(state)); //
Debugging

// Map GPIO number (A0 to A9) to alphabet (a to h)


char gpioChar = 'a' + gpioNum; // Maps A0 to 'a', A1 to 'b', ..., A9 to 'j'

// Convert to uppercase if the state is 1 (GPIO ON)


if (state == 1) {
gpioChar = toupper(gpioChar); // Convert the character to uppercase
}

// Output the formatted message


Serial.printf("$FE80,0012,4b00,2779,9797,M1,%c?\n", gpioChar);
} else {
Serial.println("Data type is not integer."); // Debugging
}
} else {
Serial.println("Invalid GPIO number."); // Debugging
}

38
DrmzTech System Innovations Pvt. Ltd.

} else {
Serial.println("Handling GPIO key: " + subKey); // Debugging
}
} else {
Serial.println("SubKey does not start with A."); // Debugging
}
} else {
Serial.println("Path is not within the reception structure."); // Debugging
}
}

// Timeout callback for stream


void streamTimeoutCallback(bool timeout) {
if (!stream.httpConnected()) {
Serial.println("Stream connection lost, retrying...");
delay(1000);
}
}

void setup() {
Serial.begin(4800); // Initialize serial at 4800 baud rate
initWiFi(); // Initialize Wi-Fi

// Firebase config
config.api_key = API_KEY;
config.database_url = DATABASE_URL;
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;

39
DrmzTech System Innovations Pvt. Ltd.

// Token status callback


config.token_status_callback = tokenStatusCallback;
Firebase.reconnectWiFi(true);

// Begin Firebase with auth


Firebase.begin(&config, &auth);

// Check Firebase authentication status

// Start streaming data from Firebase RTDB


if (!Firebase.RTDB.beginStream(&stream, listenerPath)) {
Serial.println("Failed to start Firebase stream: " + stream.errorReason());
} else {
Serial.println("Stream started successfully.");
}

Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);


}

void loop() {
checkWiFiConnection(); // Ensure Wi-Fi connection
handleSerialInput(); // Handle incoming serial input
delay(100); // Add a small delay to avoid overwhelming the loop
}
12.2 Gateway code to read serials
.c file
#include "morey_os.h"
#include "Serial.h"

40
DrmzTech System Innovations Pvt. Ltd.

void setup(void)
{
Serial.begin(4800,SERIAL_8N1);
Serial1.begin(4800,SERIAL_8N1);
Serial2.begin(4800,SERIAL_8N1);
Serial3.begin(4800,SERIAL_8N1);

TASK_CREATE(serial_copy0,"Serial copy021");
TASK_AUTOSTART(&serial_copy0);
TASK_RUN(serial_copy0)
{

BEGIN();

while(1)
{
Serial.println("Serial_0");

if(Serial.available()>0){
Serial1.println("Serial_0");
}
DELAY_SEC(1);

}
END();
}
Config file
#ifndef CONFIG_H

41
DrmzTech System Innovations Pvt. Ltd.

#define CONFIG_H

#define COMPILER AVR_GCC

#define SERIAL_ENABLE
#define SERIAL1_ENABLE
#define SERIAL2_ENABLE
#define SERIAL3_ENABLE

#endif
Makefile code
PROJECT = test_gateway_march7
MOREY_OS_PATH = ../..

ARCH = AVR_MEGA
CONTROLLER = MEGA2560
include $(MOREY_OS_PATH)/Makefile.include

12.3 Robotic Arm code


#define S_RXD 18 // Receive pin
#define S_TXD 19 // Transmit pin

#include <SCServo.h>

SCSCL sc; // SC servo instance


SMS_STS sms_sts; // ST servo instance

void setup() {
Serial.begin(115200); // Debug communication
Serial1.begin(1000000, SERIAL_8N1, S_RXD, S_TXD); // Servo communication

42
DrmzTech System Innovations Pvt. Ltd.

sms_sts.pSerial = &Serial1; // Assign Serial1 to the ST servo


sc.pSerial = &Serial1; // Assign Serial1 to the SC servo

delay(1000);
Serial.println("Enter command in the format: {ID,Degree,Speed}");
}

int degreeToPosition(int id, float degree) {


switch (id) {
case 1:
return constrain((4000 / 350.0) * degree, 0, 4000);
case 2:
return constrain(970 - ((970 - 600) / 90.0) * degree, 240, 970);
case 3:
return constrain((4.33 * degree) + 40, 40, 650);
case 4:
return constrain(100 + (3.33 * degree), 100, 700);
case 5:
return constrain((3.28 * degree) - 15.2, 0, 700);
case 6:
return constrain(1020 - (18.67 * degree), 420, 1023);
default:
return -1;
}
}

bool isValidMove(int id, int position) {


if (id == 1 && (position < 0 || position > 4000)) return false;
if (id == 2 && (position < 250 || position > 970)) return false;

43
DrmzTech System Innovations Pvt. Ltd.

if (id == 3 && (position < 10 || position > 650)) return false;


if (id == 4 && (position < 100 || position > 700)) return false;
if (id == 5 && (position < 0 || position > 700)) return false;
if (id == 6 && (position < 420 || position > 1023)) return false;

int posID3 = sc.ReadPos(3);


int posID4 = sc.ReadPos(4);

if (id == 2) {
if (position >= 820 && position <= 970) {
if (posID4 < 400) return true; // id4 should be initially < 400 for id2 movement in this
range
return false; // If id4 is not < 400 initially, restrict movement
}

if (position < 840 && position >= 740 && !((posID3 > 70 && posID4 < 420) || (posID3 >
300))) return false;
if (position < 740 && position >= 600 && !((posID3 > 130 && posID4 < 420) || (posID3
> 300))) return false;

if (position < 600 && position >= 400 && !(posID3 > 450)) return false;
if (position < 400 && position >= 230 && !((posID3 > 350) || (posID3 > 680 && posID4
== 220))) return false;
}

// --- ID 3 Rules ---


if (id == 3) {
if (position < 100 && posID4 > 430) {
if (sc.ReadPos(2) >= 800) return false; // Only restrict if id2 >= 800
}
}

44
DrmzTech System Innovations Pvt. Ltd.

// --- ID 4 Rules ---


if (id == 4) {

if (position > 400 && posID3 <= 100) {


if (sc.ReadPos(2) >= 800) return false; // Only restrict if id2 >= 800
}
if (position > 550 && posID3 < 100) {
if (sc.ReadPos(2) >= 800) return false; // Only restrict if id2 >= 800
}

return true;
}

void loop() {
if (Serial.available()) {
String input = Serial.readStringUntil('\n');
input.trim();

if (input.startsWith("{") && input.endsWith("}")) {


input = input.substring(1, input.length() - 1);

int id, speed;


float degree;

if (sscanf(input.c_str(), "%d,%f,%d", &id, &degree, &speed) == 3) {


speed = constrain(speed, 1, 700);

int position = degreeToPosition(id, degree);

45
DrmzTech System Innovations Pvt. Ltd.

if (position == -1) {
Serial.println("Invalid servo ID. Use IDs between 1 and 6.");
return;
}

if (!isValidMove(id, position)) {
Serial.println("Invalid move. Condition not met.");
return;
}

int acc = 500; // Fixed acceleration

Serial.print("Moving Servo ID ");


Serial.print(id);
Serial.print(" to position ");
Serial.print(position);
Serial.print(" at speed ");
Serial.println(speed);

if (id == 1) {
sms_sts.WritePosEx(id, position, speed, acc);
} else {
sc.WritePosEx(id, position, speed, acc);
}

delay(500);

int currentPos = (id == 1) ? sms_sts.ReadPos(id) : sc.ReadPos(id);


if (currentPos != -1) {
Serial.print("Servo ID ");

46
DrmzTech System Innovations Pvt. Ltd.

Serial.print(id);
Serial.print(" New Position: ");
Serial.println(currentPos);
} else {
Serial.print("Servo ID ");
Serial.print(id);
Serial.println(": Read Position Error");
}
} else {
Serial.println("Invalid input format. Use {ID,Degree,Speed}");
}
} else {
Serial.println("Invalid format. Use {ID,Degree,Speed}");
}
}
}

12.4 Lora Module code


Transmitter Code
#include <SPI.h>
#include <LoRa.h>

int counter = 0;

void setup() {
Serial.begin(9600);
while (!Serial);

Serial.println("LoRa Sender");

47
DrmzTech System Innovations Pvt. Ltd.

// Initialize LoRa at 433 MHz


if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}

LoRa.setTxPower(20); // Max power


}

void loop() {
Serial.print("Sending packet: ");
Serial.println(counter);

// Begin LoRa packet


LoRa.beginPacket();
LoRa.print("hello ");
LoRa.print(counter);
LoRa.endPacket();

counter++;
delay(5000); // Wait 5 seconds before sending next packet
}

Receiver Code
#include <SPI.h>
#include <LoRa.h>

void setup() {
Serial.begin(9600);
while (!Serial);

48
DrmzTech System Innovations Pvt. Ltd.

Serial.println("LoRa Receiver");

// Initialize LoRa at 433 MHz


if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}

void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet: ");

// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI (signal strength)
Serial.print(" with RSSI ");
Serial.println(LoRa.packetRssi());
}
}

49
DrmzTech System Innovations Pvt. Ltd.

50

You might also like