【ESP32-S】micropython学习记录

固件烧录

引脚

本次入门学习使用的是NODEMCU-32,在安信可官网采购,自带USB转TTL驱动

img

固件

固件下载地址:
固件下载链接:[link]:(https://micropython.org/download/esp32/).

ESP-IDF V4.0 V3.0两种版本,首先下载V4.0不带SPIram的版本测试

image-20210328194418674

下载固件

使用软件:FLASH_DOWNLOAD_TOOLS_V3.6.4
选择ESP32 DOWNLOADTOOL选项
image-20210328223943658

烧录配置:
注意烧录地址为0x1000,选中DoNotChgBin选项
image-20210328194647593

1、先点击ERASE擦除设备(必须!,否则会报错)

2、点击START下载,等待下载完成

下载完成后,连接串口,复位芯片即可看到信息

image-20210328195423571

改变主频

import machine

machine.freq()          # get the current frequency of the CPU
machine.freq(240000000) # set the CPU frequency to 240 MHz

连接WIFI

使用自己的SSID和password替代相应字符

def do_connect():
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('SSID', 'password')
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())

显示CPU温度

import esp32
def Temperature():
    Farenheit = esp32.raw_temperature()
    centigrade = (Farenheit-32)/1.8
    return centigrade

UART测试

from machine import UART
uart1=UART(1)
uart2=UART(2)

UART0

用于调试

>>> uart0=UART(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: UART(0) is disabled (dedicated to REPL)

image-20210328204747588

UART1

image-20210328204900378

短接16/17后,运行会出现错误:

image-20210328205154172

>>> uart1.write('a')
Guru Meditation Error: Core  0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x401576fc: 0008e0d7 ffaf0000 ffffffff
Core  0 register dump:
PC      : 0x40157703  PS      : 0x00060031  A0      : 0x00000001  A1      : 0x3ffbe410  
A2      : 0x3ffbd6ac  A3      : 0x3ffbf774  A4      : 0x3ffbf770  A5      : 0x00000001  
A6      : 0x0000007f  A7      : 0x00000000  A8      : 0x80157700  A9      : 0x3ffbe3f0  
A10     : 0x3ffba780  A11     : 0x3ffba88c  A12     : 0x3ffbe424  A13     : 0x3ffba864  
A14     : 0x00000000  A15     : 0x3ffe5605  SAR     : 0x0000001f  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0xffffffff  

Backtrace:0x40157700:0x3ffbe410 0xfffffffe:0x3ffbe470 |<-CORRUPTED


ELF file SHA256: 56a3348b1921e984

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:5636
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0
MicroPython v1.14 on 2021-03-28; ESP32 module with ESP32
Type "help()" for more information.

UART2

image-20210328204824730

短接P16/P17后,测试UART2引脚

uart2实测可以使用

with ESP32
Type “help()” for more information.




### UART2

[外链图片转存中...(img-kHknIvwk-1616942567469)]

短接P16/P17后,测试UART2引脚

uart2实测可以使用

![image-20210328205259302](https://img-blog.csdnimg.cn/img_convert/4bd7e60b9f8b9f4bbd4e526a2f6f1c0b.png)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值