Arduino Mega 1280 Library for Proteus V3.0

Hello friends! I hope you are doing great. Today, we are discussing the latest version of the Arduino Mega 1280 library for Proteus. This can be used in both versions (Proteus 7 and Proteus. We have shared the previous versions, which are the Arduino Mega 1280 library for Proteus and the Arduino Mega 1280 library for Proteus V2.0 with you. With the advancement in the version, these microcontrollers have a better structure and the design is closer to the real microcontrollers. 

In this article, I will discuss the introduction of the Arduino Mega 1280 in detail. Here, you will learn the features and functions of this microcontroller. Then, we’ll see how to download and install this library in Proteus. In the end, we’ll see a mini project using the Arduino Mega 1280 V3.0. Let’s move towards our first topic:

Where To Buy?
No.ComponentsDistributorLink To Buy
1Battery 12VAmazonBuy Now
2ResistorAmazonBuy Now
3LCD 20x4AmazonBuy Now

Introduction to the Arduino Mega 1280 V3.0

  • The Arduino Mega is a microcontroller board that is based on the ATmega 1280. It has a large structure and provides more I/O pins.
  • It has the following memory features:
  • 128KB of flash memory to store the programs in it.
  • 8KB of SRAM for dynamic memory allocation
  • 4KB of EEPROM for data storage
  • It has 54 digital pins, of which 14 are used as PWM outputs.
  • It has 16 analogue input pins
  • This microcontroller uses the ATmega16U2 microcontroller for USB-to-serial conversion
  • It has compatibility with Arduino IDE where it is programmed with C++ just like other Arduino boards.
  • One must know that the Arduino Mega 1280 V3.0 is an open-source microcontroller and it is a robust platform for building and experiencing a vast range of electronic projects.

Now, let’s see the Arduino Mega 1280 library V3.0 in Porteus. 

Arduino Mega 1280 V3.0 Library for Proteus

The download and installation process for Arduino Mega 1280 is easy. The Proteus software does not have this library by default. To use it, the first step is to download it from the link given below:

Arduino Mega 1280 V3.0 for Proteus

Adding Proteus Library File

  • The downloading does not take much time. Once it is complete, it can be seen in the download folder on your system.

  • You will see a zip file when it is extracted to a particular path of your choice. 

  • There are two files in the folder named:

    • ArduinoMega3TEP.IDX

    • ArduinoMega3TEP.LIB

  • Copy these files and paste them into the folder with the following path:
    C>Program files>Lab centre electronics>Proteus 7 Professional>Library

Note: The same process is applicable to Proteus 8 professional if you are using that.

Arduino Mega 2560 Library V3.0 in Proteus

  • If all the above steps are completed successfully, the Proteus has to start/restart so that it may load all the files.
  • The Arduino Mega 1280 V3.0 is present in the libraries so click on the “P” button at the left side of the screen to pick it from the libraries. It will open a search box in front of you.
  • Type “Arduino Mega 1280” there and you will see the following options in front of you:

  • Double-click on its name to pick it.
  • Now, click on the picked Arduino Mega and place it on the working area to see its structure:

You can see it has many pins and the structure and design are closer to the real Arduino Mega. There is no link to the website on this microcontroller and it has more details about the pins on it. These points are different from the previous versions. 

Arduino Mega 1280 V3.0 Simulation in Proteus

The Arduino Mega 1280 has many features and it is used in a great number of projects. But, as a beginner, we’ll check the work with the help of a simple project. In this project, we’ll use the LED with Arduino Mega 1280 V3.0 and print the message of our own choice. Follow the steps to perform this example:

  • Go to the pick library once again and write “LCD 20X4 TEP” there. Pick it to use it.
  • Similarly, pick the potentiometer by searching “POT-HG” in the search box.
  • Now, get the “Button” from the same search box.
  • Place the components of the project in the working area by following the pattern given here:

Go to the terminal mode from the left side of the screen, and then choose the default pins for the clean circuit. 

Set and label the pins according to the image given here:

The circuit is fine but it can’t be run without coding.

Code for Arduino Mega 1280 V3.0

  • Fire up your Arduino IDE.

  • Create a new sketch for this project. 

  • The upper side has a drop-down menu, choose Arduino from there. 

  • Delete the default code. 

  • Paste the following code into it:

#include

//Setting the LCD pins

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

const int buttonPin = 0;

boolean lastButtonState = LOW;

boolean displayMessage = false;


void setup() {

  pinMode(buttonPin, INPUT);

  //Printing the first message

  lcd.begin(20, 4);

  lcd.setCursor(1, 0);

  lcd.print("Press the button to see the message");

}


void loop() {

  int buttonState = digitalRead(buttonPin);

// Using if loop to create the condition

  if (buttonState != lastButtonState) {

    lastButtonState = buttonState;


    if (buttonState == LOW) {

      displayMessage = true;

      lcd.clear();

      lcd.setCursor(1, 0);

      //Printing the message on screen when buttin is pressed

      lcd.print("www.TheEngineering");

      lcd.setCursor(4, 1);

      lcd.print("Projects.com");

    } else {

      displayMessage = false;

      lcd.clear();

      lcd.setCursor(1, 0);

      lcd.print("Press the button to see the message");

    }

  }

}

  • The same code is also present in the zip file of the Arduino Mega 1280 V3.0 library folder you have downloaded. 

  • Click on the tick mark to run the code. It will take some moments to be loaded.

  • Once the loading is complete, click on the upload button to get the hex file address.

  • In the loading process, you have to search for the path to the hex file. In my case, it looks like the following image:

Add the Hex File in Proteus

  • Go to the proteus where we have created our project.

  • Double-click on the Arduino Mega 1280 V3.0 module.  It will open its properties panel in front of you. 

  • Paste the address of the hex file into the section named “Program File.".

  • Hit the “OK” button and close the window.

Arduino Mega 1280 V3.0 Simulation Results

  • There are some buttons at the bottom left corner of the screen. Out of these, you have to click the play button to run the project. 

  • If all the above procedures are completed successfully, you will see the output on the screen. 

  • When the button is opened, the LCD shows the message that you have to push the button to see the message.

  • Click on the button, and now you can see the message on the LCD. 

If all the above steps are completed successfully, you will see that you have used the Arduino Mega 1280 V3.0 to show the required message on the LCD. This microcontroller can be used in different complex projects and can provide the basic working according to the code. Now, you can try different projects on your Proteus. I hope you have installed the microcontroller successfully. Yet, if you are stuck at any point, you can ask in the comment section.

Interface PCF8591 ADC/DAC Analog Digital Converter Module with Raspberry Pi 4

Welcome back to another Python tutorial for the Raspberry Pi 4! The previous tutorial showed us how to construct a Raspberry Pi-powered cell phone with a microphone and speaker for making and receiving calls and reading text messages (SMS). To make our Raspberry Pi 4 into a fully functional smartphone, we built software in Python. As we monitored text and phone calls being sent and received between the raspberry pi and our mobile phone, we experienced no technical difficulties. But in this tutorial, you'll learn how to hook up the PCF8591 ADC/DAC module to a Raspberry Pi 4.

Since most sensors only output their data in analog values, converting them to binary values that a microcontroller can understand is a crucial part of any integrated electronics project. A microcontroller's ability to process analog data necessitates using an analog-to-digital converter.

Some microcontrollers, including the Arduino, MSP430, and PIC16F877A, contain an onboard analog-to-digital converter (ADC), whereas others, like the 8051 and Raspberry Pi, do not.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Jumper WiresAmazonBuy Now
2PCF8591AmazonBuy Now
3Raspberry Pi 4AmazonBuy Now

Required Components

  1. Raspberry-pi 4

  2. PCF8591 ADC Module

  3. 100K Pot

  4. Jumper wires

You are expected to have a Raspberry Pi 4 with the most recent version of Raspbian OS installed on it, and that you are familiar with using a terminal program like putty to connect to the Pi via the Internet and access its file system remotely. Those unfamiliar with Raspberry Pi can learn the basics by reading the articles below.

PCF8591 ADC/DAC Module

Each of the ten pins on the PCF8591 module may read analog values as high as 256 on the PCF8591's digital side or vice versa. The board has a thermistor and LDR circuit. Input and output from this module are both analogs. To facilitate the I2C protocol, it has a dedicated serial clock and serial data address pins. The supply voltage ranges from 2.5 to 6V, and the stand-by current is minimal. We can further turn the module's potentiometer knob to control the input voltage. A total of three jumpers can be found on the board. Switching between the thermistor, LDR/photoresistor, and adjustable voltage access circuits is possible by connecting J4, J5, and J6. D1 and D2 are two LEDs on the board, with D1 displaying the strength of the output voltage and D2 indicating the power of the supply voltage. When the supply or output voltage is increased, the brightness of LEDs D1 and D2 are correspondingly enhanced. Potentiometers connected to the LEDs' VCC or AOUT pins also allow testing.

Microprocessors, Arduinos, Raspberry Pis, and other digital logic circuits can interact with the physical environment thanks to Analogue-to-Digital Converters (ADCs). Many digital systems gather information about their settings by analyzing the analog signals produced by transducers such as microphones, light detectors, thermometers, and accelerometers. These signals constantly vary in value since they are derived from the physical world.

Digital circuits use binary signals, which can only be in one of two states, "1" (HIGH) or "0" (LOW), as opposed to the infinitely variable voltage values provided by analog signals (LOW). Therefore, Analogue-to-Digital Converters (A/D) is an essential electronic circuit for translating between constantly varying analog impulses and discrete digital signals.

To put it simply, an analog-to-digital converter (ADC) is a device that, given a single instantaneous reading of an analog voltage, generates a unique digital output code that stands in for that reading. The precision of an A/D converter determines how many binary digits, or bits, are utilized to represent the original analog voltage value.

Analogue and Digital Signals

By rotating the potentiometer's wiper terminal between 0 and VMAX, we may see a continuous output signal with an endless set of output values related to the wiper position. In a potentiometer, the output voltage constantly varies while the wiper is moved between fixed positions. Variations in temperature, pressure, liquid levels, and brightness are all examples of analog signals.

A digital circuit uses a single rotary switch to control the potential divider network, taking the place of the potentiometer's wiper at each node. The output voltage, VOUT, rapidly transitions from one node to the next as the switch is turned, with each node's value representing a multiple of 1.0 volts.

The output is guaranteed at 2-volt, 3-volt, 5 volts, etc., but NOT a 2.5-volt, 3.1-volt, or 4.6-volt output. Using a multi-position switch and more resistive components in the voltage-divider network, resulting in more discrete switching steps, would allow for generating finer output voltage levels.

By this definition, we can see that a digital signal has discrete (step-by-step) values, while an analog signal's values change continuously over time. We are going from "LOW" to "HIGH" or "HIGH" to "LOW."

So the question becomes how to transform an infinitely variable signal into one with discrete values or steps that a digital circuit can work with.

Converting from Analog to Digital

Although several commercially available analog-to-digital converter (ADC) chips exist, such as the ADC08xx family, for converting analog voltage signals to their digital equivalents, a primary ADC can be constructed out of discrete components.

Using comparators to detect various voltage levels and output their switching signal state to an encoder is a straightforward method known as parallel encoding, flash encoding, simultaneous encoding, or multiple comparator converters.

The equivalence output script for a given n-bit resolution is formed by a chain network of accuracy resistors and a series of comparators that are connected but equally spaced.

As soon as an analog signal is provided to the comparator input, it is evaluated with a reference voltage, making parallel converters advantageous because of their ease of construction and lack of need for timing clocks. The following comparator circuit may be of interest.

A Logic Comparator

The LM339N is an analog comparator that compares the relative magnitudes of two voltage levels via its two analog inputs (one positive and one negative).

The comparator receives two signals, one representing the input voltage (VIN) and the other representing the reference value (VREF). The comparator's digital circuits state, "1" or "0," is determined by comparing two output voltages at the input of the comparator.

One input (VREF) receives a reference voltage, and the other input (VIN) receives the input voltage to be compared to it. Output is "OFF" by an LM339 comparator when the input power is lower than (VIN VREF) and "ON" when the input power is higher than the standard voltage (VIN > VREF). A comparator is a device to determine which of two voltages is greater.

Using the potential divider network established by R1 and R2, we can calculate VREF. If the two resistors are identical in value (R1 = R2), then the reference voltage will be half the input power (V/2). Therefore, like with a 1-bit ADC, the output of an open-collector comparator is HIGH if VIN is lower than V/2 and LOW otherwise.

However, by increasing the number of resistors in the voltage divider circuit, we can "divide" the voltage source by an amount equal to the ratio of the resistors' resistances. However, the number of comparators needed increases with the number of resistors in the voltage-divider network.

For an "n"-bit binary output, where "n" is commonly between 8 and 16 bits, a 2n- 1 comparator would be needed in general. As we saw previously, the comparator utilized by the one-bit ADC to determine whether or not VIN was more significant than the V/2 voltage output was 21 minus 1, which equals 1.

If we want to build a 2-bit ADC, we'll need 22-1 or "3" comparators since the 4-to-2-bit encoder circuitry depicted above requires four distinct voltage levels to represent the four digital values.

Circuit for 2-bit A/D Conversion

For each of the four potential values of the analog input of:

A/D Conversion Output, 2-Bit

Where X is a "don't care" statement, representing a logical 0 or 1.

Explain how this analog-to-digital device operates. An analog-to-digital converter (A/D) must generate a faithful digital copy of the Analog input signal to be of any value. To keep things straightforward, we've assumed that VIN is somewhere between 0 and 4 volts and have adjusted VREF and the voltage divider network so that there is a 1 V drop between each resistor in this simple 2-bit Analog - to - digital example.

A binary zero (00) is output by the encoder on pins Q0 and Q1 when the input voltage, VIN, is less than the reference voltage level, which occurs when VIN is between 0 and 1 volts (1V). Since comparator U1's reference voltage input is set to 1 volt, when VIN rises above 1 volt but is below 2 volts, U1's HIGH output is triggered. When the input changes at D1, the priority encoder, used for the 4-to-2-bit encoding, generates a binary result of "1." (01).

Remember that the inputs of a Priority Encoder, like the TTL 74LS148, are all assigned different priority levels. The highest priority input is always used as the output of the priority encoder. So, when a higher priority input is available, lesser priority inputs are disregarded. Therefore, if there are many inputs simultaneously at logic state "1", only the input with high priority will have its output code reflected on D0 and D1.

Thus, now that VIN is greater than 2 volts—the next reference voltage level—comparator U2 will sense the difference and output HIGH. However, when VIN is more than 3 volts, the priority encoder will output a binary "3" (11), as input D2 has a high priority than inputs D0 and D1. Each comparator outputs a HIGH or LOW state to the encoder, generating 2-bit binary data between 00 and 11 as VIN decreases or changes between every reference voltage level.

This is great and all, but commercially available priority encoders, like the TTL, are 8-bit circuits, and if we use one of these, six of the binary numbers will go unused. A digital Ex-OR gate and a grid of signaling diodes can create a straightforward encoder circuit.

Diode-based 2-bit ADC

Before feeding the diodes, the results of the comparators go through an Exclusive-OR gate to be encoded. Whenever the diode is reverse biased, an external pull-down resistor is connected between the diodes' outputs and ground (0V) to maintain a LOW state and prevent the outputs from floating.

Also, as with the main board, the value of VIN controls which comparator sends a HIGH (or LOW) signal to the exclusive-OR gates, which provide a HIGH output if either of the inputs is HIGH but not both (the corresponding Boolean is Q = A.B + A.B). The AND-OR-NAND gates of combinational logic could also be used to build these Ex-OR gates.

The difficulty with both of these 4-to-2 converter designs is that the input analog voltage at VIN needs to vary by one full volt for the encoder to vary its output code, limiting the precision of the simple two-bit A/D converter to 1 volt. The output resolution can be improved by employing more comparators to convert to a three-bit A/D converter.

D/A Converter, 3-Bit

The aforementioned parallel ADC takes a voltage reading between 0 and over 3 volts as an analog input and turns it into a binary code with only 2 bits. Since there are 23 = 8 possible digital outputs from a 3-bit digital circuits system, the input analog voltage can be compared to a scale of eight voltages, each of which is one-eighth (1/8) of the voltage supply. This means that we can now measure to an accuracy of 0.5 (4/8) volts and that 23-1 comparators are needed to generate a binary code with a 3-bit resolution (from 000 (0) to 111 (7)).

Circuit for 3-bit Analog-to-Digital Conversion

This will provide us with a three-bit code for each of the eight potential values of the analog input of:

The result of a Three-Bit Analog-to-Digital Converter

An "X" may be a logic 0 or a logic 1 to indicate a "don't care" state.

Then we can see that more comparators and power levels are required and more output binary bits when the ADC's resolution is increased.

Therefore, an analog-to-digital converter with a 4-bit resolution needs only 15 (24-1) comparators. An eight-bit resolution requires 255 (28-1) comparators. A 10-bit resolution needs 1023 comparators, etc. Therefore, the complexity of this type of Analog-to-Digital Converter circuit increases as the number of output bits increases.

Only if a few binary bits are needed to make a read on a display unit to represent the reference voltage of an input analog signal can a parallel or flashed A/D converter quickly be developed as part of a project due to its fast real-time conversion rate.

As an input interface circuit component, an analog signal from sensors or transducers is converted into a digital binary code by an analog-to-digital converter. Similarly, a digital binary code can be converted into a comparable analog quantity using a Digital-to-Analog Conversion for output interfacing to operate a motor or actuator or, more often, in audio applications.

Raspberry Pi's I2C pins

Knowing the Raspberry Pi's I2C port pins and setting up the I2C connection in the pi 4 are the initial steps in using a PCF8591 with the Pi.

GPIO2 and GPIO3 on the Rpi Model are utilized for I2C communication in this guide.

Raspberry Pi I2C Configuration

Raspberry Pi lacks I2C support by default. Therefore, it must be activated before anything else. Turn on Raspberry Pi's I2C port.

  1. First, open a terminal and enter sudo raspi-config.

  2. The RPi 4 Software Configuration Tool has opened.

  3. Third, activate the I2C by selecting Interfacing options.

    1. Restart the Pi after enabling I2C.

    Reading the PCF8591's I2C Address with a Raspberry Pi

    The Raspberry Pi has to know the I2C address of the PCF8591 IC before communication can begin. You may get the address by linking the PCF8591's SDA and SCL pins to the Raspberry Pi's own SDA and SCL jacks. The 5-volts and GND pins should be connected as well.

    You may find the address of an attached I2C device by opening a terminal and entering the following command.

    sudo i2cdetect –y 1 or sudo i2cdetect –y 0

    After locating the I2C address, the next step is constructing the circuit and setting up the required libraries to use PCF8591 and a Raspberry Pi 4.

    Connecting the PCF8591 ADC/DAC Module to the Raspberry Pi 4

    The circuit diagram to interface the PCF8591 with the Raspberry Pi is straightforward. In this example of interfacing, we'll read the analog signal from any analog inputs and display them in the Raspberry Pi terminal. We have a 100K pot to adjust the settings.

    Pi's GPIO2 and GPIO must be connected to the power supply and ground. Then, hook up GPIO3 and GPIO5 to SDA and SCL, respectively. Last but not least, link AIN0 to a 100K pot. Instead of using the Terminal to view the ADC values, a 16x2 LCD can be added.

    The A/D Conversion Python Program

    The complete code and demo video are included after this guide.

    To communicate with the I2C bus, you must first import the SMBus library and then use the time library to specify how long to wait before outputting the value.

    import smbus

    import time

    Create some variables now. The I2C bus address is stored in the first variable, and the first analog input pin's address is stored in the second variable.

    address = 0x48

    A0 = 0x40

    Next, we've invoked the library smbus's SMBus(1) function to create an object.

    bus = smbus.SMBus(1)

    The first line in the while instructs IC to take a reading from the first analog signal pin. Address information read from an Analog pin is saved as a numeric variable in the second line. Exit with the value printed.

    While True:

        bus.write_byte(address,A0)

        value = bus.read_byte(address)

        print(value)

        time.sleep(0.1)

    Finally, put the Python script in a file ending in.py and run it in the Raspberry Pi terminal with the command below.

    python filename.py

    Ensure that the I2C communication is turned on and that the pins are linked according to the diagram before running the code, or else you will get errors. It's time for the analog readings to appear in the terminal format below. The values gradually shift as you turn the pot's knob. Find out more about getting the software to work in

    Here is the full Python script.

    import smbus

    import time

    address = 0x48

    bus = smbus.SMBus(1)

    while True:

        bus.write_byte(address,A0)

        value = bus.read_byte(address)

        print(value)

        time.sleep(0.1)

    ADC's Practical Uses

    We rely heavily on electronic gadgets in today's high-tech society. The digital signal is the driving force behind these digital devices. While most numbers are represented digitally, few still use analog notation. Thus, an ADC is employed to transform analog impulses into digital ones. ADC can be used in an infinite variety of contexts. Here are only a few examples of their use:

    • The digitized voice signal is used by cell phones. The voice is first transformed to digital form using an ADC before being sent to the cell phone's transmitter.

    • Digital photos and movies shot with a camera can be viewed on any computer or mobile device thanks to an analog-to-digital converter.

    • X-rays and MRIs are just two examples of medical imaging techniques that use ADC to go from Analog to digital before further processing. Then, they're adjusted so that everyone can follow along.

    • ADC converters can also transfer music from a cassette tape to a digital format, such as a CD or a USB flash drive.

    • The Analog-to-Digital Converter (ADC) in a digital oscilloscope converts analog signals to digital ones that can then be displayed and used for other reasons.

    • The air conditioner's built-in temperature sensors allow for consistent comfort levels. The onboard controller reads the temperature and makes adjustments based on the data it receives from the ADC.

    Nowadays, practically everything has a digital counterpart, so every gadget must also include an ADC. For the simple reason that its operations require a digital domain accessible only via an analog-to-digital converter (ADC).

    Conclusion

    This piece taught us how to connect a Raspberry Pi 4 to a PCF8591 Analogue - to - digital decoder module. We have observed the output being shown as integers on our Terminal. We have also researched how the ADC generates its output signals. Here we will use OpenCV and a Raspberry Pi 4 to create a social distance detector.

    Sending SMS & Call with GSM Module and Raspberry Pi 4

    Greetings, and welcome to another tutorial in our series on the raspberry pi 4 Python programming. The previous guide covered the basics of transmitting data over the radio using the nrf24l01 chip in Pi 4. We also learned about interfacing Arduino and raspberry pi 4 and sending radio signals between the two devices. However, this tutorial will walk you through building a Raspberry Pi-based mobile phone with a microphone and speaker for making and receiving calls and reading text messages (SMS). This Project also serves as a proper GSM Module for the Raspberry Pi interface, with all the necessary Code to run the most fundamental features of any modern smartphone. First, we will understand what gsm is, its architecture and how it works, then we will learn how to program it in our pi 4; therefore, let us begin.

    Where To Buy?
    No.ComponentsDistributorLink To Buy
    1Jumper WiresAmazonBuy Now
    2LCD 16x2AmazonBuy Now
    3Raspberry Pi 4AmazonBuy Now

    Components:

    • Raspberry Pi 4

    • GSM Module

    • 16x2 LCD

    • 4 *4 Keypad

    • 10k pot

    • Breadboard

    • Connecting jumper wire

    • Power supply

    • Speaker

    • Microphone

    • SIM Card

    • Loudspeaker

    Structure and Uses of the Global System for Mobile Communications

    The acronym "GSM" refers to the "global system for mobile communication" and is the name of a type of mobile communication modem (GSM). Bell Labs was responsible for conceptualizing GSM in the 1970s. It's one of the most common forms of mobile communication around the globe. The 850MegaHertz, 900MegaHertz, 1800 Megahertz, and 1900 Megahertz frequency bands are utilized by GSM networks, which are part of an open and digital mobile network used to carry voice and data services.

    Using the telecommunications method of multiple time division access (TDMA), GSM technology was created as a digital system. For transmission, a GSM converts analog signals to digital ones, compresses them further and delivers them through a channel sharing bandwidth with two data streams from separate clients. The data rates transported by the digital system range from 64 kilobytes per second to 120 Megabytes per second.

    In a GSM network, macro, micro, and umbrella cells coexist. The implementation context determines the specifics of each cell. The macro, micro, and umbrella cell sizes are in use in a GSM network. Each cell may have a different range of coverage depending on the setting.

    Time-division multiple access (TDMA) works by giving each user a specific amount of time to transmit on the same frequency. It's flexible, supporting data rates from 64kbps to 120Mbps and allowing for clear voice communications.

    Structure of GSM-Based Technologies

    The following are the primary components of the GSM architecture.

    • Connectivity and Switching Infrastructure (NSS)

    • All three of these components—the Base Station (BS), the Mobile Station (MS), and the Operations and Maintenance Subsystem (OSS)—are necessary for proper communication (OSS)

    Network Switching Subsystem (NSS)

    Each component of the GSM system design contributes to what is collectively called the core system/network. In this case, the mobile network system is primarily controlled and interfaced with via a data network consisting of several different components. Listed below are some of the most crucial elements of the underlying network.

    Mobile Switching Centre (MSC)

    One of the essential parts of a GSM network is its core network, where the Mobile Switching Center (MSC) resides. This MSC performs the same functions as a common switching node in an ISDN or PSTN. Still, it provides additional features to accommodate mobile users' requirements, such as authentication, registration, inter-MSC handovers, call localization, and routing.

    In addition, it gives users an advantage in connecting their mobile phone networks to the PSTN (public switched telephone network) for making and receiving landline calls. To facilitate mobile-to-mobile calls across different networks, interfaces to all other switched telephone networks ( PSTN center servers are given.

    Home Location Register (HLR)

    Every subscriber's administrative details, including their last known location, are stored in this HLR database. This manner, calls can be routed over the GSM network to the appropriate mobile switch base station. If a call comes in when an operator has their phone turned on, the network can determine which base transmitter station the call is coming from and link it to the correct phone.

    When the phone is turned on but not being used, it nevertheless registers to ensure the HLR system is aware of its current location. Each network has a single HLR, which may be physically split across several data centers for practical reasons.

    Visitor Location Register (VLR)

    To facilitate the VLR's desired services for the individual subscriber, it incorporates data from the HLR network. It is possible to run the visitor coordinates register independently, but it is most commonly implemented as a core component of the MSC. Because of this, getting access is more manageable, and it takes less time overall.

    Equipment Identity Register (EIR)

    The Equipment Identity Register (EIR) is the part of the network infrastructure in charge of deciding whether or not certain pieces of mobile equipment are allowed access. The International Mobile Equipment Identification (IMEI) numbers uniquely identify each mobile technology work.

    This IMEI number is permanently embedded within the mobile device and checked by the network after registration. Depending on the data in the EIR, the mobile phone may be given one of three possible network access states: allowed, banned, or monitored.

    Authentication Centre (AuC)

    When users insert their SIM card into their phone, the secret key is stored in a secure file known as the AUC (authentication center). The AUC sees the extensive application as a radio channel coding and verification standard.

    Gateway Mobile Switching Centre (GMSC)

    In the absence of location information for the mobile station (MS), a call placed by a ME terminates with the GMSC (Gateway Mobile Switching Centre). Using the Mobile Subscriber Identifier Service Data Number (MSISDN) and the HLR, the GMSC can locate the specific MSC that has been visited and connect the call to the appropriate location. It's unclear what the "MSC" part of GMSC stands for, as the gateway procedure does not require relating to an MSC.

    SMS Gateway (SMS-G)

    Both SMS-Gateways are referred to collectively as the SMS gateway in the GSM specifications. The messages passing via these gateways are directed in various ways.

    Sending a short message to mobile equipment (ME) requires the usage of the Short Messaging Service Gateway Switching Center. Short messages sent over a mobile network are routed through the  SMS Inter-Working Switching Center. While the SMS-primary GMSC's function concerns the GMSC, the SMS-IWMSC serves as a constant endpoint for access to the Short Message Service Centre.

    These were the primary nodes in the GSM system's infrastructure. While they frequently shared physical space, the entire middle network would sometimes be broadcast throughout the country. In the event of a failure, it will provide a degree of leeway.

    Base Station Subsystem (BSS)

    The connection point between the mobile node and the broader network infrastructure. The radio transceivers and protocol management for mobile devices are housed in the Base Transceiver Station. In addition, a Base Station Controller manages the Base Transceiver and serves as a bridge between mobile devices and the mobile switching hub.

    The network subsystem handles connectivity between the network and the mobile stations. The Phone Service Switch Centre is the backbone of the Network Subsystem, allowing users to connect to other networks (ISDN, PSTN, etc.). The GSM system's ability to route calls and allow for roaming depends on two additional components, the Home Location Record and the guest Location Record.

    In addition, it stores the Equipment Identity Register, which keeps track of all the mobile devices and their associated IMEI numbers. The acronym IMEI refers to the unique identifier for mobile devices worldwide.

    In the second generation of GSM network design, the mobile devices communicate with the BSS, or Base Station Subsystem. These components comprise this subsystem, and each will be examined.

    Base Transceiver Station (BTS)

    As part of a GSM network, the radio Tx, Rx, and their associated antennas make up the base Transceiver Station, which is used for transmitting, receiving, and communicating directly through mobiles. The base station is the central component of each cell, and it communicates with mobile devices using an interface known as the Um interface and related protocols.

    Base Station Controller (BSC)

    The base station controller (BSC) is employed for the following step back into GSM technology. This controller is typically co-located within one of the base transceiver stations it controls. This controller handles radio resource management, including channel allocation and handover between base station groups. Over the Abis interface, it communicates with the BTSs.

    The acceptable radio technology is used by the GSM network's subsystems component in the ground station to ensure that multiple operators can utilize the system at the same time. Each base station can support many operators because each channel can support up to eight users.

    The network provider strategically places these to ensure comprehensive coverage. A base station, sometimes known as a "cell," can surround this space. Signals can't be prevented from bleeding into neighbouring cells, and the channels used in one don't transfer to the next.

    Mobile Station

    Mobile phones include a transceiver, a display, and a CPU, all of which are network-connected and operated using a SIM card. In a GSM mobile transmission medium, the operator monitors and controls the mobile station or mobile equipment, which are most commonly represented by cell phones. Their size has shrunk significantly while their functionality has skyrocketed. The benefit of a much longer interval between charges is still another advantage. Phone hardware and the subscriber identity module (SIM) are two of many components.

    A mobile device's hardware consists of its primary components, such as the housing, screen, battery, and electronics used to generate the signal and process the signal receiver before transmission. The IMEI is a unique number assigned to each mobile device. This feature can be permanently programmed into a phone throughout its manufacturing process. During the registration process, the network accesses this database to see if the device has been flagged as stolen.

    A user's identity on the network is stored in the information contained in their SIMcard. It also includes other data, such as the IMSI number. With this IMSI stored in the Sim, the phone user could easily switch phones by swapping SIM cards. As a result, if switching to a new mobile phone were simple and didn't require a unique phone number, more people would do it, generating more revenue for network operators and contributing to GSM's overall economic triumph.

    Operation and Support Subsystem (OSS)

    The OSS is an integral aspect of any functional GSM network. The NSS and BSC parts are linked here. The GSM network and BSS traffic load are the primary areas of focus for this OSS. It is worth noting that some preservation responsibilities are relocated to the base station controller to lower the maintenance expense of the system when the amount of BS increases through the consumer population growth.

    The 2G GSM network architecture is predicated on a rational functioning method. This approach is remarkably straightforward compared to today's mobile network architectures, which rely on software-defined units to facilitate highly adaptable operations. However, the 2G GSM architecture will show how the necessary voice and essential operational functions are organized. 

    Specifications of a GSM Module

    The following are some of the functions provided by the GSM module.

    • Enhanced spectrum efficiency

    • Features including "international roaming," "integrated services digital network" (ISDN) compatibility, and "support for future services" are also included.

    • High-quality voice communications; encrypted phone conversations;

    • Features like a programmable alarm clock, high-quality voice communication, a fixed calling number, a real-time clock, and the ability to send and receive SMS messages are all standard on modern smartphones (SMS)

    As a result of its rigorous security measures, the GSM system is currently the safest available for use in the telecommunications industry. Call privacy and subscriber anonymity for GSM users are only protected during transmission, but this is still a massive step toward attaining end-to-end security.

    GSM Modem

    In either its mobile phone or modem form, a Global System for Mobile Communications (GSM) modem enables two computers or processors to connect across a network. A SIM card is needed to run a GSM modem, and it can only be used within the coverage area the network provider has paid for. It has serial, USB, and Bluetooth connectivity options for linking to a personal computer.

    Any regular GSM cell phone can double as a GSM modem if you have a suitable cable and driver installed on your PC. It would be best if you used a GSM modem instead of a GSM cell phone. The GSM modem is helpful in many devices, including POS terminals, inventory management systems, surveillance cameras, weather stations, and GPRS-mode remote data loggers.

    GSM Module Operation

    Below is a circuit showing how to connect a GSM modem to the MC using the level-shifting IC Max232. When a numeric command is received by short message service (SMS) from any mobile device, the SIM card-mounted GSM modem transfers that information to the MC via serial connection. The GSM modem is programmed to respond to the order "STOP" by producing an MC output, the point which is utilized to deactivate the ignition switch.

    If the input is driven low, the GSM modem will send a predetermined message (in this case, "ALERT") to the user. A 162 LCD screen displays the entirety of the procedure.

    In-depth working Explanation of raspberry pi 4

    We have utilized a GSM module and a Raspberry Pi 4 to manage the entire system and interface its many parts in this Project. You can input data of any kind, including phone numbers, text messages, and phone calls, read and respond to text messages, and more, using a 4x4 alphanumeric keypad. The SIM900A GSM module connects mobile phones to wireless networks for making and receiving calls and sending and receiving text messages. We've integrated a microphone, a loudspeaker for making and receiving voice calls, and a 16 * 2 liquid crystal displays information like menu options and alarms.

    With alphanumeric input, you can use the same keyboard to type in both numbers and letters. For the Code we used to allow alphabets in addition to numbers in this method, scroll down to the "Code in Code" section.

    It's simple to put this plan into action. The alphanumeric keypad is used for all functions. Below you'll find a link to the complete Code and a demonstration video. This section will elaborate on the four aspects of the listed projects.

    The Pi 4 Mobile Phone Four Main Attributes

    Make Call

    The Pi 4 phone we built requires us to press the letter "C" and provide the cellphone number we wish to call. We'll use an alphanumeric keyboard to enter the number. Once the correct number has been entered, we must hit "C" again. The AT command is now processed by pi 4 to connect the call to a specified number.

    ATDxxxxxxxxxx; <Enter>     where xxxxxxxxx is entered Mobile Number.

    Receive Call

    Answering a phone call is simple. When a call comes into the SIM number stored in the GSM Module of your system, the LCD will display the message "Incoming..." along with the caller's number. All that's left to do is hit the 'A' key to answer the call. Pi 4 will send the following command to the GSM Module when the "A" button is pressed:

    ATA <enter>

    Transmit SMS

    Pressing "D" on our Raspberry Pi phone allows us to send a text message. To whom (or what) should we address the SMS message that the system has just requested? Once the number has been entered, pressing "D" again will prompt the LCD to request a message. To send an SMS, enter the message using the keypad as you would with any other mobile device, and then hit the 'D' key again. Raspberry Pi can send SMS with the following command:

    AT+CMGF=1 <enter>

    AT+CMGS=”xxxxxxxxxx” <enter>     where: xxxxxxxxxx is entered mobile number

    Receive and Read SMS

    Even this component is easy to use. Here, the SIM card is used to receive SMS messages from the GSM. The Raspberry Pi also keeps a close eye on the UART SMS signal. New notes are shown by the LCD displaying the text "New message," and reading them is as simple as pressing the "B" key. This is an SMS Received signal:

    +CMTI: "SM," 6  Where 6 is the message location where it is stored in the SIM card.

    When the RPi detects the 'SMS received' signal, it will get the SMS storage location and instruct the Global system for mobile to read the message. Moreover, the LCD will flash the words "New Message" in a prominent location.

    AT+CMGR=<SMS stored location><enter>

    The GSM now delivers the saved message to the Raspberry Pi, and the Pi, having extracted the primary SMS, shows it on the LCD. When it comes to MIC and Speaker, there is no secret code.

    Detailed Circuit Layout and Explanation

    The GPIO pins of the Raspberry Pi are wired to the RS, EN, D4, D5, D6, and D7 pins of the 16 * 2 liquid crystal display. A direct connection is made between the GSM module's Rx and Tx pins and the Raspberry Pi's Tx and Rx pins. Connectors R1, R2, R3, and R4 of a 4 * 4 keypad are connected to GPIOs 12, 16, 20, and 21, whereas pins C1, C2, C3, and C4 are connected to GPIOs 26, 19, 13, and 6. If you want to boost the audio volume from the GSM Module, you can join the microphone directly to the mic+ and mic- pins and the loudspeaker to the sp+ and sp- pins. The loudspeaker can be connected directly to the GSM module without using the Audio Amplifier circuit.

    Explanation of the Code

    This Pi 4 mobile phone's programming interface may be challenging to novices—the programming language of choice for this Project is Python.

    Here, we define the keypad() function to be used with a basic numeric keypad. We've also added a def alpha keypad(): for typing alphabets so that you may use the same keypad for both purposes. To make it compatible with the Arduino keypad library, we've given this keypad a wide range of new capabilities. This keypad only takes 10 presses to enter a whole string of text or a numeric value.

    For example, if we push key 2 (abc2) once, the LCD will display the letter 'a.' If we press it again, the letter 'b' will take its place, and if we hit it three more times, the letter 'c' will appear in the same spot. After holding down a key for a short time, the LCD pointer will advance to the following available location. We can now proceed to the next character or number. Any other keys can be processed in the same way.

    def keypad():

       for j in range(4):

         gpio.setup(COL[j], gpio.OUT)

         gpio.output(COL[j], 0)

         ch=0

         for i in range(4):

           if gpio.input(ROW[i])==0:

             ch=MATRIX[i][j]

             return ch

             while (gpio.input(ROW[i]) == 0):

               pass

         gpio.output(COL[j],1)

    def alphaKeypad():

        lcdclear()

        setCursor(x,y)

        lcdcmd(0x0f)

        msg=""

        while 1:

            key=0

            count=0

            key=keypad()

            if key == '1':

                ind=0

                maxInd=6

                Key='1'

                getChar(Key, ind, maxInd)

                .... .....

                ..... .....

    To begin, we have declared the pins for the liquid crystal display, the keypad, and other components, as well as included the necessary libraries in this python script:

    import RPi.GPIO as gpio

    import serial

    import time


    msg=""

    alpha="1!@.,:?ABC2DEF3GHI4JKL5MNO6PQRS7TUV8WXYZ90 *#"

    x=0

    y=0


    MATRIX = [

                ['1','2','3','A'],

                ['4','5','6','B'],

                ['7','8','9','C'],

                ['*','0','#','D']

             ]

    ROW = [21,20,16,12]

    COL = [26,19,13,6]

    ... .....

    ..... .....

    The pins need to be pointed in the proper direction.

    gpio.setwarnings(False)

    gpio.setmode(gpio.BCM)

    gpio.setup(RS, gpio.OUT)

    gpio.setup(EN, gpio.OUT)

    gpio.setup(D4, gpio.OUT)

    gpio.setup(D5, gpio.OUT)

    gpio.setup(D6, gpio.OUT)

    gpio.setup(D7, gpio.OUT)

    gpio.setup(led, gpio.OUT)

    gpio.setup(buz, gpio.OUT)

    gpio.setup(m11, gpio.OUT)

    gpio.setup(m12, gpio.OUT)

    gpio.setup(button, gpio.IN)

    gpio.output(led , 0)

    gpio.output(buz , 0)

    gpio.output(m11 , 0)

    gpio.output(m12 , 0)

    To begin Serial communication, follow the steps below.

    Serial = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=2)

    We must now create a liquid crystal display driving function. The def lcdcmd(ch): and def lcdwrite(ch): functions are used to deliver commands and data to the LCD, respectively. The liquid crystal display may also be cleared with def lcdclear(), the cursor position can be set with def setCursor(x,y), and a string can be sent to the liquid crystal display with def lcdprint(Str).

    def lcdcmd(ch): 

      gpio.output(RS, 0)

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x10==0x10:

        gpio.output(D4, 1)

        .... .....

        ..... ....

    def lcdwrite(ch): 

      gpio.output(RS, 1)

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x10==0x10:

        gpio.output(D4, 1)

      if ch&0x20==0x20:

        gpio.output(D5, 1)

        .... .....

        ..... ....

    def lcdclear():

      lcdcmd(0x01)

     

    def lcdprint(Str):

      l=0;

      l=len(Str)

      for i in range(l):

        lcdwrite(ord(Str[i]))

    def setCursor(x,y):

        if y == 0:

            n=128+x

        elif y == 1:

            n=192+x

        lcdcmd(n)

    Next, we'll need to code some features for interacting with text messages, phone calls, and incoming calls.

    The call is placed using the function def call():. Also, the LCD can display the receiving message and number via the function def receiveCall(data):. Finally, the call is answered with def attendCall():.

    The message is composed and sent using the alphaKeypad() method, accessed via the def sendSMS(): function. The SMS is received, and its location is retrieved using the def receive SMS(data) function. And finally, the LCD gets updated with the message thanks to def readSMS(index:).

    All of the operations mentioned above are included in the Code that follows.

    import RPi.GPIO as gpio

    import serial

    import time

    msg=""

    #     0      7   11  15  19  23  27   32  36   414244   ROLL45

    alpha="1!@.,:?ABC2DEF3GHI4JKL5MNO6PQRS7TUV8WXYZ90 *#"

    x=0

    y=0

    MATRIX = [

                ['1','2','3','A'],

                ['4','5','6','B'],

                ['7','8','9','C'],

                ['*','0','#','D']

             ]

    ROW = [21,20,16,12]

    COL = [26,19,13,6]

    moNum=['0','0','0','0','0','0','0','0','0','0']

    m11=17

    m12=27

    led=5

    buz=26

    button=19

    RS =18

    EN =23

    D4 =24

    D5 =25

    D6 =8

    D7 =7

    HIGH=1

    LOW=0

    gpio.setwarnings(False)

    gpio.setmode(gpio.BCM)

    gpio.setup(RS, gpio.OUT)

    gpio.setup(EN, gpio.OUT)

    gpio.setup(D4, gpio.OUT)

    gpio.setup(D5, gpio.OUT)

    gpio.setup(D6, gpio.OUT)

    gpio.setup(D7, gpio.OUT)

    gpio.setup(led, gpio.OUT)

    gpio.setup(buz, gpio.OUT)

    gpio.setup(m11, gpio.OUT)

    gpio.setup(m12, gpio.OUT)

    gpio.setup(button, gpio.IN)

    gpio.output(led , 0)

    gpio.output(buz , 0)

    gpio.output(m11 , 0)

    gpio.output(m12 , 0)

    for j in range(4):

        gpio.setup(COL[j], gpio.OUT)

        gpio.setup(COL[j],1)

    for i in range (4):

        gpio.setup(ROW[i],gpio.IN,pull_up_down=gpio.PUD_UP)

    Serial = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=2)

     

    data=""

    def begin():

      lcdcmd(0x33) 

      lcdcmd(0x32) 

      lcdcmd(0x06)

      lcdcmd(0x0C) 

      lcdcmd(0x28) 

      lcdcmd(0x01) 

      time.sleep(0.0005)

    def lcdcmd(ch): 

      gpio.output(RS, 0)

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x10==0x10:

        gpio.output(D4, 1)

      if ch&0x20==0x20:

        gpio.output(D5, 1)

      if ch&0x40==0x40:

        gpio.output(D6, 1)

      if ch&0x80==0x80:

        gpio.output(D7, 1)

      gpio.output(EN, 1)

      time.sleep(0.005)

      gpio.output(EN, 0)

      # Low bits

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x01==0x01:

        gpio.output(D4, 1)

      if ch&0x02==0x02:

        gpio.output(D5, 1)

      if ch&0x04==0x04:

        gpio.output(D6, 1)

      if ch&0x08==0x08:

        gpio.output(D7, 1)

      gpio.output(EN, 1)

      time.sleep(0.005)

      gpio.output(EN, 0)

    def lcdwrite(ch): 

      gpio.output(RS, 1)

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x10==0x10:

        gpio.output(D4, 1)

      if ch&0x20==0x20:

        gpio.output(D5, 1)

      if ch&0x40==0x40:

        gpio.output(D6, 1)

      if ch&0x80==0x80:

        gpio.output(D7, 1)

      gpio.output(EN, 1)

      time.sleep(0.005)

      gpio.output(EN, 0)

      # Low bits

      gpio.output(D4, 0)

      gpio.output(D5, 0)

      gpio.output(D6, 0)

      gpio.output(D7, 0)

      if ch&0x01==0x01:

        gpio.output(D4, 1)

      if ch&0x02==0x02:

        gpio.output(D5, 1)

      if ch&0x04==0x04:

        gpio.output(D6, 1)

      if ch&0x08==0x08:

        gpio.output(D7, 1)

      gpio.output(EN, 1)

      time.sleep(0.005)

      gpio.output(EN, 0)

    def lcdclear():

      lcdcmd(0x01)

    def lcdprint(Str):

      l=0;

      l=len(Str)

      for i in range(l):

        lcdwrite(ord(Str[i]))

    def setCursor(x,y):

        if y == 0:

            n=128+x

        elif y == 1:

            n=192+x

        lcdcmd(n)

    def keypad():

       for j in range(4):

         gpio.setup(COL[j], gpio.OUT)

         gpio.output(COL[j], 0)

         ch=0

         for i in range(4):

           if gpio.input(ROW[i])==0:

             ch=MATRIX[i][j]

             #lcdwrite(ord(ch))

            # print "Key Pressed:",ch

            # time.sleep(2)

             return ch

             while (gpio.input(ROW[i]) == 0):

               pass

         gpio.output(COL[j],1)

        # callNum[n]=ch

    def serialEvent():

        data = Serial.read(20)

        #if data != '\0':

        print data

        data=""

    def gsmInit():

        lcdclear()

        lcdprint("Finding Module");

        time.sleep(1)

        while 1:

            data=""

            Serial.write("AT\r");

            data=Serial.read(10)

            print data

            r=data.find("OK")

            if r>=0:

                break

            time.sleep(0.5)

        while 1:

            data=""

            Serial.write("AT+CLIP=1\r");

            data=Serial.read(10)

            print data

            r=data.find("OK")

            if r>=0:

                break

            time.sleep(0.5)

        lcdclear()

        lcdprint("Finding Network")

        time.sleep(1)

        while 1:

            data=""

            Serial.flush()

            Serial.write("AT+CPIN?\r");

            data=Serial.read(30)

            print data

            r=data.find("READY")

            if r>=0:

                break

            time.sleep(0.5)

        lcdclear()

        lcdprint("Finding Operator")

        time.sleep(1)

        while 1:

            data=""

            Serial.flush()

            Serial.read(20)

            Serial.write("AT+COPS?\r");

            data=Serial.read(40)

            #print data

            r=data.find("+COPS:")

            if r>=0:

                l1=data.find(",\"")+2

                l2=data.find("\"\r")

                operator=data[l1:l2]

                lcdclear()

                lcdprint(operator)

                time.sleep(3)

                print operator

                break;

            time.sleep(0.5)

        Serial.write("AT+CMGF=1\r");

        time.sleep(0.5)

       # Serial.write("AT+CNMI=2,2,0,0,0\r");

       # time.sleep(0.5)

        Serial.write("AT+CSMP=17,167,0,0\r");

        time.sleep(0.5)

    def receiveCall(data):

            inNumber=""

            r=data.find("+CLIP:")

            if r>0:

                inNumber=""

                inNumber=data[r+8:r+21]

                lcdclear()

                lcdprint("incoming")

                setCursor(0,1)

                lcdprint(inNumber)

                time.sleep(1)

                return 1

    def receive SMS(data):

        print data

        r=data.find("\",")

        print r

        if r>0:

            if data[r+4] == "\r":

                smsNum=data[r+2:r+4]

            elif data[r+3] == "\r":

                smsNum=data[r+2]

            elif data[r+5] == "\r":

                smsNum=data[r+2:r+5]

            else:

                print "else"

            print smsNum

            if r>0:

                lcdclear()

                lcdprint("SMS Received")

                setCursor(0,1)

                lcdprint("Press Button B")

                print "AT+CMGR="+smsNum+"\r"

                time.sleep(2)

                return str(smsNum)

        else:

            return 0

    def attendCall():

        print "Attend call"

        Serial.write("ATA\r")

        data=""

        data=Serial.read(10)

        l=data.find("OK")

        if l>=0:

            lcdclear()

            lcdprint("Call attended")

            time.sleep(2)

            flag=-1;

            while flag<0:

                data=Serial.read(12);

                print data

                flag=data.find("NO CARRIER")

                #flag=data.find("BUSY")

                print flag

            lcdclear()

            lcdprint("Call Ended")

            time.sleep(1)

            lcdclear()

    def readSMS(index):

                    print index

                    Serial.write("AT+CMGR="+index+"\r")

                    data=""

                    data=Serial.read(200)

                    print data

                    r=data.find("OK")

                    if r>=0:

                        r1=data.find("\"\r\n")

                        msg=""

                        msg=data[r1+3:r-4]

                        lcdclear()

                        lcdprint(msg)

                        print msg

                        time.sleep(5)

                        lcdclear();

                        smsFlag=0

                        print "Receive SMS"

    def getChar(Key, ind, maxInd):

                ch=0

                ch=ind

                lcdcmd(0x0e)

               Char=''

                count=0

     

                global msg

                global x

                global y

                while count<20:

                    key=keypad()

                    print key

                    if key== Key:

                        setCursor(x,y)

                        Char=alpha[ch]

                        lcdwrite(ord(Char))

                        ch=ch+1

                        if ch>maxInd:

                            ch=ind

                        count=0

                    count=count+1

                    time.sleep(0.1)

                msg+=Char

                x=x+1

                if x>15:

                    x=0

                    y=1

                lcdcmd(0x0f)

     

    def alphaKeypad():

        lcdclear()

        setCursor(x,y)

        lcdcmd(0x0f)

        msg=""

        while 1:

            key=0

            count=0

            key=keypad()

            if key == '1':

                ind=0

                maxInd=6

                Key='1'

                getChar(Key, ind, maxInd)

            elif key == '2':

                ind=7

                maxInd=10

                Key='2'

                getChar(Key, ind, maxInd)

            elif key == '3':

                ind=11

                maxInd=14

                Key='3'

                getChar(Key, ind, maxInd)

            elif key == '4':

                ind=15

                maxInd=18

                Key='4'

                getChar(Key, ind, maxInd)

            elif key == '5':

                ind=19

                maxInd=22

                Key='5'

                getChar(Key, ind, maxInd)

            elif key == '6':

                ind=23

                maxInd=26

                Key='6'

                getChar(Key, ind, maxInd)

            elif key == '7':

                ind=27

                maxInd=31

                Key='7'

                getChar(Key, ind, maxInd)

            elif key == '8':

                ind=32

                maxInd=35

                Key='8'

                getChar(Key, ind, maxInd)

            elif key == '9':

                ind=36

                maxInd=40

                Key='9'

                getChar(Key, ind, maxInd)

            elif key == '0':

                ind=41

                maxInd=42

                Key='0'

                getChar(Key, ind, maxInd)

            elif key == '*':

                ind=43

                maxInd=43

                Key='*'

                getChar(Key, ind, maxInd)

            elif key == '#':

                ind=44

                maxInd=44

                Key='#'

                getChar(Key, ind, maxInd)

            elif key== 'D':

                return

    def sendSMS():

        print"Sending sms"

        lcdclear()

        lcdprint("Enter Number:")

        setCursor(0,1)

        time.sleep(2)

        moNum=""

        while 1:

            key=0;

            key=keypad()

            #print key

            if key>0:

                if key == 'A'  or key== 'B' or key== 'C':

                    print key

                    return

                elif key == 'D':

                    print key

                    print moNum

                    Serial.write("AT+CMGF=1\r")

                    time.sleep(1)

                    Serial.write("AT+CMGS=\"+91"+moNum+"\"\r")

                    time.sleep(2)

                    data=""

                    data=Serial.read(60)

                    print data

                    alphaKeypad()

                    print msg

                    lcdclear()

                    lcdprint("Sending.....")

                    Serial.write(msg)

                    time.sleep(1)

                    Serial.write("\x1A")

                    while 1:

                        data=""

                        data=Serial.read(40)

                        print data

                        l=data.find("+CMGS:")

                       if l>=0:

                            lcdclear()

                            lcdprint("SMS Sent.")

                            time.sleep(2)

                            return;

                        l=data.find("Error")

                        if l>=0:

                            lcdclear()

                            lcdprint("Error")

                            time.sleep(1)

                            return

                else:

                    print key

                    moNum+=key

                    lcdwrite(ord(key))

                    time.sleep(0.5)

    def call():

        print "Call"

        n=0

        moNum=""

        lcdclear()

        lcdprint("Enter Number:")

        setCursor(0,1)

        time.sleep(2)

        while 1:

            key=0;

            key=keypad()

            #print key

            if key>0:

                if key == 'A'  or key== 'B' or key== 'D':

                    print key

                    return

                elif key == 'C':

                    print key

                    print moNum

                    Serial.write("ATD+91"+moNum+";\r")

                    data=""

                    time.sleep(2)

                    data=Serial.read(30)

                    l=data.find("OK")

                    if l>=0:

                        lcdclear()

                        lcdprint("Calling.....")

                       setCursor(0,1)

                        lcdprint("+91"+moNum)

                        time.sleep(30)

                        lcdclear()

                        return

                    #l=data.find("Error")

                    #if l>=0:

                    else:

                        lcdclear()

                        lcdprint("Error")

                        time.sleep(1)

                        return

                else:

                    print key

                    moNum+=key

                    lcdwrite(ord(key))

                    n=n+1

                    time.sleep(0.5)

    begin()

    lcdcmd(0x01)

    lcdprint("  Mobile Phone  ")

    lcdcmd(0xc0)

    lcdprint("    Using RPI     ")

    time.sleep(3)

    lcdcmd(0x01)

    lcdprint("Circuit Digest")

    lcdcmd(0xc0)

    lcdprint("Welcomes you")

    time.sleep(3)

    gsmInit()

    smsFlag=0

    index=""

    while 1:

        key=0

        key=keypad()

        print key

        if key == 'A':

          attendCall()

        elif key == 'B':

          readSMS(index)

          smsFlag=0

        elif key == 'C':

          call()

        elif key == 'D':

          sendSMS()

        data=""

        Serial.flush()

        data=Serial.read(150)

        print data

        l=data.find("RING")

        if l>=0:

          callstr=data

          receiveCall(data)

        l=data.find("\"SM\"")

        if l>=0:

          smsstr=data

          smsIndex=""

          (smsIndex)=receiveSMS(smsstr)

          print smsIndex

          if smsIndex>0:

              smsFlag=1

              index=smsIndex

        if smsFlag == 1:

            lcdclear()

            lcdprint("New Message")

            time.sleep(1)

        setCursor(0,0)

        lcdprint("C--> Call <--A");

        setCursor(0,1);

        lcdprint("D--> SMS  <--B")

    GSM Technology Applications

    Here are some examples of how GSM technology can be put to use.

    1. Automation and Safety via Smart GSM Technology

    Nowadays, we can't live without our GSM mobile terminal. The Mobile phone terminal is essentially an extension of ourselves, allowing us to connect with the world in the same way our wallet/purse, keys, or watch does. Many people like not having to worry about being unavailable or who they can call at any given moment.

    It's clear from the name that this Project relies on the SMS transmission capabilities of GSM networks. The ability to send and receive text messages is widely utilized to provide access to equipment and facilitate home security breach management. There are two proposed subsystems in the system. Controlling appliances in one's house from afar is made possible by the appliance control subsystem, while the security alert subsystem provides automatic security monitoring.

    The system can send consumers instructions via SMS from a designated phone number to adjust the home appliance's state as needed. An automatic SMS can be generated by the system upon detection of an intrusion, warning the user of a potential threat to their data.

    The advent of GSM technology will make global, instantaneous, and universal communication possible. GSM's functional architecture employs intelligent networking principles as the first step toward a genuinely personal communication system with sufficient standards to ensure interoperability.

    1. Medical Uses for GSM-Based Systems

    Here are two examples of similar situations to think about.

    • The patient has sustained a life-threatening injury or illness and requires emergency medical attention. A mobile phone is the only thing he (or his companion) has.

    • After being released from the hospital, the patient plans to rest at home but is reminded that he must return for routine exams. A mobile phone and perhaps some health monitoring or other medical sensor gadgets may be in his possession.

    The only way to solve either problem is via a mobile communication system. In other words, the above scenarios are easily manageable with today's communication technology because all that needs to be done is send the patient's information across a network and have it processed at the receiving end, which may be a hospital or the doctor's office.

    In the first scenario, the doctor keeps tabs on the patient's information and returns the instructions to him so he can take whatever precautions before getting to the hospital. In the second scenario, the doctor keeps tabs on the patient's test results and, if necessary, proceeds with treatment.

    Telemedicine services are the driving force behind this entire operation. The telemedicine system has three different applications.

    • Video conferencing lets patients in one location have face-to-face contact with their doctors and nurses, speeding up the healing process.

    • With the help of sensors that constantly report on a patient's condition and direct medical staff on how to proceed with treatment.

    • By sending the gathered health information for further review and analysis.

    A wireless method of communication is used for the three options mentioned above. When providing healthcare, it is necessary to have many data retrieval mechanisms in place. These can be online medical databases or hosts with equipment that aid recovery and health monitoring. Broadband networks, medium-throughput media, and narrowband GSM access are all viable possibilities.

    There are several benefits to using GSM technology in a telemedicine setup.

    • Cost savings and widespread availability of GSM receivers (including cell phones and modems)

    • It can transfer data quickly.

    1. Typical Telemedical Infrastructure

    The four components that make up a standard telemedicine system are as follows:

    1. The Patient Unit: It takes data from the patient, either in its original analog form or after being converted to digital format, and then manages the data stream before sending it. It is made up of several different types of medical sensors, such as those used to track heart rate, blood pressure, body temperature, spirometry, etc., each of which generates an electrical signal that is sent to a processor or controller for analysis before being transmitted over a wireless network.

    2. Communication Network: As such, it is employed for both data transmission and security. Networks, mobile stations, and base stations are all components of the Global System for Mobile Communication (GSM) system. The mobile station, also known as the mobile phone or primary mobile access point, is the device responsible for connecting mobile devices to the global system for mobile communications (GSM) network.

    3. Receiving/Server Side: This is a healthcare system with a GSM modem installed to receive, decode, and forward signals to the presenting device.

    4. Presentation Unit: This is the brains of the operation. This processor saves the data in a standard format for later retrieval and analysis by doctors and from which they can send text messages to the client side if necessary.

    To demonstrate the fundamentals of telemedicine, a rudimentary model will suffice. It has a sender and a receiver, both of which are separate components. The sensor input is transmitted by the transmitter and received by the receiver unit for processing.

    See below for a simplified telemedicine system to track a patient's heart rate and apply the results as needed.

    The data collected by the heartbeat detector (a light-emitting device whose light is modified as it flows through human blood) is transformed into electrical pulses at the transmitter unit. When the Microcontroller picks up on these pulses, it calculates the heart rate and communicates that information and other data collected to the medical team via a Gsm network. An IC called a Max 232 connects the Microcontroller to the GSM modem.

    The GSM modem at the receiving end grabs the information and passes it to the Microcontroller. The Microcontroller then performs an analysis using the input from the Personal computer and displays the outcome on the LCD. Medical professionals can keep tabs on the patient and begin the necessary treatment after reviewing the results on the screen.

    Medical Applications of Global Systems for Mobile Communication

    The following are some real-world applications for GSM technology.

    1. AT&T Health GlowCaps

    These plain pill bottles serve as a gentle prompt to the patient to take their prescribed medications. It uses GSM technology to contact the patient on their mobile phone at the specified pill-taking time, at which point the cap will light up, the buzzer will sound, and the patient will be reminded to take their medication. Each time a bottle is uncorked, it is documented.

    1. Ultrasound technology

    With the help of a portable ultrasound transducer that connects to a smartphone, it is possible to send ultrasound images captured with a handheld device to a distant location using a global system for mobile communications (GSM).

    1. A Continuous Glucose Monitor (CGM)

    The patient's blood sugar levels can be tracked and reported to the doctor. A sensor is implanted under the skin and monitors blood glucose levels, sending the data to a receiver (a mobile phone) at regular intervals.

    Conclusion

    As part of this guide, we analyzed GSM's architecture and learned how it operates in practice. We wrote a Python program to turn our Raspberry Pi 4 into a fully functional mobile phone. No technical difficulties were encountered as we watched text and phone calls travel between the raspberry pi and our mobile phone. You should feel confident in your ability to apply the ideas and understand the circuits of GSM now. One way to up the difficulty level of this Project is to try to make a live video call using the raspberry pi 4 mobile. Next, we'll look at connecting the pcf8591 ADC/DAC analog-digital converter module to a Raspberry Pi.

    Water Level Indicator using Arduino

    Hello geeks, welcome to our new project. Here, we are going to make a very useful project which we can use for ourselves or we can use this as a product as well on an industry level.

    In this project, we are going to make a water level indicator. We all know it is one of the most essential products because there are many water tanks in every house or office, and most of them are not easily accessible to check the level of water in it and I think most of us faced the problem such as shortage of water as we do not have anything to monitor the exact amount of water available in the tank and this causes many problems on our daily lives.

    Where To Buy?
    No.ComponentsDistributorLink To Buy
    1LEDsAmazonBuy Now
    2Arduino UnoAmazonBuy Now

    Software to install

    As we are going to make this project in the simulation first, for that, we will use the Proteus simulation tool. It is a tool used for electronic projects in which, we can run the real-time simulation of any electronic project and we can debug it in real-time without making any damage to real components.

    Proteus has a very big database for electronic components which comes in the installation package of Proteus, but still, sometimes we have to install packages or libraries for some modules which are not pre-installed in it.

    As in this project, we are going to use Arduino which is not pre-installed in the Proteus software. So we can download the Arduino module package from the link given below:

    Components Required

    In this project, we will use the following components
    • Arduino UNO
    • LEDs
    • Water level indicator

    Components details

    Arduino UNO

    • Arduino UNO is an open-source microcontroller of the Arduino family.
    • We have used this as the main controller of this project.
    • Using this we can measure the readings of the water level sensor and indicate the user accordingly.
    • It has 14 digital input/output pins which can be used for controlling any digital components or can be used to read digital sensors.
    • It has 6 analog input /output pins which are used for analog read and write functions.
    • The ADC used for analog pins is 10 bits which range from 0-1023.

    Note- While uploading the code on the Arduino UNO, disconnect any wire which is connected to Rx(D0) and Tx(D1) pins, otherwise it will give an error while uploading the code.

    Water Level Sensor

    • The water level indicator works on the principle of the potentiometer.
    • It has three pins as Vcc, Gnd, and Signal.
    • There are two kinds of exposed copper strips on the sensor which are Vcc and sensor line.
    • When it emerges in the water tank, the conductivity increases and the resistance decreases due to that, it increases the output voltage on the sensor pin of the water level sensor.
    • The output value of the sensor changes with the height of the water level in the water tank.
    • And this gives the analog output so that we will use the analog pin of the Arduino UNO for reading the sensor value.
    • As this will have analog values, we have to calibrate the sensor before using it in the project.
    • We will talk about calibration later in the article.

    LEDs

    • LED stands for light-emitting diode.
    • They are used for indication purposes in this project.
    • LEDs are like normal diodes, they will allow the current to pass from only one direction.
    • They come in different colors and the color of LEDs differs as per the used material in its manufacturing.
    • There are two terminals in the LEDs, the larger one is the cathode and another one is the anode.
    • Using the length of the terminals, we can figure out the polarity of the LED but if in case both terminals are the same size then there is a flat side on the LED, that side is the negative terminal and another is the positive terminal.

    Project overview

    The water level indicator works on the principle of change in the resistance of the water level sensor due to a change in the amount of water in the container.

    Basically, there are two parallel strips in the water level sensor, one for the power supply and another is for the sensor strip. As we know, water is a conductor of electricity so when we increase the amount of water in the container then more length of the sensor emerges in the water and that will increase the conductivity between the strips therefore, it increases the voltage on the sensor pin as well. We will read that voltage on the Arduino UNO.

    To get the exact amount of water level in the container, we have to calibrate the sensor with the water because we can not be assured that the output voltage will be the same for every water because we know that there are lots of materials dissolved in the water so it will vary for a different source of water, therefore, we have to calibrate it first.

    For calibration of the sensor, we will take a container with the water and we will read the values from the sensor by changing the level of water in the container. We will perform this action till the container gets filled with water and we will note down all the reference values and mark them as thresholds for each level.

    As in this project, we are making it in the simulation so it would not be possible for changing the values as per the water level therefore we have used the potentiometer and we have chosen the threshold values randomly.

    No need to worry while making this project with the real components as the sensor values from the water level sensor will be in the same format as the output of the potentiometer.

    Now that we know the working principle of the water level indicator let’s go for the circuit diagram of the project.

    Circuit diagram

    As we know the required components which we are going to use in this project.

    • First of all, start a new project in the Proteus simulation software.
    • Import all the listed components in the Proteus workspace.
    • For sensor simulation, we will import one potentiometer.
    • Connect the output pin of the potentiometer with the analog pin of the Arduino UNO. In this project, we are using the A0 pin.
    • And other pins with the ground and 5volt Vcc.
    • Now start connecting the LEDs, for controlling the LEDs, we will use the digital pins of Arduino and they are D2, D3, D4, D5 pins.
    • While connecting the LED pins, keep the sequence the same otherwise there will be an error in the indication of levels.
    • Connect the positive terminal of the LED with the digital pins of the Arduino and the negative pins with the ground.
    • Now we have completed the connection of our project. Let’s move to the coding side of this project.

    Arduino code of water level indicator

    For coding, we will use the Arduino IDE. It is a built-in IDE for Arduino developments.

    Arduino code is divided into mainly three parts: declaration of function and variables, second is void setup section, and third is void loop.

    First of all, declare the variables and pin number which we are going to use in this project.

    • Declare five variables for storing the pin numbers of LEDs and one variable for storing analog pins for reading the sensors.

    Void Setup()

    • This is the most important function in Arduino programming because our code will not compile successfully without using this function in the code.
    • When Arduino code starts this is the first function that runs.
    • This function runs only once when the code restarts.
    • So here, we will write the code which requires only one time to run.
    • In this function, we will basically declare the pin modes of the pins which we will use in the project.
    • Declare the pin mode of LEDs as output mode and sensor pin as input mode. Because we want to control the LEDs so that they must be in output mode and to read data from the sensor as input then it should be declared as input mode.

    Void loop()

    • This is the second most important function of Arduino code structure.
    • This function also must be in the code without it our code will not compile successfully.
    • In this function, we will write the main application code which we want to run continuously.
    • First of all, we will read the sensor value because we will make the decisions on the sensor values.
    • And for debugging purposes, we will print that value on the serial monitor.
    • As the sensor will give the analog output data, we will use the analogRead function for reading the sensor data.
    • After reading the sensor value, set the LEDs as per the threshold which we have calculated while calibrating the sensor for each level.
    • We will divide the values into five conditions for each level we set the LEDs accordingly.
    • First, we write the condition for when the container is full then, let’s assume the value will be more than 760. Then switch on all the LEDs.
    • After that, set the condition for the second level when the sensor value is lesser than 760 but greater than 720. Here we will set the 5th LED to low state and other LEDs to a high state.
    • Next check the condition for the third level when the sensor value is in the range of 615 to 720 and here we will set the 5th and 4th LED to low state and other LEDs to a high state.
    • Next check the condition for the fourth level when the sensor value lies in the range of 615 to 410. Here we will set the 3rd, 4th, 5th LEDs to low state and the rest two LEDs to a high state.
    • After that, check the condition for the fifth level when the sensor value lies in the range of 410 to 250, and here we will set 5th, 4th, 3rd, 2nd LED to low state and remaining one LED to a high state.
    • Last check the condition for when the container is almost empty when the sensor value lies in the range of 250 to 0. Here we will set all five LEDs to a low state.
    • After that give a delay of 1 second for settling of sensor values and calibration.

    Results and working

    Now we have completed our code and circuit, it's time to run the project.

    • To run the simulation, we have to include the hex file of the Arduino code.
    • We will generate the hex from the Arduino IDE.
    • To generate the hex file, go to the Sketch >> Export compiled binary, after that, it will compile the code and in the project folder, there will be two files one is binary and the other is hex file.
    • Now we have to include the hex file in the Arduino module in the Proteus software.
    • Click on the Arduino UNO module, then a window will pop up where you can add the hex file of the project.
    • Now we are all set to run the project, click on the Run button in the software to start the simulation.
    • To change the water level in the simulation, we will change the value on the potentiometer and as the values from the potentiometer change then the LEDs will also respond accordingly.
    • First check the condition when the water level is very low, mostly when the container is empty.
    • When the water level is very low then there will be very less conductivity or maybe no conductivity, in this case, the output voltage from the sensor will be very less.
    • So in this condition, all LEDs will be off.
    • In the image, we can see that the voltage at the analog pin is 0.5 volts.
    • Now when the water level increases then in that condition the conductivity will also increase so does the output voltage from the sensor.
    • So let’s increase the water level to the first level.
    • Here we can see the output voltage increased to 1.5 volts and the first led is glowing.
    • Now similarly increase the water level for next levels.
    • Check water for the second level. The output voltage is iincreased to 2 volts.
    • Now check for the next level.
    • Now check for when the container is filled. Then all LEDs will glow.

    Conclusion

    I hope we have covered all the points related to this project, and I think it will be very useful in daily life and it will give us ease of monitoring water in our water tanks. After this project, we don’t have to take the headache of how much water is available in our tank. And please let us know in the comment section if you have faced any issues while making it and also how you are going to use it in real life.

    Thanks for reading this article. All the best for your projects.

     

    Scrolling Text on LCD with Arduino

    Hello everyone! hope you all will be fine. In this article I am going to share the knowledge about displaying Scrolling Text on LCD with Arduino. A Liquid Crystal Display is usually known as LCD in the market. It is a display unit made up of liquid crystal. When we want to made electronics based projects, we need a device on which we can show the system’s output and the desired messages. There are a lot of such devices which are helpful to display the output messages and the most common is a seven segment display. Alternate good option is LCD, which are now available in different size having different qualities. 16×2 LCD Module is a most frequently used device for the electronic projects out of all the other types of LCD’s available in the market. 32 ASCII characters can be displayed on it simultaneously in 2 rows i.e. it has a capacity to show 16 characters per row. 20×4 LCD, 128×64 graphical LCD and 2.4 inch TFT Touch screen LCD are also used commonly for the electronic projects now-a-days in the market and as well as in the institutions.

    Scrolling Text on LCD with Arduino

    In the tutorial Scrolling Text on LCD with Arduino, we are going to learn how to interface a 16×2 lcd to Arduino UNO and how to display the scrolling text on LCD in Proteus ISIS. First I would like to write a simple code to print something on the LCD and then I will update the previously written code to scroll the text printed already on the LCD.
    • You candownload the complete simulation here by clicking on the button below.

    Arduino Source Code

    • Just download .rar file, extract it and enjoy the complete simulation.
    Interfacing 16×2 LCD to Arduino uno
    LCD modules are most frequently used devices specially in Arduino based electronic projects. So it is essential to share this tutorial based on interfacing LCD module to Arduino UNO and displaying scrolling text on LCD with all of you. Interfacing of an Arduino UNO to 16×2 LCD is elaborated in this section. The selected LCD module has 16 pins. You can operate this module in 4 bit mode by using only four data lines (from D4 to D7) or 8 bit mode by using all the eight data lines (from D0 to D7). In this article we are using the LCD module operating in the 4-bit operational mode i.e. we are using only four data pins. I have divided this tutorial in two parts. First of all, I will explain how to display a simple text messages on the 16×2 LCD with Arduino UNO and secondly I will show that how to display scrolling text on the same LCD interfaced with Arduino UNO. Before the explanation of this design, let’s have a look at the selected LCD. You should also have a look at this New LCD Library for Proteus.
    Designed Circuit in Proteus ISIS
    Find Arduino UNO and a 16×2 LCD in the components library of proteus ISIS ISIS. If arduino library is present in your Arduino software then arduino will be shown in the components library otherwise you have to install Arduino library for proteus ISIS. Wiring diagram of the LCD module with Arduino UNO in proteus ISIS is shown in the figure below. You can download this Proteus Simulation from Interfacing of LCD with Arduino.
    • .Now just copy and paste the given source code in the Arduino software
    #include<LiquidCrystal.h> //Library for LCD
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// LCD pins at which it is attached to the Arduino
    
    void setup() //method used to run the source for the one time onlys
    {
      lcd.begin(16, 2);//LCD order i.e. 16 columns & 2 rows
      lcd.print("The Engineering Projects ");//prints on LCD
      lcd.setCursor(0,1);//setting cursor on LCD
      lcd.print("www.TheEngineeringProjects.com");//prints on LCD
      delay(1000);//delay of 1 sec
    }
    void loop() //method to run the source code repeatedly 
    {
     lcd.noDisplay();//turn off the display of LCD
     delay(250);//delay to 0.25 seconds
     lcd.display();//turning on the LCD display
     delay(250); //delay of 0.25 seconds again
    }
    • Now compile the source code and get hex file from it as shown in the figure below.
    • Copy this address as shown in the figure above.
    • Double click on Arduino UNO in proteus, a new window will be opend as shown in the figure below.
    • Paste that address in the file menu as encircled in the figure below.
    • Run the proteus simulation from the Arduino software from the upper left corner of the software.
    • If everything goes perfect you will see the output as shown in the figure below.
    • Copy and paste the source given below in your Arduino software.
    #include <LiquidCrystal.h>//Library for LCD
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//LCD pins at which it is attached to the Arudino
    
    void setup()//method used to run the code for once 
    {
      lcd.begin(16, 2);//LCD order
      lcd.print("The Engineering Projects ");//prints on LCD
      lcd.setCursor(0,1);//Setting the cursor on LCD
      lcd.print("www.TheEngineeringProjects.com");//prints on LCD
      delay(1000);//delay of 1 second
    }
    
    void loop() //used to run the code repeatedly
    {
     for(int PositionCount=0;PositionCount<13; PositionCount++)//loop for scrolling the LCD text
      {
        lcd.scrollDisplayLeft();//builtin command to scroll left the text
        delay(150);// delay of 150 msec
        }
    
       for(int PositionCount=0; PositionCount<29; PositionCount++)
       {
        lcd.scrollDisplayRight(); //builtin command to scroll right the text
        delay(150);//delay of 150 msec
        }
       for(int PositionCount=0; PositionCount<16; PositionCount++)//loop for scrolling the text
       {
        lcd.scrollDisplayLeft();//builtin command to scroll the text left again
        delay(150);//delay of 150 msec
        }
    }
    • Compile the code given above.
    • Obtain the hex file as I told above in the figure.
    • And open it in your proteus as I described above.
    • Run the simulation like the I have previously done.
    • You will be able to see the scrolling text on LCD as shown in the figure below.
    • That all from this article to show Scrolling Text on LCD using Arduino.
    • Was it difficult? I don't think so :)
    So, that is all from the tutorial Scrolling Text on LCD using Arduino. I hope you enjoyed this tutorial. If you face any sort of problem, you can ask me in the comments any time. I will try my level best to solve your issues in a better way, if possible. I will explore Arduino by making different projects on it and will share them with you as well. Till then, take care :)

    How to use Arduino Serial Write?

    Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share the next tutorial in this series of basic Arduino tutorials and it's named How to use Arduino Serial Write. In this tutorial, I have given an overview of How to use the Arduino Serial Write Command. In the previous tutorial, we have seen How to use Arduino Serial Read? in which we have read the data coming from the serial port.

    While today we will have a look at how to send the data through a serial port in Arduino and for that, I am going to use the Arduino Serial Write command. It's also going to be a very simple and basic Arduino tutorial but if you are new to Arduino then you must read it completely as it will gonna help you out. I have also designed a Proteus Simulation and explained it at the end of this tutorial. I hope you guys are gonna learn from it:

    How to use Arduino Serial Write ???

    • In the Arduino Serial Read, we have seen that How to read data coming from the serial port and we have used Pin # 0 for that purpose.
    • So, now we are going to write some data on the Serial Port.
    • It's like we are sending data from Arduino to some other device via Serial Port.
    • For example, you are using a GSM module with Arduino then you have to send AT commands to your GSM board from Arduino and that's where you use Arduino Serial write.
    • You can download the Proteus Simulation and code for Arduino Serial Write Command by clicking the below button:
    Download Simulation and Code
    • Here's the first syntax for Arduino Serial write:
    Arduino Serial Write Syntax 1:
    • Arduino Serial Write is used to write some data on the Serial Port and it sends data in binary form.
    • Here's Arduino Serial Write Syntax:

    Serial.write ( 'DataSent' ) ;

    where:

    • DataSent is a simple byte and is used in these characters ' '. The below example code will send byte '1' on the serial port:

    Serial.write ( '1' ) ;

    • Now, let's write some data on Arduino Serial Port using the above syntax and see what we got.

    Proteus Simulation

    • So, design a Proteus Simulation as shown in the below figure:
    #include <LiquidCrystal.h>
    
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
    
    void setup() {
      // set up the LCD's number of columns and rows:
      lcd.begin(20, 4);
      // Print a message to the LCD.
      lcd.setCursor(1,0);
      lcd.print("www.TheEngineering");
      lcd.setCursor(4,1);
      lcd.print("Projects.com");
      lcd.setCursor(1,0);
      Serial.begin(9600);
      lcd.clear();
      
      Serial.write('1');
    }
    
    void loop() 
    {
    }
    
    • In the above code, I have simply written a byte which you can see is 1.
    • So, now upload it and run your simulation and if everything goes fine then you will get 1 on your virtual serial terminal of Proteus, as shown in the below figure:
    • You can see in the above figure that we got 1 in Serial Port so now you can send whatever you want via this Arduino Serial Write Command.
    • Now let's have a look at the second syntax of the Arduino Serial Write command:
    Arduino Serial Write Syntax 2:
    • We can also send a String of bytes via Arduino Serial Write Command. Here's the syntax:

    Serial.write ( "DataSent" ) ;

    where:

    • DataSent is a simple byte and is used in these characters " ". The below example code will send our site address on the serial port:

    Serial.write ( "www.TheEngineeringProjects.com" ) ;

    • Now let's sent a string of bytes through this Arduino Serial Write Command, so I have used the below code and have sent our website address via Serial Write.
    • So, use the below code and get your Hex File:
    #include <LiquidCrystal.h>
    
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
    
    void setup() {
      // set up the LCD's number of columns and rows:
      lcd.begin(20, 4);
      // Print a message to the LCD.
      lcd.setCursor(1,0);
      lcd.print("www.TheEngineering");
      lcd.setCursor(4,1);
      lcd.print("Projects.com");
      lcd.setCursor(1,0);
      Serial.begin(9600);
     // lcd.clear();
      
      Serial.write("www.TheEngineeringProjects.com");
    }
    
    void loop() 
    {
    }
    
    • Run your Proteus Simulation and you will get the below results:
    • You can see in the above figure that we got the whole address via Serial Port.
    That's all for today, I hope you guys have enjoyed today's post. In the coming post, I am gonna discuss the Arduino Print Command. Thanks for reading. Take care.

    Interfacing of Flame Sensor with Arduino

    Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new tutorial which is Interfacing of Flame Sensor with Arduino. I have recently posted a tutorial in which I have shared the Flame Sensor Library for Proteus. Now in this tutorial, I am gonna use that Flame Sensor Library and will interface this Flame Sensor with Arduino. So, if you haven't downloaded this file then I suggest you to download this Flame Sensor Library so that you can easily simulate this flame Sensor in Proteus.

    I am sharing interfacing of this Flame Sensor with Arduino today, but soon I will also post a tutorial on Interfacing of Flame Sensor with PIC Microcontroller. If you guys have any questions then ask in comments. I have also given the Simulation file and the Programming code below to download. But I would recommend you to design this proejct on your own so that you make mistakes and then learn from them. So, let's get started with Interfacing of Flame Sensor with Arduino:

    Interfacing of Flame Sensor with Arduino

    • You can download the complete Proteus Simulation along with Arduino programming code from the below button:

    Download the Simulation

    • Now design a small Arduino code as given below:
    #include <LiquidCrystal.h>
    
    LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
    
    int Flame = 7;
    
    void setup() {
      Serial.begin(9600);
      pinMode(Flame, INPUT_PULLUP);
      lcd.begin(20, 4);
      lcd.setCursor(0,0);
      lcd.print("Flame : ");
      lcd.setCursor(1,2);
      lcd.print("www.TheEngineering");
      lcd.setCursor(4,3);
      lcd.print("Projects.com");
    }
    
    void loop() {
      if(digitalRead(Flame) == HIGH){lcd.setCursor(8,0);lcd.print("Detected    ");}
      if(digitalRead(Flame) == LOW ){lcd.setCursor(8,0);lcd.print("Not Detected");}
      
    }
    
    • Add this code in your Arduino software and compile it to get the Hex File from Arduino Software.
    • Upload this hex file in your simulation and then run your simulation and if everything goes fine then you will get something as shown in below figure:
    • In the above figure, you can see the sensor is off that's why in the LCD its written that no smoke detected.
    • Now, let's bring some Flame by clicking the Logic State on Flame Sensor and you will see the below results:
    • Now you can see in the above figure that when the Flame is detected then the LCD indicated that Flame has detected.
    • That's how we can easily simulate the Flame Sensor with Arduino.
    • I have explained this project in detail in the below video:
    That's all for today. I hope you have enjoyed this project and now you can easily interface your Flame Sensor with Arduino in Proteus ISIS.

    How to Measure Frequency using Arduino

    Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share on How to measure Frequency using Arduino board. Its quite a simple tutorial but is an essential one especially when you are working on some power related project. Because in Power projects, you have to measure the frequency of AC voltages. I was working on a project in which I have to do dimming of AC Lamp so in that project I have to measure the frequency of AC signal.

    I have designed this project using Arduino UNO and have simulated in the Proteus software, which you all know is my favorite simulating software. :) The code is also quite simple which I have given below for download. The simulation is also included in download package but again I suggest you to design it on your own. If you got into any trouble then ask in comments and I will try to resolve them. Anyways let's get started with How to measure frequency using Arduino.

    How to Measure Frequency using Arduino ???

    • You can download the simulation for this frequency measuring by clicking the below button:

    Download Project Files

    • Now let's design this project in Proteus. So, first of all, design a simulation as shown in below figure:
    • The small block attached with the pin # 2 of Arduino is a frequency meter.
    • We can create any kind of frequency signal using this component.
    • If you double click it then its properties will open up where you can change the frequency as shown in below figure:
    • You can see in the above figure that I have setted the Clock Frequency to 2000 Hz.
    • Now, let's design the programming code for this project. So, paste the below code in your Arduino software:
    #include <LiquidCrystal.h>
    
    LiquidCrystal lcd(13,12,11,10,9,8);
    
    long freq, tempo;
    int pulsos;
    boolean pulso;
    void setup() {
      pulso=HIGH;
      pinMode(2,INPUT);
      lcd.begin(20, 4);
      lcd.setCursor(0,0);
      lcd.print("Frequency =");
      lcd.setCursor(1,2);
      lcd.print("www.TheEngineering");
      lcd.setCursor(4,3);
      lcd.print("Projects.com");
    }
    
    void loop() {
      tempo = millis();
      if(digitalRead(2)==HIGH)
      {
        if(pulso==HIGH)
        {
          pulsos = pulsos + 1;
        }
    
        pulso=LOW; 
    
      }
      else{
        pulso=HIGH;
      }
    
      if(tempo%2000==0){
        freq = pulsos/2;
        lcd.setCursor(12,0);
        lcd.print(freq);
        lcd.print("Hz");
        pulsos=0;  
      }
    }
    • Now using the above code, get your hex file from Arduino software and upload it in your Proteus software.
    • Now once you are done then run your simulation and if everything goes fine then you will get results as shown in below figure:
    • Now you can see the LCD is showing the same frequency as we set in the properties of the frequency meter.
    • The code is quite simple, I don't think it needs any explanation but if you get into sme trouble then ask in comments.
    • The below video will show you this project in detail:
    So, that's all for today. I hope now you know How to measure frequency using Arduino. So, will meet you guys in the next tutorial. Till then take care !!! :)

    DS1307 Arduino based Digital Clock in Proteus

    Hello everyone, today I am going to share a complete project which is DS1307 Arduino based digital Clock in Proteus ISIS. In this project, I have designed a digital clock using Arduino UNO and DS1307 RTC Module. So, first of all, if you haven't yet installed then, you should install Arduino Library for Proteus using which you will be able to easily simulate Arduino baords in Proteus. Along with Arduino Library you will also need to install DS1307 Library for Proteus, which I have shared in my previous post as we are gonna use this RTC Module DS1307 for designing our digital clock.

    So, now I hope that you have installed both these libraries successfully and are ready to design this DS1307 Arduino based Digital Clock. I have given the Simulation and Code for download below but as I always advise, don't just download the files. Instead design your own simulation and try to write your own code. In this way, you will learn more out of it. So, let's get started with DS1307 Arduino based Digital Clock in Proteus ISIS:

    DS1307 Arduino based Digital Clock in Proteus

    • You can download the complete Proteus Simulation along with Arduino Code by clicking the below button.
    • You will also need DS1307 Library for Arduino, which is also available in this package.

    Download Project Files

    • Now, let's get started with designing of this DS1307 Arduino based Digital Clock.
    • So, first of all, design a circuit in Proteus as shown in below figure:
    • You can see in the above figure that I have used Arduino UNO along with RTC module, LCD and the four buttons.
    • These four buttons will be used to change the year,date etc as mentioned on each of them.
    • Now here's the code for DS1307 Arduino based Digital Clock.
    #include <LiquidCrystal.h>
    #include <DS1307.h>
    #include <Wire.h>
    
    LiquidCrystal lcd(13,12,11,10,9,8);
    
    int clock[7];
    
    void setup(){
    for(int i=3;i<8;i++){
     pinMode(i,INPUT); 
    }
    
    lcd.begin(20,2);
    DS1307.begin();
    DS1307.setDate(16,4,7,0,17,50,04);//ano,mes,dia,semana,horas,minutos,segundos
    }
    
    void loop(){
    DS1307.getDate(clock);
    
    lcd.setCursor(0,1);
    lcd.print("Time: ");
    Print(clock[4]);
    lcd.print(":");
    Print(clock[5]);
    lcd.print(":");
    Print(clock[6]);
    lcd.setCursor(0,0);
    lcd.print("Date: ");
    Print(clock[1]);
    lcd.print("/");
    Print(clock[2]);
    lcd.print("/");
    lcd.print("20");
    Print(clock[0]);
    
    if(digitalRead(7)){
     clock[5]++;
     if(clock[5]>59) clock[5]=0;
     DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]);
     while(digitalRead(7));
    }
    
    if(digitalRead(6)){
     clock[4]++;
     if(clock[4]>23) clock[4]=0;
     DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]);
     while(digitalRead(6));
    }
    
    if(digitalRead(5)){
     clock[2]++;
      if(clock[2]>31) clock[2]=1;
     DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]);
     while(digitalRead(5));
    }
    
    if(digitalRead(4)){
     clock[1]++;
     if(clock[1]>12) clock[1]=1;
     DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]);
     while(digitalRead(4));
    }
    
    if(digitalRead(3)){
     clock[0]++;
     if(clock[0]>99) clock[0]=0;
     DS1307.setDate(clock[0],clock[1],clock[2],0,clock[4],clock[5],clock[6]);
     while(digitalRead(3));
    }
    
    
    delay(100);
    }
    
    void Print(int number){
    lcd.print(number/10);
    lcd.print(number%10);
    }
    • Now get your hex file from Arduino software and then upload it in your Proteus software.
    • Now run your simulation and if everything goes fine, then it will look like something as shown in below figure:
    • Now you can see its today's date in the LCD and the same is shown over on the small pop up of DS1307 Clock.
    • Now the time will start on ticking and the buttons will used to change the minutes hours etc.
    • You will get the better demonstration of this project in the below video.
    So, that's all for today. I hope this projects DS1307 Arduino based Digital Clock will help you in some way. So see you in next post.

    Display ADC value on LCD using Arduino

    Hello friends, hope you all are fine and having good life. In today's project, we will see how to display ADC value on LCD using Arduino in Proteus ISIS. Its quite a simple project in which we are gonna measure the voltage of ADC pins and then will display them over to LCD. The microcontroller I am using in this project is Arduino. The simulation is designed in Proteus ISIS. IF you are working on PIC Microcontroller then you should have a look at How to Display ADC value on LCD using PIC Microcontroller in Proteus ISIS.

    Arduino has 10 bit ADC pins so whenever you apply voltage on these pins it will give you a value ranging from 0 to 1023 depending on the voltage provided. One can easily get this value using a simple function in Arduino analogRead(); but the real problem is to convert this analog value into the actual voltage present on the pin. Suppose you are using A0 pin of arduino and you are providing 3.3V over to this pin, now when you use this analoagRead() function then it will give you some value say 543, but you wanna know what's the actual voltage at this pin which is 3.3V so now converting this 543 to 3.3 is a bit tricky part. It's not difficult but involves a little calculations, which I am gonna cover today in detail. Before going any further, make sure you have already installed the Arduino Library For Proteus, if not then first do it because without this library you won't be able to use Arduino board in Proteus. So, let's get started with How to Display ADC value on LCD using Arduino.

    Display ADC value on LCD using Arduino in Proteus ISIS

    I have divided this tutorial on How to Display ADC value on LCD using Arduino in few steps, follow these steps carefully and if you get into some trouble then ask in comments and I will try my best to resolve them, all the materials are provided at the end of step 1 for download but I suggest that you design your own so that you do mistakes and learn from them. Moreover, you should also have a look at these Arduino Projects for Beginners. Anyways, let get started:

    Step1: Circuit Designing in Proteus
    • First of all, I have designed a circuit in Proteus for Displaying ADC value on LCD using Arduino.
    • In this circuit, I have used two transformers which I have named as Potential Transformer and Current Transformer. I am supplying 220V to these transformers which is then converted into 5V.
    • I have set the turn ratio of these transformers such that they give maximum 5V at the output.
    • Now,rest of the circuit is simple, I have just connected the LCD with Arduino so that we could display these ADC value over to LCD.
    Note:
    • Here's the circuit diagram of displaying ADC value on LCD using Arduino in Proteus ISIS:
    • You can download the Proteus Simulation and the Arduino hex file for Displaying ADC value on LCD using Arduino by clicking on below button:

    Download Proteus Simulation and Arduino Hex File

    • It's quite simple and self explanatory. After designing the circuit diagram, now let's move to second step, which is code designing for Displaying ADC value on LCD using Arduino.
    Step 2: Arduino Code Designing
    • Now copy the below code and paste it into Arduino software. Compile your code and get the Arduino hex file.
    • If you dont know How to get the hex file from Arduino then read Arduino Library for Proteus, I have explained it in detail there.
    #include <LiquidCrystal.h>
    #define NUM_SAMPLES 10
    
    int sum = 0;
    unsigned char sample_count = 0;
    float voltage = 0.0;
    
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    const int PT = A0;
    const int CT = A1;
    float Cur;
    float Vol;
    float Power;
    
    void setup() {
    // set up the LCD's number of columns and rows:
    lcd.begin(20, 4);
    // Print a message to the LCD.
    lcd.setCursor(6,1);
    lcd.print("Welcome To");
    lcd.setCursor(5,2);
    lcd.print("Energy Meter");
    //delay(5000);
    lcd.clear();
    
    Constants();
    }
    
    void loop() {
    lcd.setCursor(0, 2);
    ShowVoltage(9, 0, PT);
    Vol = voltage;
    ShowVoltage(9, 1, CT);
    Cur = voltage;
    Power = Vol * Cur;
    lcd.setCursor(7,2);
    lcd.print(Power);
    }
    
    void Constants()
    {
    lcd.setCursor(0,0);
    lcd.print("Voltage: ");
    lcd.setCursor(0,1);
    lcd.print("Current: ");
    lcd.setCursor(0,2);
    lcd.print("Power: ");
    lcd.setCursor(14,0);
    lcd.print("V");
    lcd.setCursor(14,1);
    lcd.print("A");
    lcd.setCursor(12,2);
    lcd.print("W");
    }
    
    void ShowVoltage (int x,int y, unsigned int value)
    {
    while (sample_count < NUM_SAMPLES)
    {
    sum += analogRead(value);
    sample_count++;
    delay(10);
    }
    
    voltage = ((float)sum / (float)NUM_SAMPLES * 5.015) / 1024.0;
    lcd.setCursor(x, y);
    lcd.print(voltage);
    sample_count = 0;
    sum = 0;
    }
    • The code is quite simple and self explanatory, the only difficulty is in ShowVoltage function. In this function, I have first taken an average of 10 ADC values and after that I have applied a simple formula over it and then it will start start giving the voltage value which I have simply displayed over the LCD.
    • Now everything's done, so Get your Hex File from Arduino Software and let's check the results whether it displayed ADC value on LCD using Arduino or not
    Step 3: Result
    • We have designed the electronic circuit in Proteus and have also designed our code and uploaded the hex file in Arduino.
    • Now press start button and you will see something like this:
    • Now if you compare the voltages in voltmeter and on LCD, you can see they are exactly the same. You can check the value of variable resistor and the values in LCD will also change as the voltage in voltmeter change.
    That's all for today, hope I have conveyed some knowledge today and now you can easily Display ADC value on LCD using Arduino. In the next post we will explore more Arduino features. Till then take care and have fun !!! :)
    Syed Zain Nasir

    I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

    Share
    Published by
    Syed Zain Nasir