Python Archives - Engineers Garage https://www.engineersgarage.com/tutorials/python/ Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News Tue, 22 Oct 2024 07:21:01 +0000 en-US hourly 1 https://www.engineersgarage.com/wp-content/uploads/2019/08/cropped-eg-favicon-32x32.png Python Archives - Engineers Garage https://www.engineersgarage.com/tutorials/python/ 32 32 RPi Python Programming 06: Python basics https://www.engineersgarage.com/rpi-python-programming-06-python-basics/ https://www.engineersgarage.com/rpi-python-programming-06-python-basics/#respond Mon, 21 Oct 2024 12:06:01 +0000 https://www.engineersgarage.com/?p=60504 In the previous tutorial, we discussed the Python language, its applications, implementations (including CPython, Jython, IronPython, and PyPy), and IDEs. We also learned how to write Python scripts and modules, and how to run Python scripts through an integrated development environment (or IDLE) and a Bash shell. Before we jump to controlling hardware via Python…

The post RPi Python Programming 06: Python basics appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/rpi-python-programming-06-python-basics/feed/ 0
RPi Python Programming 05: Introduction to Python https://www.engineersgarage.com/rpi-python-programming-05-introduction-to-python/ https://www.engineersgarage.com/rpi-python-programming-05-introduction-to-python/#respond Mon, 21 Oct 2024 12:05:41 +0000 https://www.engineersgarage.com/?p=60477 In the previous tutorial, we successfully set up a Raspberry Pi (RPi) Linux desktop. Now let’s learn Python.  We could start with how to control the hardware by using Python scripts, but that would defeat the purpose of using Raspberry Pi and a Very-High-Level-Language (VHLL) — such as Python — to control electronics. Certainly, you can…

The post RPi Python Programming 05: Introduction to Python appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/rpi-python-programming-05-introduction-to-python/feed/ 0
How to use Raspberry Pi camera module with Python https://www.engineersgarage.com/raspberry-pi-camera-python/ https://www.engineersgarage.com/raspberry-pi-camera-python/#respond Wed, 21 Jun 2023 17:59:58 +0000 https://www.engineersgarage.com/?p=64805 One of the main attractions of the Raspberry Pi platform is its camera module. At present, Raspberry Pi Foundation offers three camera modules: • Camera Module 2 • Camera Module 2 NoIR • Raspberry Pi High-Quality Camera The camera module 2 is a replacement for the original camera module in April 2016. The V2 module…

The post How to use Raspberry Pi camera module with Python appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/raspberry-pi-camera-python/feed/ 0
RPi Python Programming 10: Object-oriented Python https://www.engineersgarage.com/rpi-python-programming-10-object-oriented-python/ Wed, 21 Jun 2023 17:28:00 +0000 https://www.engineersgarage.com/?p=60634 In the previous tutorial, we learned about the sequences and unordered collections in Python, including the operations, functions, and methods applicable to them. However, there can be more complex data structures in an application, which are known as user-defined classes and objects. Any application uses data (values/objects/user-defined classes/objects) and code behavior (how the data is…

The post RPi Python Programming 10: Object-oriented Python appeared first on Engineers Garage.

]]>
RPi Python Programming 11: Python GUI with Tkinter https://www.engineersgarage.com/rpi-python-programming-11-python-gui-with-tkinter/ Wed, 21 Jun 2023 17:27:27 +0000 https://www.engineersgarage.com/?p=60665 In the previous tutorial, we learned about the object-oriented features of Python, which are important for organizing code and structuring our applications. Now, let’s discuss how to design graphic interfaces in Python. Embedded applications developed on microcontrollers typically have LEDs, character LCDs, or small graphic LCDs as display devices. However, these displays do not have…

The post RPi Python Programming 11: Python GUI with Tkinter appeared first on Engineers Garage.

]]>
RPi Python Programming 12: Tkinter and TTK widgets https://www.engineersgarage.com/rpi-python-programming-12-tkinter-and-ttk-widgets/ Wed, 21 Jun 2023 17:26:53 +0000 https://www.engineersgarage.com/?p=60778 In the previous tutorial, we learned about the window widget in Tkinter and designed a blank GUI main window (which is not a child to any other window in the GUI application). Child windows serve as a container for other widgets There is no point of blank windows so there must be other widgets included…

The post RPi Python Programming 12: Tkinter and TTK widgets appeared first on Engineers Garage.

]]>
RPi Python Programming 08: Python lists and byte arrays https://www.engineersgarage.com/articles-raspberry-pi-python-lists-byte-arrays-methods-operations/ Wed, 21 Jun 2023 17:21:43 +0000 https://www.engineersgarage.com/?p=60555 In the previous tutorial, we learned about basic syntax and several elements of Python’s language. Python offers six types of sequences: strings, bytes, byte arrays, range, tuples, and lists. Importantly, the strings, bytes, range, and tuples are immutable sequences that cannot be modified once defined. It’s only possible to create or destroy these sequences. This…

