Alexandria University
Faculty of Engineering
Electrical Engineering Department
3rd. year communications
EE345 - Microprocessors-1
23/01/2021
                      Microprocessor Project
                  Using NodeMCU with MicroPython
                     Team 22                       ID
           Abanoub Victor Mikhail Fahim             8
       Muhammed Alaa Mustafa Khalil Haikal         185
           Mahmoud Fawzy Taha-Elaraby              202
       Mahmoud Muhammed Abd-ElMeguid               205
            Myar Saber Fahmy Saber Gad             234
                                                         1
                                                         Page
Introduction
This project is a made using NodeMCU board with ESP8266
Microprocessor with the software of MicroPython downloaded on it.
The function of the project is a very simple counter:
We have a 7-segment connected to the board with 3 bush buttons.
  1- The first is to increment the number displayed on the segment,
     and when the number is 9 it returns to 0.
  2- The second is to decrement the number displayed on the
     segment, and when the number is 0 it returns to 9.
  3- The third is to reset the number displayed on the segment to 0.
And throughout the board’s Wi-Fi we will open a web server from any
connected device (Mobile, Laptop, ….) which has 3 buttons as same as
the physical board.
and also there are an android mobile application that skips all the IP
issues and will be able to do changes to the board once the phone is
connected to the Wi-Fi of the microprocessor.
1-The Hardware part
                                                                         Page
a) The Board (NodeMCU ESP8266)
NodeMCU is an open-source Lua based
firmware and development board
specially targeted for IoT based
Applications. It includes firmware that
runs on the ESP8266 Wi-Fi SoC from
Espressif Systems, and hardware which is
based on the ESP-12 module.
   Small Sized module to fit smartly inside your IoT projects.
   USB-TTL based on CP2102 is included onboard, Enabling Plug n Play.
   Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106
   Operating Voltage: 3.3V
   Input Voltage: 7-12V
   Digital I/O Pins (DIO):
    16
   Analog Input Pins
    (ADC): 1
   UARTs: 1
   SPIs: 1
   I2Cs: 1
   Flash Memory: 4 MB
   SRAM: 64 KB
   Clock Speed: 80 MHz
   PCB Antenna
                                                                         3
b) The Circuit Schematic
                                                                         Page 
The circuit is mainly consists of 3 main parts:
 The NodeMCU Board /ESP8266 Microprocessor:
  The main core unit which will take the code, compile it, generate the
  output voltage, deal with the input interrupts and connect with Wi-Fi
    - We will connect the Board using an USB data cable which will
    transfer both power and data to the microprocessor form the PC and
    transfer power only when it is connected to a proper power supply
    unit like the phone charger.
    - We could also connect power to the Board using GND & 3.3V Pins.
    -The pins we will mainly use will be:
    As output (16, 2, 12, 14, 4, 15, 13) [7 pins for 7 LEDs of the segment]
    As input (10 <increment>, 3 <decrement>, 0 <reset>)
                                                                              4
 7-segment display and 7 resistors:
                                                                              Page
  - The seven segment has 10 pins: 7 for the 7 LEDs (from a to g),
  1 for decimal point, and 2 for power (common anode/cathode).
  - We will connect the 7 LEDs pins each with a resistor and the other
  resistor terminal to the o/p pins of the
  Board in this order:
  (a,16) (b,2) (c,12) (d,14) (e,4) (f,15)
  (g,13)
  -the common anode pins will be
  connected to 3.3V pin
   (in case of common cathode, it will be
  connected to the GND pin).
 3 push down switches with 3 pull up resistors:
  Each switch/button will be connected to the GND pin from an end,
  the other will be connected to the i/p pin of the board and to a
  resistor connected to the 3.3V pin to work as a pull up resistor.
2-The Software Part:
                                                                         Page
a) Micro python Programming Language
MicroPython is a lean and efficient implementation of the Python 3
programming language that includes a small subset of the Python
standard library and is optimized to run on microcontrollers and in
constrained environments.
MicroPython is packed full of advanced features such as an interactive
prompt, arbitrary precision integers, closures, list comprehension,
generators, exception handling and more. Yet it is compact enough to
fit and run within just 256k of code space and 16k of RAM.
b) uPyCraft IDE
uPyCraft, an IDE specially designed for micro python, working with a
series of operation systems, e.g., Windows XP, Windows 7, Windows 8,
Windows 10, MAC OSX 10.11 and above. Moreover, uPyCraft is free
from installation for all systems, so it is easy to use.
Features:
1. Supports update online.
2. Supports both windows system and mac system.
3. Extremely simplification in designing, easy to use.
4. With built-in examples of different boards, cost effective.
5. Supports on-line updating of boards.
6. Provides technical supports in GitHub.
                                                                         6
c) The Used Steps and Operation
                                                                         Page
1- Download Python (latest version 3.9.0).
2- Download Micro Python.
3- Download .bin firmware that is used with ESP8266.
4- Download upycraft.
5- Install esptool using cmd.
6- Connect upycraft with the board.
7- Writing the code on upycraft
8- Erase the flash memory of the board.
9- Download the new firmware.
10- Burn the code.
11- When the code is successfully downloaded, we notice that the
   segment is initialized to zero.
12- We can click on the buttons and it will work.
13- The board generates a Wi-Fi point which we can connect the
   phone to it using the password (name and password are in the code
   and we can change them easily)
14- If we typed the IP address appeared
   on the PC screen during burning the
   code in the phone’s web browser, a web page appears with 3
   buttons on it and we can change the segment display with them
15- If the phone has the application mentioned in page 2, if we open
   it after connecting the 3 buttons will appear and we we can change
   the segment display with them just like the web page.
References
                                                                        7
                                                                        Page
1-   Python Programming language
     https://www.python.org/downloads/
2-   The data all about the microprocessor
     https://www.espressif.com/en/products/modules/esp8266
3-   Micro python site where we get all the data and codes
     https://micropython.org
4-   Firmware for Generic ESP8266 module
     https://micropython.org/download/esp8266/
5- The site where we downloaded upycraft IDE to load the code
   on to the board.
   https://randomnerdtutorials.com/install-upycraft-ide-
   windows-pc-instructions/
6-   Circuit diagram online draw tool (for circuit schematic)
     https://www.circuit-diagram.org/editor/
                                                                8
                                                                Page