本来之前买和另一贴子的esp8266一起买了一块esp32.

现在开发esp的大概有乐鑫的ide以及基于乐鑫定制的、arduino、nodemcu、还有就是现在要讲的micropython.

乐鑫的主要跑ucos,arduino版本顾名思义,nodemcu用lua脚本语言,micropython用定制的python。

每一种都或多或少接触过,偶然的时候在NDIY论坛看到F4跑micropython,用python语言干单片机的活,然后就百度了下。

感觉如果拿来做轻量开发十分方便,比arduino还方便。恰好身边也有人在学python,学好了还可以介绍给他们。


http://www.eeboard.com/evaluation/pyboard/

这个帖子写的是pyboard评测,从中可以看出micropython的特点。


官方自己下的定义:

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems 
https://micropython.org

以下是安装步骤:

先安装esptool.py

pip install esptool.py

没装pip先sudo apt装好pip

然后不知道为什么我默认安装到/home/xxx/.local/bin/这个目录里面了,百度过来都是直接pip好了就能用,然后我locate esptool找到了脚本的位置,

然后在.bashrc里面alias esptool="/home/xxx/.local/bin/esptool.py"然后source一下就行了.

先按照官网说的:

Firmware for ESP32 boards
The following files are daily firmware for ESP32-based boards, with separate firmware for boards with and without external SPIRAM. Non-SPIRAM firmware will work on any board, whereas SPIRAM enabled firmware will only work on boards with 4MiB of external pSRAM. Program your board using the esptool.py program, and put the firmware starting at address 0x1000. For example: esptool.py --chip esp32 --port /dev/ttyUSB1 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin. If you are putting MicroPython on for the first time then you should first erase the entire flash using esptool.py --chip esp32 erase_flash.

清除flash

katachi@katachi-Inspiron-:~/eclipse-workspace/micropython$ esptool --chip esp32 --port /dev/ttyUSB0 erase_flash
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting........__
Chip is ESP32D0WDQ6 (revision )
Features: WiFi, BT, Dual Core
MAC: :ae:a4:3a:1b:9c
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in .6s
Hard resetting via RTS pin...
katachi@katachi-Inspiron-:~/eclipse-workspace/micropython$

然后刷进去:

katachi@katachi-Inspiron-:~/eclipse-workspace/micropython$ esptool --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32spiram--v1.9.4--g5cd2c7f2e.bin
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32D0WDQ6 (revision )
Features: WiFi, BT, Dual Core
MAC: :ae:a4:3a:1b:9c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed bytes to ...
Wrote bytes ( compressed) at 0x00001000 in 60.7 seconds (effective 147.1 kbit/s)...
Hash of data verified. Leaving...
Hard resetting via RTS pin...

刷的是带ram的,但是rst后报错,然后刷了不带ram的就启动了,用串口连接,是一个叫REPL(read evaluate print loop)的交互bash,

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err,
ets_main.c
ets Jun :: rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: , SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:
load:0x3fff0018,len:
load:0x3fff001c,len:
load:0x40078000,len:
load:0x40080400,len:
entry 0x4008114c
I () cpu_start: Pro cpu up.
I () cpu_start: Single core mode
I () heap_init: Initializing. RAM available for dynamic allocation:
I () heap_init: At 3FFAE6E0 len ( KiB): DRAM
I () heap_init: At 3FFC4F48 len 0001B0B8 ( KiB): DRAM
I () heap_init: At 3FFE0440 len 00003BC0 ( KiB): D/IRAM
I () heap_init: At 3FFE4350 len 0001BCB0 ( KiB): D/IRAM
I () heap_init: At len 0000EBB8 ( KiB): IRAM
I () cpu_start: Pro cpu start user code
I () cpu_start: Starting scheduler on PRO CPU.
OSError: [Errno ] ENOENT
MicroPython v1.9.4--g5cd2c7f2e on --; ESP32 module with ESP32
Type "help()" for more information.
>>>

help一下

Welcome to MicroPython on the ESP32!

For generic online docs please visit http://docs.micropython.org/

For access to the hardware use the 'machine' module:

import machine
pin12 = machine.Pin(, machine.Pin.OUT)
pin12.value()
pin13 = machine.Pin(, machine.Pin.IN, machine.Pin.PULL_UP)
print(pin13.value())
i2c = machine.I2C(scl=machine.Pin(), sda=machine.Pin())
i2c.scan()
i2c.writeto(addr, b'')
i2c.readfrom(addr, ) Basic WiFi configuration: import network
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.scan() # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected() # Check for successful connection Control commands:
CTRL-A -- on a blank line, enter raw REPL mode
CTRL-B -- on a blank line, enter normal REPL mode
CTRL-C -- interrupt a running program
CTRL-D -- on a blank line, do a soft reset of the board
CTRL-E -- on a blank line, enter paste mode For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')

