Git Product home page Git Product logo

esp32-thonny-ampy's Introduction

Basic Introduction to an esp32 Board

A walkthrough of using Thonny and Ampy to connect to an ESP32 board for the first time.

ESP32 Drivers

Download the ESP32 Drivers and walk through the installation process. Connect your ESP32 board using a USB cable.

You will need to know the port name your board is connected to. Run the following command:

ls /dev/tty.*

The command will list your existing ports:

/dev/tty.Bluetooth-Incoming-Port	/dev/tty.SoundcoreLifeQ35-Spp1
/dev/tty.LEGOHubA8E2C19B5757-Ser	/dev/tty.usbserial-14220
/dev/tty.SoundcoreLifeQ35-OTA1

If possible, determine which port is your ESP32 board and copy it for later.

If you are not sure which one is your board, disconnect your board, then run the list command again. Take note as to which port has been removed from the list. This is the port we will need for later. Mine port is:

/dev/tty.usbserial-14220

LED

If your ESP32 board has an onboard LED, you can likely use pin two. If not, you will need to connect the circuit below and change the pin to 22:

LED Circuit

Then create the following Micropython program using your favourite IDE. I would recommend VSCode or Thonny.

import time
from machine import Pin

led = Pin(2, Pin.OUT)

while True:

    led.value(1)
    time.sleep(1)

    led.value(0)
    time.sleep(1)

    print.write("Working...")

Next you will need to upload your program to your ESP32 board. This can be done using either of the two methods below:

Thonny

Connect your board if it is not connected. Then follow these steps:

  1. Download the Thonny IDE

  2. In the main menu, click Thonny and then Preferences...

  3. Click Interpreter

  4. From the first dropdown, select Micropython (ESP32)

  5. From the second dropdown, choose your port or the Try to detect port automatically option

    Thonny Preferences

  6. Open your LED program

  7. Click on the green play botton to uplaod your code to your ESP32 board and execute

Ampy

A second option is to use the IDE of your choice and then use the Terminal and a small Python module called Ampy to upload and execute.

This process will assume you have Python and PIP instapped.

Python

Note that a Mac usually comes with Python installed. My Mac has Python 2 installed, so I used Brew to install Python 3. Run the following command to see what version of Python you have installed:

python --version

If the response is Python 2, try this command:

python3 --version

If this does not work, you will need to install Python 3 using Brew.

PIP

Check that you have PIP installed. Try the following commands:

pip --version
pip3 --version
python2 -m pip --version

If you no not have PIP installed, you can install it using Python.

Ampy

Install Ampy using the format that best worked for you, use one of the following:

pip install adafruit-ampy
pip3 install adafruit-ampy
python3 -m pip install adafruit-ampy

Then using the Terminal, navigate to the same folder as your led.py file and run the following command:

ampy --port /dev/tty.usbserial-14210 run led.py

You will need to replace the port name with your port name.


Repo Resources

esp32-thonny-ampy's People

Contributors

codeadamca avatar

Watchers

 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.