蓝猫淘气

[Hangshun Training Camp] Outdoor temperature, humidity and pressure sensor

 
Overview

Design summary

This project is a very simple application. It is mainly used for converting I2C to RS485. It is a sensor conversion module. This project is to digitize the I2C signal of the temperature, humidity and air pressure sensor and output the RS485 signal to facilitate the integrated development of other instruments.

Sensor parameters

Power supply: 5-18V

Output: RS485 (MOUDBUS protocol)

name Measuring range Accuracy Accuracy unit
Temperature Sensor -40~85 0.1 ±0.5
Humidity Sensor 0-100 0.1 ±5% %RH
barometric pressure sensor 300-1100 1 ±0.2 hPa

designing process

1. Chip selection and peripheral circuits

In this case, as a simple application, the chip must have one I2C, one UART, and at least 1 byte of EEPROM. The chip I chose here is the domestic Hangshun chip, HK32F030MF4P6. The chip has a built-in crystal oscillator, so many peripheral devices can be omitted. Chip circuit.jpg

2. Power circuit part

In order to be compatible with more systems, the power supply is designed to be powered by 5-18V. Considering that the high voltage drop will cause the LDO step-down chip to overheat, a DC-DC chip + LDO step-down chip is used here, and the input is transferred through the switching power supply chip. The VCC is converted to 5V, and then converted to 3.3V by the LDO power chip as the main power supply of the chip. The voltage is reduced to DC3.3V in two steps. (Actually measured 4.0-18.5V is available). **Note:** I have omitted the capacitor of the VIN part of HK7533 here, because in the PCB layout, I introduced it directly from the 5V voltage capacitor of the front stage, which is very close. Therefore, a 10uF capacitor is omitted at VIN. Please be careful to add it if you transplant it later. Power circuit.jpg

3. RS485 chip circuit

The reason I highlight here is that some RS485 chips do not support 3.3V power supply (some are 5V power supply). If you transplant, please pay attention to the voltage issue. RS485 chip circuit.jpg

4. Shell selection

If you search for "louver temperature and humidity sensor housing" on Taobao, you can quickly find a housing similar to the author's. Plan the PCB according to the internal dimensions of the housing.

5. PCB precautions

The temperature, humidity and air pressure sensors should be placed as close to the side as possible, and a tiny fan can be added if conditions permit. The sensor should be kept away from internal heating components (such as power chips, power modules, buck chips, etc.). The case is placed in the corner. Designed with 4 wires (pin and female positions), you can also break the board and connect it with wires to completely isolate the PCB from heat conduction. Sensor location.jpg

Welded finished product

1. There are various methods. Currently, the author uses the "teppanyaki" method. First, apply solder paste, stick it on, and then heat it with a "whirter".

2. After completing the power-on test, first use a multimeter to check whether VCC (5V3.3VUSB) and GND are short-circuited. Make sure before plugging in. Do not plug in if there is a short circuit. Welding comparison.jpg

software code

1. Power adjustment and saving parameters

Because RS485 involves hardware address issues and requires a power-saving function, eeprom reading and writing is added to the program to save the address after power failure.

#include "eeprom.h"
uint8_t EEPROM_WriteByte(uint32_t address, uint8_t data_in)//写EEPROM
{
    if(HK32F030M_EE_SIZE <= address)
    {
        return 0;
    }

    FLASH_Unlock();
    EEPROM_EraseByte(address+HK32F030M_EE_BEGIN);
    EEPROM_ProgramByte(address+HK32F030M_EE_BEGIN, data_in);
    FLASH_Lock();

    if((*(uint8_t *)(address+HK32F030M_EE_BEGIN)) != data_in)
    {
        return 0;
    }
    return 1;
}
uint8_t EEPROM_ReadByte(uint32_t address,uint8_t *data_out)//读EEPROM
{
    if(HK32F030M_EE_SIZE <= address)
    {
        return 0;
    }

    *data_out = (*((uint8_t *)(address + HK32F030M_EE_BEGIN)));
    return 1;
}

2. RS485 chip flow control problem

The RS485 chip needs to control input and output, which is half-duplex. When coding, GPIO must be used as output high and low levels for control. The code snippet is as follows

void RS485_CTRL_TX(void)
{
  GPIOC->BSRR = GPIO_Pin_3;  //IO口置为3.3v
}
void RS485_CTRL_RX(void)
{
  GPIOC->BRR = GPIO_Pin_3;    //IO置为0v 
}

product assembly

I found an abandoned shutter box in the corner of the warehouse and assembled it. The two pads drawn on the PCB were just used to weld on the copper pillars, and the copper pillars were fixed on the shutters. As shown below: Assembly.jpg

Completed.jpg

The Joy of Success-Video Sharing

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-19 20:16:30
  • Logo three-wheel electric sports car
  • Problems encountered when using GetAdaptersAddresses to obtain DNS
  • Dot matrix screen simulation demonstration
  • sysMemTop return address
  • Urgent help for graduation project~~Urgent~~
  • The latency of cache in arm system refers to

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号