• 【毕业设计】基于ESP32的在线墨水屏桌面摆件 -物联网 单片机 嵌入式



    0 前言

    🔥 这两年开始毕业设计和毕业答辩的要求和难度不断提升,传统的毕设题目缺少创新和亮点,往往达不到毕业答辩的要求,这两年不断有学弟学妹告诉学长自己做的项目系统达不到老师的要求。

    为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的是

    🚩 基于STM32自行车智能无线防盗报警器

    🥇学长这里给一个题目综合评分(每项满分5分)

    • 难度系数:3分
    • 工作量:4分
    • 创新点:4分

    🧿 选题指导, 项目分享:

    https://gitee.com/dancheng-senior/project-sharing-1/blob/master/%E6%AF%95%E8%AE%BE%E6%8C%87%E5%AF%BC/README.md


    1 简介

    使用了合宙的ESP32C3开发板,设计了一款可拆卸的桌面模式屏摆件,通过wifi联网,可实现时间、天气、古诗、图片四种模式的显示。通过按键实现不同模式间的切换和更新。

    2 主要器件

    • ESP32C3开发板
    • 墨水屏模块
    • MOSFET-N+AO3400A
    • 按键微动开关 664.3
    • PCB插座_2.54_2x8/16P 立式

    3 实现效果

    在这里插入图片描述
    在这里插入图片描述

    在这里插入图片描述

    4 实现原理

    4.1 硬件部分

    墨水屏模块
    在这里插入图片描述
    使用2.9寸墨水屏,单片价格在15左右

    项目在软件方面驱动墨水屏使用的是GxEPD2库,在GxEPD2库中选择适当的对于型号即可。如下所示:
    GxEPD2_BW display(GxEPD2_290(/CS=5/ 7, /DC=/ 4, /RST=/ 5, /BUSY=/ 6)); // 屏幕型号1
    GxEPD2_BW display(GxEPD2_290_T5(/CS=5/ 7, /DC=/4, /RST=/5, /BUSY=/6)); //屏幕型号2

    底座模块
    在这里插入图片描述
    底座模块主要是起一个连接开发板和墨水屏模块的作用。

    焊接PCB插座来实现墨水屏模块的拔插,焊接排母来实现与ESP32C3开发板的连接,焊接按钮来进行显示控制。

    ESP32C3开发板
    在这里插入图片描述
    使用合宙的ESP32C3开发板,开发板买经典款或者简约款都可以。

    经典款比较方便,因为使用简约款注意的技术细节会比较多,容易遇到坑。

    排针朝上焊接就行,因为排针排母连接,这个项目用完拔下来做其他项目也很方便。

    4.2 软件部分

    编程软件Arduino

    编程软件用的Arduino,环境配置参照网上资料。

    开发板添加
    在这里插入图片描述
    使用到的库
    在这里插入图片描述
    本项目使用的库有:

    • ArduinoJson库: 解析Json数据,项目里的天气、古诗、名言等信息都是通过一些API获得,保存在返回的json数据中。
    • GxEPD2库:驱动墨水屏
    • Timezone库:通过NTP获取时钟需要用到
    • U8g2库:图像显示库

    库的话可以在项目->加载库->管理库 中搜索下载。

    5 部分核心固件代码

    在这里插入图片描述

    // wifi连接UDP设置参数
    WiFiUDP Udp;
    
    time_t getNtpTime() //通过NTP获取时间
    {
        IPAddress ntpServerIP; // NTP server's ip address
        while (Udp.parsePacket() > 0)
            ; // discard any previously received packets
        // Serial.println("Transmit NTP Request");
        //  get a random server from the pool
        WiFi.hostByName(ntpServerName, ntpServerIP);
        sendNTPpacket(ntpServerIP);
        uint32_t beginWait = millis();
        while (millis() - beginWait < 1500)
        {
            int size = Udp.parsePacket();
            if (size >= NTP_PACKET_SIZE)
            {
                Serial.println("Receive NTP Response");
                Udp.read(packetBuffer, NTP_PACKET_SIZE); // read packet into the buffer
                unsigned long secsSince1900;
                // convert four bytes starting at location 40 to a long integer
                secsSince1900 = (unsigned long)packetBuffer[40] << 24;
                secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
                secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
                secsSince1900 |= (unsigned long)packetBuffer[43];
                return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
            }
        }
        Serial.println("No NTP Response :-(");
        return 0; // 无法获取时间时返回0
    }
    
    // 向NTP服务器发送请求
    void sendNTPpacket(IPAddress &address)
    {
        // set all bytes in the buffer to 0
        memset(packetBuffer, 0, NTP_PACKET_SIZE);
        // Initialize values needed to form NTP request
        // (see URL above for details on the packets)
        packetBuffer[0] = 0b11100011; // LI, Version, Mode
        packetBuffer[1] = 0;          // Stratum, or type of clock
        packetBuffer[2] = 6;          // Polling Interval
        packetBuffer[3] = 0xEC;       // Peer Clock Precision
        // 8 bytes of zero for Root Delay & Root Dispersion
        packetBuffer[12] = 49;
        packetBuffer[13] = 0x4E;
        packetBuffer[14] = 49;
        packetBuffer[15] = 52;
        // all NTP fields have been given values, now
        // you can send a packet requesting a timestamp:
        Udp.beginPacket(address, 123); // NTP requests are to port 123
        Udp.write(packetBuffer, NTP_PACKET_SIZE);
        Udp.endPacket();
    }
    
    void initNTP()
    {
        // Login suceeded so set UDP local port
        Udp.begin(LOCALPORT);
        // Set the time provider to NTP
        setSyncProvider(getNtpTime); //同步时间
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63

    6 最后

  • 相关阅读:
    Win11新建不了文本文档?Win11右键无法新建文本文档的解决方法
    有点无聊,来试试用Python采集下载漫画
    日常中msvcr120.dll丢失怎样修复?总结5个msvcr120.dll丢失的修复教程
    23面向对象
    Java.lang.Character类中codePointBefore(char[ ] a, int index)方法具有什么功能呢?
    业务型 编辑器组件的封装(复制即可使用)
    Java idea查看自定义注解的调用地方
    Oracle12c新特性大全 IO资源隔离
    【置顶】QT的知识点以及代码汇总整理
    PaddleOCR中Android示例Demo编译问题解决
  • 原文地址:https://blog.csdn.net/m0_71572576/article/details/126243687