GithubHelp home page GithubHelp logo

esp32-simple-counter's Introduction

ESP32 Simple Counter with Micropython

An exploration and entry point project to Micropython.


Table of Content


Problem Statement

You are to use an ESP32 module and program it using Micropython in order to build a simple one-digit counter. The user should be able to control the counter through two different methods concurrently:

  • Direct Control (Push Buttons).
  • Wireless Control (Mobile Application).

For the direct control method, there should be three push buttons to control the counter. The three buttons should do increment, decrement and reset operations. Also, there should be a seven segment display to display the current counter value.

For the wireless Control, the esp32 should broadcast its own wifi network (being in the "Access Point" operation mode). Then, the user should be able use his phone to join this WIFI network (access point) and use an application (on his phone) to control the counter and display the current value of the counter. Through the application, the user can do increment, decrement and reset operations.

Note: the current value of the counter has to be same (synchronized) on both the seven segment display and the mobile application at all time. This implies that, if the counter value is changed through push buttons, the value on the application should be automatically updated. Similarly, if the counter value is changed through the application, it should be updated on the seven segment display automatically.


Getting Started

Depending on your background and previous knowledge, what you need to get started may vary. However, I assume you are like me; diving into Micropython for the first time, but having strong basic knowledge in Embedded Systems.

In all, I found the Micropython Documentation extremely helpful in all aspects. A great starting off point was the Quick Reference For The ESP32.

  • To get the firmware on my ESP32, I easily followed up this simple tutorial.
  • I used Tera Term as the serial terminal to communicate with the ESP32.
  • Writing the code, I found those documentation pages so helpful:
    • To deal with pins for input and output, Here.
    • To control the WIFI module and configure the network, Here.
    • Sockets are needed for communication in the Wireless Control , Here.
    • Wireless control depends on the existence of a web server. this tutorial is nice ❤️.

Software Architecture

After finding comfort in using micropython and communicating with the ESP32 through the serial terminal program, comes the time of thinking about the appropriate software architecture.

To approach the problem, I tried to create a script for each control method separately. So, I build:

  • the local_control.py script to implement the direct control method using push buttons and seven segment display. In that script, I tried to achieve the objective using only interrupts attached to the push buttons.
  • the wifi_control.py script to implement the wireless control method. Here, I used the super-loop architecture to wait for and handle the requests coming from the mobile application.

For the two scripts being built on interrupts and super-loop, merging them to create main.py was a trouble-free process. Now, main.py can handle both control methods smoothly. The final architecture is a super-loop cut by interrupts. The super-loop is serving coming requests and the interrupts are serving button presses.


Hardware Layout

Connecting push buttons to the ESP32 is a straight forward process. However, there can be an argument about connecting the seven segment display. One can suggest connecting the display directly to the ESP32. On the other hand, I saw that using a decoder in between the ESP32 and the display was far better in terms of safety and the number of ESP32 pins needed to control the display.

We used the 74LS47N BCD to seven segment decoder. We used common anode display.

This schematic was done by my teammate Seif

NOTE: the ESP32 is powered through the USB. The rest of the circuitry (decoder and display) are powered by external 5V power supply.


Mobile Application

The application was done by my teammate Sief. More info should be found on his repository.


Tutorials and Videos

As always, tutorials can be found on my YouTube Channel as well as my Facebook Page.

The project playlist includes following videos:

  • Demo: Casual video showing the project during development.
  • Code Hints: Trying to provide help in form of hints and useful resources for fellow colleagues.
  • Button Debouncing: Explaining the phenomena of button bouncing and how to deal with it in the context of our project.
  • Web Server: As some colleagues struggled in this part, this video with an attempt to help and guide them.
  • Code Explanation: Line by line explanation for my final code.
  • Final Demo: Showing the project on its final form and represent all features.

esp32-simple-counter's People

Contributors

alphaarslan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.