The post RPi Python Programming 08: Python lists and byte arrays appeared first on Engineers Garage.

]]>
RPi Python Programming 09: Python sets and dictionaries https://www.engineersgarage.com/rpi-python-programming-09-python-sets-and-dictionaries/ Tue, 21 Mar 2023 17:29:17 +0000 https://www.engineersgarage.com/?p=60601 In the previous tutorial, we learned about manipulating data values in lists and byte arrays. Python also has mutable unordered collections, including sets and dictionaries. Let’s review these two and learn how to manipulate the data values/objects in sets and dictionaries. Sets Sets are unordered mutable collections of items. The items in a set can…

The post RPi Python Programming 09: Python sets and dictionaries appeared first on Engineers Garage.

]]>
How to build a MicroPython-based sensorless, weather station https://www.engineersgarage.com/how-to-build-a-micropython-based-sensorless-weather-station/ https://www.engineersgarage.com/how-to-build-a-micropython-based-sensorless-weather-station/#respond Sun, 12 Mar 2023 16:30:59 +0000 https://www.engineersgarage.com/?p=78272 Is it possible to update the weather on an embedded device or a wearable without interfacing with any temperature or humidity sensor? With Internet of Things (IoT) access, devices can connect to a variety of web services with the help of APIs and extract several useful insights and information through simple HTTP requests. In response,…

The post How to build a MicroPython-based sensorless, weather station appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/how-to-build-a-micropython-based-sensorless-weather-station/feed/ 0
How to use MicroPython’s watchdog timer in ESP8266 and ESP32 https://www.engineersgarage.com/micropython-esp8266-esp32-watchdog-timer-wdt/ https://www.engineersgarage.com/micropython-esp8266-esp32-watchdog-timer-wdt/#respond Fri, 20 Jan 2023 00:52:05 +0000 https://www.engineersgarage.com/?p=76968 A watchdog timer is an internal or external timer that monitors a microcontroller’s program to ensure the application remains operative without failure. It serves as a safety feature in critical applications by monitoring the microcontroller’s output signal. The watchdog can operate in two modes:  Timeout mode – the timer establishes the microcontroller is not working properly if it…

The post How to use MicroPython’s watchdog timer in ESP8266 and ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-esp32-watchdog-timer-wdt/feed/ 0
MicroPython: How to program a real-time clock (RTC) in ESP8266 and ESP32 https://www.engineersgarage.com/micropython-esp8266-esp32-rtc-utc-local-time/ https://www.engineersgarage.com/micropython-esp8266-esp32-rtc-utc-local-time/#respond Fri, 20 Jan 2023 00:51:18 +0000 https://www.engineersgarage.com/?p=76971 A real-time clock (RTC) is a computer clock to keep time and is one of the more popular microcontroller features. Microcontrollers without a built-in RTC require an external RTC chip for keeping time. Typically, mid-segment to high-end microcontrollers have a built-in RTC because time-keeping is necessary for several embedded applications.  RTCs count seconds, minutes, hours,…

The post MicroPython: How to program a real-time clock (RTC) in ESP8266 and ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-esp32-rtc-utc-local-time/feed/ 0
MicroPython based online weather station on ESP8266 and ESP32 https://www.engineersgarage.com/micropython-esp8266-esp32-online-weather-station/ https://www.engineersgarage.com/micropython-esp8266-esp32-online-weather-station/#respond Fri, 20 Jan 2023 00:50:29 +0000 https://www.engineersgarage.com/?p=77022 MicroPython is one of the best microcontroller firmware that supports a variety of embedded platforms. The WiFi development boards like ESP8266 and ESP32 are among the MicroPython-supported ports. With MicroPython, it is extremely simple to implement top-notch IoT applications.  MicroPython has wide support for network programming along with implementing all basic hardware functions. It combines…

The post MicroPython based online weather station on ESP8266 and ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-esp32-online-weather-station/feed/ 0
How to animate text on SSD1306 using MicroPython and ESP8266 https://www.engineersgarage.com/micropython-esp8266-ssd1306-text-animations/ https://www.engineersgarage.com/micropython-esp8266-ssd1306-text-animations/#respond Wed, 26 Oct 2022 00:00:04 +0000 https://www.engineersgarage.com/?p=77451 Organic light-emitting diode or OLED displays have become essential for many embedded devices. OLEDs are considered one of the highest-quality displays to showcase device information.  Typically, embedded devices use single-screen graphics, but complex interfaces are required when there are several user interactions. For example, such interfaces might use menus or other graphical navigation. Adding a…

The post How to animate text on SSD1306 using MicroPython and ESP8266 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-ssd1306-text-animations/feed/ 0
MicroPython: How to write and read text files on a MicroSD card using ESP32 https://www.engineersgarage.com/micropython-esp32-microsd-card/ https://www.engineersgarage.com/micropython-esp32-microsd-card/#respond Thu, 29 Sep 2022 01:10:27 +0000 https://www.engineersgarage.com/?p=77291 Data logging is an integral part of many embedded projects. Typically, data logging is used to record sensor readings, with or without a timestamp. For example, many IoT applications use data logging to store network changes or data for troubleshooting or verification.  The ideal way to log data locally is using an SD or MicroSD…

