本来之前买和另一贴子的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. GitLab push除发Jenkins事件

    1.打开Jenkins项目配置 2.勾选Trigger builds remotely (e.g., from scripts) 3.Authentication Token随便填个内容(比方1234 ...

  2. Windows下使用VS2017搭建FLTK开发环境

    环境介绍 系统:win10 64位 IDE:VS 2017 Community FLTK版本:1.3.4-2 下载FLTK 截止到本文编写,FLTK的最新稳定版本是1.3.4-2.我们从官网(www. ...

  3. lis最长上升子序列

    因为是最长上升的,可以用一个数组储存上升的序列,如果后一个数字比数组的最大数字还大,就加到末尾去,如果不大于,那么就可以把这个数组中比他大的数字替换掉,因为如果数字更小,后面上升序列更长的可能性更大, ...

  4. 扫描系统进程和获取某进程的PID

    扫描系统的所有进程 #include <stdio.h> #include <windows.h> #include <tlhelp32.h> int scan() ...

  5. Nestjs 接口验证

    class-validator Nestjs yarn add class-transformer class-validator main.ts import { NestFactory } fro ...

  6. java获取当前网站的IP地址

    package ip; import java.net.InetAddress; import java.net.UnknownHostException; /** * * @author * */ ...

  7. java Api 读取HDFS文件内容

    package dao; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.*; import java ...

  8. Caused by: java.lang.ClassNotFoundException: Could not load requested class :XXX.XXX.XXX 异常处理

    在ssh整合中:出现的异常 Exception sending context initialized event to listener instance of class org.springfr ...

  9. java web应用连接mysql会突然connection连接失败

    tomcat6.0 mysql5.1 项目:java web项目 问题:原本项目运行了好几天了,一直没发现问题,突然今天报数据库连接异常,进入看日志发现 ### Error querying data ...

  10. hibernate--博客

    地址:http://blog.csdn.net/wangpeng047/article/category/907051