2589 views|1 replies

6609

Posts

0

Resources
The OP
 

MAX6675 temperature acquisition program based on ESP8266 [Copy link]

 

The MAX6675 temperature acquisition program based on ESP8266 is feasible after personal testing. Currently, only the serial port is used to send data for testing.

/*
* max6675.c
*
* Created on: 2021年11月5日
*   Author: Administrator
*/
#include"driver/max6675.h"

// 毫秒延时函数
//=================================================
void ICACHE_FLASH_ATTR Dht11_delay_ms(u32 C_time)
{    for(;C_time>0;C_time--)
        os_delay_us(1000);
}
//=========================================================
//GPIO5设为SO口
//========================================================
void ICACHE_FLASH_ATTR MAX6675_SO(u8 Value_Vol)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U,    FUNC_GPIO5);    // GPIO5设为IO口
    GPIO_OUTPUT_SET(GPIO_ID_PIN(5),Value_Vol);                // IO5设为输出=X
}
//=========================================================
//GPIO4设为SCLK口
//========================================================
void ICACHE_FLASH_ATTR MAX6675_SCLK(u8 Value_Vol)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U,    FUNC_GPIO4);    // GPIO4设为SCLK口
    GPIO_OUTPUT_SET(GPIO_ID_PIN(4),Value_Vol);                // IO4设为输出=X
}
//=========================================================
//GPIO2设为CS口
//========================================================
void ICACHE_FLASH_ATTR MAX6675_CS(u8 Value_Vol)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U,    FUNC_GPIO2);    // GPIO2设为CS口
    GPIO_OUTPUT_SET(GPIO_ID_PIN(2),Value_Vol);                // IO2设为输出=X
}
// GPIO_5(MAX6675信号线)设为输入模式
//===========================================================================
void ICACHE_FLASH_ATTR MAX6675_Input(void)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U,    FUNC_GPIO5);    // GPIO5设为IO口
    GPIO_DIS_OUTPUT(GPIO_ID_PIN(5));        // GPIO5失能输出(输入)
}
unsigned long max6675_read()    //读取温度值
{
    unsigned char i;
    unsigned long max_6675=0x00;
    MAX6675_CS(0);
    MAX6675_SCLK(0);
    MAX6675_SO(0);
    for(i=0;i<16;i++)
    {
        MAX6675_SCLK(1);
        max_6675<<=1;
        MAX6675_Input();
        if(GPIO_INPUT_GET(GPIO_ID_PIN(5))==1){max_6675=max_6675|0x01;}
        else max_6675=max_6675|0x00;
        MAX6675_SCLK(0);
    }
    MAX6675_CS(1);
    max_6675<<=1;
    max_6675>>=4;
    max_6675=max_6675/4;
    return max_6675;
}

Code

代码_MAX6675.7z (3.25 MB, downloads: 15)

This post is from Domestic Chip Exchange

Latest reply

Thanks for sharing. I once bought an esp8266, but it has been gathering dust in a drawer.  Details Published on 2021-11-11 09:16
 
 

18

Posts

1

Resources
2
 
Thanks for sharing. I once bought an esp8266, but it has been gathering dust in a drawer.
This post is from Domestic Chip Exchange
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list