esp32-micropython的更多相关文章

  1. 登录华科校园网,我用Socket

    登录华科校园网,我用Socket 导语: 找一个华科学生问一问,学校的网络怎么样?得到的大多数是负面回答.其实不论是从覆盖区域.网络稳定性.还是速度来说,华科做的都还是可以的(24:00断网除外).可 ...

  2. 如何为 esp32 编译和配置及烧写 MicroPython 固件。

    MicroPython 在 esp-idf (esp32) 上编译固件 esp32 编译 micropython 的固件相关的资料应该很多吧,我也会出一篇,但会额外讲一些 linux 的东西的. 资料 ...

  3. ESP32与MicroPython入门-01 搭建开发环境

    ESP32简介 ESP32 是上海乐鑫公司开发的一款比较新的32位微控制器,它集成了WiFi及蓝牙等功能,有着性能稳定.功耗低.价格低廉等特点,非常适用于物联网开发,但也可以作为普通的MCU使用. E ...

  4. esp32驱动SSD1306的oled显示汉字(micropython)

    1.完整源码: 主函数oled.py from ssd1306 import SSD1306_SPI from ssd1306 import SSD1306 import font import ma ...

  5. (2)用Micropython将ESP32数据上云

    之前我们尝试过直接把LED点亮并且闪烁. 今天尝试一下将LED的开关状态上云,并可以通过云来进行数据下发. 数据要上云,首先开发板要联网. 首先我们会用 Python的network 库, 在netw ...

  6. MicroPython的开发板

    比如: pyboard micro:bit ESP8266/ESP32 stm32等等 什么是pyboard? pyboard是官方的MicroPython微控制器板,完全支持软件功能.硬件有: ST ...

  7. micropython驱动sh1106点亮oled

    继上一帖给esp32刷入micropython之后,忍不住给以esp12e也刷了micropython 这里先说一下webrepl: 通过wifi可以和esp8266交互,以及便携的传输文件 首次使用 ...

  8. microPython环境安装及使用

    1.ESP8266_12E(NodeMCU1.0)(AI Thinker)板Arduino IDE环境安装 (1)方法1(自动安装,windows,mac,linux平台都可) http://ardu ...

  9. 说说 MicroPython 的项目整体架构

    今天来说说 MicroPython 的架构情况,如果有必要我会做一些源码分析的文章供大家参考. 先来认识一下 MicroPython 整体情况,可以从软件的角度上去看待,首先我们拿到 MicroPyt ...

  10. Esp32的一些资料链接

    http://wiki.ai-thinker.com/doku.php/utils/esp32_idf_menuconfig   http://wiki.ai-thinker.com/doku.php ...

随机推荐

  1. 盘点 React 16.0 ~ 16.5 主要更新及其应用

    目录 0. 生命周期函数的更新 1. 全新的 Content API 2. React Strict Mode 3. Portal 4. Refs 5. Fragment 6. 其他 7. 总结 生命 ...

  2. pandas replace 替换功能function

    list like replace method dict like replace method regex expression import pandas as pd import numpy ...

  3. java中jdbc源码解读

    在jdbc中一个重要的接口类就是java.sql.Driver,其中有一个重要的方法:Connection connect(String url, java.util.Propeties info); ...

  4. Linux命令行下快捷键

    快捷键 说明 Ctrl+a 切换到命令行开始 Ctrl+e 切换到命令行末尾 Ctrl+c 终止当前命令或脚本 Ctrl+d ①退出当前shell,相当于exit②一个个删除光标后字符 Ctrl+l ...

  5. windows下怎样测试oracle安装是否成功以及在oracle中创建用户并赋予用户权限;和[Err] ORA-65096: 公用用户名或角色名无效的解决方案

    测试oracle数据安装是否成功,可按顺序执行以下两个步骤: 测试步骤 1:请执行操作系统级的命令:tnsping orcl 上述命令假定全局数据库名是 orcl.以下是命令执行后的示例(请在cmd命 ...

  6. mui 轮播

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  7. 补充:MySQL经典45道题型

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher). 四个表的结构分别如表1-1的表(一)~表 ...

  8. css的小知识4

    ---恢复内容开始--- 一.单位 1.px就是一个基本单位     像素 2.em也是一个单位      用父级元素的字体大小乘以em前面的数字.如果父级没有就继承上一个父级直到body,如果bod ...

  9. git从已有分支拉新分支开发

    开发过程中经常用到从master分支copy一个开发分支,下面我们就用命令行完成这个操作: 1. 切换到被copy的分支(master),并且从远端拉取最新版本 $git checkout maste ...

  10. springmvc用model传值到jsp页面,el表达式引用接收不到传递过来的值

    springmvc用model传值到jsp页面,el表达式引用接收不到传递过来的值 查看下controller层代码可以发现,写的是没有错误的. @RequestMapping("list. ...