本来之前买和另一贴子的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. mysql按位的索引判断值是否为1

    DELIMITER $$ DROP FUNCTION IF EXISTS `value_of_bit_index_is_true`$$/*计算某个数字的某些索引的位的值是否都为1,索引类似1,2,3, ...

  2. C# 不安装Oracle客户端情况下,如何连接到Oracle数据库

    简介: 在我们开发应用场景经常碰到需要连接Oracle数据库,这也是相当常见的一种情况.一般.Net环境连接Oracle数据库,可以通过TNS/SQL.NET 配置文件,而 TNS 必须要 Oracl ...

  3. php 实现双向链表

    /** * 链表元素结点类 */ class Node { public $pre = NULL; // 前驱 public $next = NULL; // 后继 public $data = NU ...

  4. 关于Redis 应用 的一些 感悟

    最近在项目中 使用了 Redis技术

  5. linux的基本操作(mysql 的基本操作)

    Mysql 的基本操作 在前面两个章节中已经介绍过MySQL的安装了,但是光会安装还不够,还需要会一些基本的相关操作.当然了,关于MySQL的内容也是非常多的,只不过对于linux系统管理员来讲,一些 ...

  6. Javascript实现MD5加密

    /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as d ...

  7. 微信小程序(微信应用号)组件讲解[申明:来源于网络]

    微信小程序(微信应用号)组件讲解[申明:来源于网络] 地址:http://www.cnblogs.com/muyixiaoguang/p/5902008.html

  8. 个人小爱好:Operating System: three easy pieces—第6章第3小节问题2#进程间的切换

    问题2#:进程间的切换 直接执行的下一个问题是如何实现进程的切换.进程的切换按理说是挺简单的,对吧?不就是决定哪一个进程应该停止,哪一进程应该开始而已,才多大点事情啊?但,事实上这还真的有点棘手:尤其 ...

  9. CH 2401 - 送礼 - [折半DFS+二分]

    题目链接:传送门 描述 作为惩罚,GY被遣送去帮助某神牛给女生送礼物(GY:貌似是个好差事)但是在GY看到礼物之后,他就不这么认为了.某神牛有N个礼物,且异常沉重,但是GY的力气也异常的大(-_-b) ...

  10. [AI][tensorflow][keras] archlinux下 tersorflow and keras 安装

    tensorflow TensorFlow is an open-source machine learning library for research and production. https: ...