ESP32开发板的RTC时钟,利用0.91寸oled显示(ssd1306),MicroPython编写

21-ESP32-S3实时时钟(RTC) ESP32-S3的RTC模块具有以下主要功能: - **时间和日期**:RTC模块可以提供实时的时间和日期信息。 - **闹钟**:可以设置RTC模块在特定的时间和日期发出信号。 - **定时器**:RTC模块可以作为一个定时器,用于在特定的时间间隔后发出信号。 - **低功耗模式**:当ESP32-S3的其他部分关闭时,RTC模块可以继续运行,以节省电能。 阅读详情

又入手了一个ESP32的开发板,主要是便宜,四舍五入约等于不要钱,哈哈,再配上一个0.91寸的OLED,马上就能看见程序输出的内容,十分激动!赶紧copy一个代码过来学习下,毕竟自己是肯定研究不出来的,哈哈哈,但是并不是无脑copy,每次都会根据自己的实际情况修改下,消化吸收后自己以后也能照猫画虎的用一用了。

在这记录一下,总算是能显示出来了,做的这些东西都十分鸡肋,主要就是学习过程,哈哈哈!

import machine
from machine import Pin, I2C, RTC,Timer
from ssd1306 import SSD1306_I2C

week = ['Monday', 'Tuesday', 'Wednesay', 'Thursday', 'Friday', 'Saturday', 'Sunday']
time_list = ['', '', '']
i2c = machine.SoftI2C(sda=Pin(23), scl=Pin(19)) 
oled = SSD1306_I2C(128, 32, i2c, addr=0x3c)
rtc = RTC()
if rtc.datetime()[0] != 2022:
    rtc.datetime()

def RTC_Run(tim):
    datetime = rtc.datetime() # 获取当前时间
    oled.fill(0) # 清屏显示黑色背景
    oled.text('CLOCK!',0,0)
    
    oled.text(str(datetime[0]) + '-' + str(datetime[1]) + '-' + 
    str(datetime[2]) + '' + week[datetime[3]], 0, 12)
    # 显示时间需要判断时、分、秒的值否小于 10,如果小于 10,则在显示前面补“0”以
    # 达到较佳的显示效果
    for i in range(4, 7):
        if datetime[i] < 10:
            time_list[i - 4] 