The post MicroPython: How to write and read text files on a MicroSD card using ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp32-microsd-card/feed/ 0
ESP8266/ESP32-based WiFi access point using MicroPython https://www.engineersgarage.com/esp8266-esp32-based-wifi-access-point-using-micropython/ https://www.engineersgarage.com/esp8266-esp32-based-wifi-access-point-using-micropython/#respond Fri, 29 Jul 2022 17:56:26 +0000 https://www.engineersgarage.com/?p=76941 Many IoT applications are controlled with the help of a webpage or an HTML website running within a Local Area Network (LAN) or Wireless Local Area Network (WLAN). Some examples of such IoT applications include home automation, office automation, and smart farming. The HTML webpage or website controlling the things is hosted on a microcomputer…

The post ESP8266/ESP32-based WiFi access point using MicroPython appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/esp8266-esp32-based-wifi-access-point-using-micropython/feed/ 0
Getting started with MicroPython on ESP8266 https://www.engineersgarage.com/micropython-esp8266-esp32-upycraft-ide-getting-started/ https://www.engineersgarage.com/micropython-esp8266-esp32-upycraft-ide-getting-started/#respond Wed, 20 Jul 2022 18:19:10 +0000 https://www.engineersgarage.com/?p=71295 MicroPython is an implementation of Python 3 for microcontrollers. It’s an awesome firmware that combines the powerful features of Python programming language with the low-level access of microcontrollers. Following is a list of microcontrollers supported by the MicroPython framework. Arch Mix, Actinius icarus, Arduino Nano RP2040 Connect, Arduino Primo, B_L072Z_LRWAN1, B_L475E_IOT01A, blueio_tag_evim, C3 mini, CERB40,…

The post Getting started with MicroPython on ESP8266 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-esp32-upycraft-ide-getting-started/feed/ 0
Using MicroPython SSD1306 driver to interface an OLED display with ESP8266 & ESP32 https://www.engineersgarage.com/micropython-esp8266-esp32-ssd1306/ https://www.engineersgarage.com/micropython-esp8266-esp32-ssd1306/#comments Wed, 20 Jul 2022 18:17:02 +0000 https://www.engineersgarage.com/?p=76534 You’ve likely heard about SSD1306 or SSD1315 organic light-emitting diode (OLED) displays. These monochrome screens are typically in a similar price range as character displays, providing a more aesthetic appeal. More significantly, they provide a truly graphical interface for an embedded device. The OLED displays are available in ready-to-use breakout boards that can easily push…

The post Using MicroPython SSD1306 driver to interface an OLED display with ESP8266 & ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-esp32-ssd1306/feed/ 2
How to use ESP8266’s sleep modes in MicroPython https://www.engineersgarage.com/micropython-esp8266-modem-light-deep-sleep-modes-timer-external-wake-up/ https://www.engineersgarage.com/micropython-esp8266-modem-light-deep-sleep-modes-timer-external-wake-up/#respond Wed, 20 Jul 2022 18:16:29 +0000 https://www.engineersgarage.com/?p=76497 Networking applications consume a lot of power. If such applications are battery-powered, there’s a risk the battery will exhaust because of the high power demands of networking functions. Frequently, power is also wasted in non-essential microcontroller activities. For example, the power might remain on for various built-in peripherals irrespective of their use or relevance in…

The post How to use ESP8266’s sleep modes in MicroPython appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-esp8266-modem-light-deep-sleep-modes-timer-external-wake-up/feed/ 0
MicroPython: Time-related functions, timers & interrupts in ESP8266 and ESP32 https://www.engineersgarage.com/micropython-time-related-functions-timers-interrupts-in-esp8266-and-esp32/ https://www.engineersgarage.com/micropython-time-related-functions-timers-interrupts-in-esp8266-and-esp32/#respond Wed, 20 Jul 2022 18:15:00 +0000 https://www.engineersgarage.com/?p=76493 Timers are one of the common hardware features in all microcontrollers. Timers and timer interrupts are of great use in microcontroller applications. The timer interrupts are often used when precise timing is required without a fraction of error. All MicroPython ports have one or more timers. Some of these timers may be reserved for specific…

The post MicroPython: Time-related functions, timers & interrupts in ESP8266 and ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-time-related-functions-timers-interrupts-in-esp8266-and-esp32/feed/ 0
MicroPython – Reading analog signals in ESP8266 and ESP32 https://www.engineersgarage.com/micropython-reading-analog-signals-in-esp8266-and-esp32/ https://www.engineersgarage.com/micropython-reading-analog-signals-in-esp8266-and-esp32/#respond Wed, 20 Jul 2022 18:14:38 +0000 https://www.engineersgarage.com/?p=76296 The majority of sensors have an analog output.  Few sensors come with a built-in controller and can stream the output measurements over a digital protocol. That is why analog to digital conversion is one of the basic features that every microcontroller/port has. The other basic features include digital input/output, analog output, PWM generation, and serial…

The post MicroPython – Reading analog signals in ESP8266 and ESP32 appeared first on Engineers Garage.

]]>
https://www.engineersgarage.com/micropython-reading-analog-signals-in-esp8266-and-esp32/feed/ 0