本来之前买和另一贴子的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. 【Zookeeper系列】ZooKeeper一致性原理(转)

    原文链接:https://www.cnblogs.com/sunddenly/p/4138580.html 一.ZooKeeper 的实现 1.1 ZooKeeper处理单点故障 我们知道可以通过Zo ...

  2. R 540

    好久没写题解了嘻嘻嘻,昨天补edu自闭了一天还没补完fg这div3令人愉悦. A: #include <bits/stdc++.h> #define mk(a,b) make_pair(a ...

  3. Gym 101810

    友情提示: 这篇题解并没有GJKL,因为我也不会,而且看别人代码也看不懂,而且问学长还不给我讲!hmc:这个题巨麻烦,我只能说balabala.我不学了我退役了啊! A:这傻逼题我从开头wa了四个小时 ...

  4. vue2中使用transition

    最终效果为  div元素从右向左出现, 然后从左向右消失. transition标签包裹要移动的元素: css 样式: 其中: 1:  为div元素显示时的状态 2:  为div元素移动的过程 (进入 ...

  5. js中typeof与instanceof用法

    今天写JS代码,遇到动态生成多个名称相同的input复选按钮 需要判断其是否是数组,用到了if (typeof(document.MapCheckMgr.checkid)!="undefin ...

  6. 深入理解Java虚拟机(笔记)

    内存分配: 为对象分配内存有两种方式,第一种是“指针碰撞”,也就是把内存分为两边,一边是已使用区域,另一边是未分配区域,分界线用指针记录,当要分配内存时,只需把指针向未分配区域移动需要的空间即可,通常 ...

  7. 从session中获取当前用户的工具类

    package cn.crmx.crm.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.Ht ...

  8. [tldk][dpdk][dev] TLDK--基于dpdk的用户态协议栈传输层组件简单调研

    如题,以下是一份简单的快速调研. TLDK: Transport Layer Development Kit 一 什么是TLDK transport layer development kit 处理t ...

  9. 什么是Rollback Segment(已truncate和delete 命令为例)?

    Rollback Segments是在你数据库中的一些存储空间,它用来临时的保存当数据库数据发生改变时的先前值,Rollback Segment主要有两个目的: 1. 如果因为某种原因或者其他用用户想 ...

  10. SQL 查询嵌套使用

    .查询: 各年级中 分数最高的学习信息   示例表如下:   create table it_student( id int primary key auto_increment,  -- 主键id ...