ESP32运行MicroPython从网络获取天气OLED显示 获取天气 网络上有好多获取天气的API,但是用的比较多的是心知天气提供的API。 注册心知天气账号(https://www.seniverse.com/),购买服务,可以看到秘钥: 有免费版的、有试用版的,免费版的可以一直使用,但是能获取的数据比较少,试用版的获取的数据更多,但是只能使用一个月。 API 将API中的your_private_key替换为自己的秘钥:https:/... 阅读详情

相关推荐

ESP32-C3入门教程 基础篇⑨——RTC 实时时钟 系统时钟 time/settimeofday/gettimeofday

ESP32-C3入门教程 基础篇⑨——RTC 实时时钟 系统时钟 time/settimeofday/gettimeofday

7006

【ESP32 IDF】RTC时钟

在嵌入式系统开发中,时间的准确性往往是至关重要的。对于某些应用程序,例如实时调度、数据记录和事件触发,使用RTC(Real-Time Clock,实时时钟)成为必要。ESP32是一款功能强大的嵌入式开发板,它提供了一个内置的RTC模块,使我们能够轻松地在应用程序中使用准确的实时时钟。本文将介绍如何在ESP32 IDF(IoT Development Framework,物联网开发框架)中利用RTC模块实现一个可靠的时钟功能。我们将探讨如何初始化RTC时钟以及如何获取和设置时间。

m0_62599305的博客 3930

【雕爷学编程】MicroPython手册之 ESP32 实时时钟(RTC)

然后,我们使用rtc.alarm()设置RTC定时唤醒的时间,以毫秒为单位(此处设置为5000毫秒,即5秒后唤醒)。4、外设:12 位 SAR ADC 最多支持 18 个通道,2 个 8 位 DAC,10 个触摸传感器,4 个 SPI,2 个 I2S,2 个 I2C,3 个 UART,SD/SDIO/MMC 主机控制器,SDIO/SPI 从设备控制器,以太网 MAC 接口,CAN 总线 2.0,红外远程控制器,电机 PWM,LED PWM 最多支持 16 通道。RTC是一个独立的时钟,用于跟踪日期和时间。

雕爷学编程 2234

【Micropython ESP32】RTC时钟

在嵌入式设备开发中,实时时钟(RTC)在很多应用中扮演着重要的角色。它可以提供准确的时间跟踪以及时间戳功能,对于需要时间相关操作的应用非常有用。本文将介绍Micropython ESP32平台上的RTC时钟模块。Micropython是一种适用于嵌入式设备的精简Python实现,它在ESP32平台上提供了RTC模块的软件实现,可以轻松地处理时间相关的任务。RTC(Real-Time Clock),即实时时钟,是一种专门用于保持和跟踪时间的设备或模块。

m0_62599305的博客 2800

esp32自动获取天气及时钟在oled显示,支持中文

esp32自动获取天气及时钟在oled显示,支持中文,物联网

从V形槽到光模块:深度解析光纤阵列FA的精密制造与核心工艺

本文深度解析光纤阵列FA的精密制造与核心工艺,从V形槽基板材料选择到纳米级开槽工艺,再到光纤排布与端面处理技术。特别探讨了高密度型FA在光通信中的应用,以及如何通过自动对准技术和可靠性验证确保产品性能。文章还分享了湿法刻蚀等关键工艺参数,为光模块制造提供实用参考。

weixin_30423977的博客 613

【3d打印】基于Klipper的3d打印远程上位机系统(Qt),klipper源码,通信解析,打印参数设置

基于Klipper的3d打印远程上位机系统(Qt),klipper源码,通信解析,打印参数设置(启庞Kp3s V1)

共享IT之美,共创机器未来 3200

STM32外围电路硬件解析

复位 :让MCU回到最开始的状态。并且从头开始,重新执行程序 我们什么时候需要复位? 1.烧录的时候 2.程序跑飞了的时候 3.上电复位(上电的时候需要复位) 复位方式: 1.上电复位: --- 一定要有 MCU的Reset是复位引脚,当这个引脚为低电平时,

qq_39577221的博客 1万+

Prometheus常用配置介绍

除了 scrape_configs 外,上部还有 global 和 rule_files 部分, 其中 global 中 是 全 局 参 数 , scrape_interval 指 定 全 局 默 认 的 时 间 间 隔 , evaluation_interval 指定告警规则校验的时间间隔,rule_files 指定了告警规 则文件的位置名称。• annotations(注释):它们被用于存储更长的其他信息,例如警报描述 或者链接,注释值也可以被模板化。• alert:告警的名称。

weixin_42886699的博客 2268

DFRobot MGC3130电容式手势传感器库深度解析

电容式近场感应(Electric Near Field Sensing)是一种非接触、抗干扰的三维空间感知技术,其原理基于人体介电特性对高频电场的扰动响应,具备低功耗、高鲁棒性与零物理接触等核心优势。该技术广泛应用于医疗人机交互、工业HMI、智能家电等对可靠性与环境适应性要求严苛的嵌入式场景。DFRobot_MGC3130库正是面向Microchip MGC3130芯片的工程化实现,封装了I²C驱动、ASU硬件加速调度及多层抽象API,支持手势识别、触控检测与接近唤醒等功能动态切换。结合电容式近场感应与嵌入

weixin_34620658的博客 558

《联邦学习实战》杨强 读书笔记十四——构建公平的大数据交易市场

当数据具有资产属性之后,数据便可以直接或者间接地为公司、为社会创造价值和收益,并且可以作为一种特殊的商品在市场中进行交易。 与传统的商品交易相比,数据资产交易的市场前景更广阔,但同时也面临着很多的挑战,主要包括: 数据的质量、价格如何定义 在合法合规的前提下,数据的交易如何确保不会泄露用户的隐私 如何构建合理的激励机制来鼓励更多的参与方加入数据交易市场中 大数据交易 数据交易的定义 数据交易是指一种对数据进行买卖的行为,大数据交易由三方共同参与,分别为数据提供方、大数据交易平台和数据需求方:

IEEE802_11的博客 3471

2025年5月架构设计师论文真题回顾,附写作技巧、所涉知识点及参考范文(三)

本文主要回顾2025年上半年(2025-5-24)系统架构设计师考试下午论文的题目,同时附带写作技巧、所涉知识点及参考范文。试题三:多模型数据库及应用。

一几文的编程学习笔记。 651

使用 MATLAB/Simulink 构建一个分布式光伏-储能联合系统在配电网中的协同控制模型

本文介绍了使用MATLAB/Simulink构建分布式光伏-储能联合系统协同控制模型的方法。该系统包含光伏发电、储能、负荷和控制器等模块,通过协同控制实现能量优化管理。建模过程详细说明了从创建项目、搭建组件到实现控制策略的步骤,包括光伏特性模拟、储能参数设置和负荷需求建模。重点设计了协同控制器算法,实时调节电力分配,并展示了系统运行指标和经济效益分析。该方法为多能互补系统在配电网中的应用提供了技术验证,未来可进一步优化控制算法和场景适应性。

MHD0815的博客 323

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: PICO控制S90舵机
Micro Python
博客等级 码龄5年 5粉丝 2原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值