Click Here to enter Utsource  site

IC Chips

74 series Digital Integrated Circuits

CD40 series Digital Integrated Circuits

Optical Couplers

Clock & Calculator ICs

Operational Amplifiers

Power Switch Ics

Driver Ics

Flash Memory

Memory

Audio Special Purpose

Clock/Timing - Application Specific

Clock/Timing - Clock Buffers, Drivers

Clock/Timing - Clock Generators, PLLs, Frequency Synthesizers

Clock/Timing - Delay Lines

Clock/Timing - IC Batteries

Clock/Timing - Programmable Timers and Oscillators

Clock/Timing - Real Time Clocks

Data Acquisition - ADCs/DACs - Special Purpose

Data Acquisition - Analog Front End (AFE)

Data Acquisition - Analog to Digital Converters (ADC)

Data Acquisition - Digital Potentiometers

Data Acquisition - Digital to Analog Converters (DAC)

Data Acquisition - Touch Screen Controllers

Embedded - CPLDs (Complex Programmable Logic Devices)

Embedded - DSP (Digital Signal Processors)

Embedded - FPGAs (Field Programmable Gate Array)

Embedded - FPGAs (Field Programmable Gate Array) with Microcontrollers

Embedded - Microcontroller, Microprocessor, FPGA Modules

Embedded - Microcontrollers

Embedded - Microcontrollers - Application Specific

Embedded - Microprocessors

Embedded - PLDs (Programmable Logic Device)

Embedded - System On Chip (SoC)

Interface - Analog Switches - Special Purpose

Interface - Analog Switches, Multiplexers, Demultiplexers

Interface - CODECs

Interface - Controllers

Interface - Direct Digital Synthesis (DDS)

Interface - Drivers, Receivers, Transceivers

Interface - Encoders, Decoders, Converters

Interface - Filters - Active

Interface - I/O Expanders

Interface - Modems - ICs and Modules

Interface - Modules

Interface - Sensor and Detector Interfaces

Interface - Sensor, Capacitive Touch

Interface - Serializers, Deserializers

Interface - Signal Buffers, Repeaters, Splitters

Interface - Signal Terminators

Interface - Specialized

Interface - Telecom

Interface - UARTs (Universal Asynchronous Receiver Transmitter)

Interface - Voice Record and Playback

Linear - Amplifiers - Audio

Linear - Amplifiers - Instrumentation, OP Amps, Buffer Amps

Linear - Amplifiers - Special Purpose

Linear - Amplifiers - Video Amps and Modules

Linear - Analog Multipliers, Dividers

Linear - Comparators

Linear - Video Processing

Logic - Buffers, Drivers, Receivers, Transceivers

Logic - Comparators

Logic - Counters, Dividers

Logic - FIFOs Memory

Logic - Flip Flops

Logic - Gates and Inverters

Logic - Gates and Inverters - Multi-Function, Configurable

Logic - Latches

Logic - Multivibrators

Logic - Parity Generators and Checkers

Logic - Shift Registers

Logic - Signal Switches, Multiplexers, Decoders

Logic - Specialty Logic

Logic - Translators, Level Shifters

Logic - Universal Bus Functions

Memory - Batteries

Memory - Configuration Proms for FPGAs

Memory - Controllers

PMIC - AC DC Converters, Offline Switchers

PMIC - Battery Chargers

PMIC - Battery Management

PMIC - Current Regulation/Management

PMIC - Display Drivers

PMIC - Energy Metering

PMIC - Full, Half-Bridge Drivers

PMIC - Gate Drivers

PMIC - Hot Swap Controllers

PMIC - Laser Drivers

PMIC - LED Drivers

PMIC - Lighting, Ballast Controllers

PMIC - Motor Drivers, Controllers

PMIC - OR Controllers, Ideal Diodes

PMIC - PFC (Power Factor Correction)

PMIC - Power Distribution Switches, Load Drivers

PMIC - Power Management - Specialized

PMIC - Power Over Ethernet (PoE) Controllers

PMIC - Power Supply Controllers, Monitors

PMIC - RMS to DC Converters

PMIC - Supervisors

PMIC - Thermal Management

PMIC - V/F and F/V Converters

PMIC - Voltage Reference

PMIC - Voltage Regulators - DC DC Switching Controllers

PMIC - Voltage Regulators - DC DC Switching Regulators

PMIC - Voltage Regulators - Linear

PMIC - Voltage Regulators - Linear + Switching

PMIC - Voltage Regulators - Linear Regulator Controllers

PMIC - Voltage Regulators - Special Purpose

Specialized ICs

Modules

IGBT

IPM

Thyristors

Rectifiers

Power Supply

Smart Power Module

SCR,GTO and Diode

FET

Darlington Transistors

RF Modules

CNC PRODUCTS

ENCODER

Motor

Servo drive & amplifier & Servo

Diode Module

Transistor Module

Switch Relay

PLC

Inverter

Contactor & Breaker

Elevator Board

Industry Control

Transistors

Diodes

Bipolar transistors

Resistors

Carbon Film Resistors

Cement Resistors

Chassis Mount Resistors

Chip Resistor - Surface Mount

Current Sense Resistors

Fusible Chip Resistor

High Precision & Low TCR SMD Resistors

High Voltage Resistor

LED Strip Resistors

MELF Resistor

Metal Alloy Resistors

Metal Film Resistor (TH)

Metal Glaze Resistors

Metal Oxide Film Resistors

Metal Oxide Resistors

NTC Thermistors

PTC Thermistors

Photoresistors

Potentiometers & Variable Resistors

Precision Potentiometer

Resistor Networks & Arrays

Resistor Networks & Arrays (TH)

Ultra Low Resistors (SMD)

Variable Resistors

Varistors

Wirewound Resistors

Capacitors

Aluminum Electrolytic Capacitors - SMD

CL21 Capacitor

Ceramic Disc Capacitors

High Voltage Capacitors

Metallized Polyester Film Capacitor

Multilayer Ceramic Capacitors MLCC - Leaded

Multilayer Ceramic Capacitors MLCC - SMD/SMT

Mylar Capacitor

Niobium Oxide Capacitors

Polyester Film Capacitors

Solid Polymer Electrolytic Capacitor

Supercapacitors & Ultracapacitors

Suppression Capacitors

Tantalum Capacitors

Trimmers, Variable Capacitors

Inductors & Ferrite Beads & Transformers

Antennas

Current Transformers

General Inductors (TH)

HF Inductors

Inductors (SMD)

LINE Filter

Power Inductors

Power Transformer

RJ45 Transformer

Radial Inductor (TH)

The circular inductors

Crystals

49S

49SMD

49U

Ceramic Resonators

DIP Oscillators(XO)

Radial Cylinder Crystals

SAW Resonators

SMD Crystals

SMD Oscillators(XO)

Connectors

AV Connectors

Audio & Video Connectors

Banana and Tip Connectors

Card Edge Connectors

Circular Connectors

Connector - Card Sockets

Connectors

Connectors - Accessories

Connectors - Housings

Contacts

D-Sub Connectors

Ethernet Connectors/Modular Connectors

FFC, FPC (Flat Flexible) Connectors

Fiber Optic Connectors

IC & Component Sockets

LED Light Pipes

Mezzanine Connectors (Board to Board)

PCB Connectors - Headers, Male Pins

PCB Connectors - Headers, Receptacles, Female Sockets

PCB Connectors - Housings

Power Connectors

RF Connectors/Coaxial Connectors

Shunts & Jumpers

Terminal Blocks - Accessories

Terminal Blocks - Barrier Blocks

Terminal Blocks - Din Rail, Channel

Terminal Blocks - Headers, Plugs and Sockets

Terminals

Test Clips

Test Points/Test Rings

USB Connectors

Unspecified Connectors

Screw-type wiring

Spring-type wiring

Pluggable Terminal Blocks

Through-wall Terminal Blocks

Automotive Terminals

Terminal Housings, Insulation Sleeves & Blocks

Quick Disconnect Wire Connectors and Terminals

Spare & Wear Tooling

Automotive Connectors

PCB Connectors

PC Laptop Parts

Lenovo Spare Parts

HP Spare Parts

Dell Spare Parts

Samsung Spare Parts

Asus Spare Parts

Microsoft Spare Parts

Huawei Spare Parts

Replacement Keyboards

Others

Laptop Screen

Mac Parts

LCD Screen

LCD Related Parts

Bottom Cover

Keyboard

Screws

Flex Cable

Touchpad

Power Board

Network Adapter

SSD Related Parts

Motherboard

Cooling Fan

Earpiece & Loundspeaker

Rubber Mats

Others

DJI Spare Parts

For DJI Phantom Series

For DJI Mavic Series

For DJI Spark Series

For DJI FPV Series

For DJI Mini Series

Others

iPhone 15 Pro Max Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 15 Pro Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 15 Plus Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 15 Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 14 Pro Max Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

FPC Connector

Others

iPhone 14 Pro Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

FPC Connector

Others

GoPro Spare Parts

Digital Camera Parts

Outer Screen

LCD Screen

Motherboard

Drive Board

Bayonet Mount Ring

Eyecups

Mode Dial

USB Cover Cap

Battery Cover

Flex Cable

Protective Leather

Card Slot

Button Cap

Shutter Blade Curtain

Others

iPhone 14 Plus Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

FPC Connector

Others

VR Spare Parts

iPhone 14 Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 13 Pro Max Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 13 Pro Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 13 Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 13 Mini Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Others

iPhone 12 Pro Max Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Side Key & Card Tray

Others

iPhone 12/12 Pro Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Metal Parts

Others

iPhone 12 Mini Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Metal Parts

Others

iPhone 11 Parts

Back Cover

LCD Related Parts

Flex Cable

Camera Series

Metal Parts

Others

iPhone 11 Pro Parts

Back Cover

LCD Related Parts

Flex Cable

Camera Series

Metal Parts

Others

iPhone 11 Pro Max Parts

Back Cover

LCD Related Parts

Flex Cable

Camera Series

Metal Parts

Others

iPhone XS Parts

Back Cover

LCD Related Parts

Flex Cable

Camera Series

Metal Parts

Others

iPhone XS Max Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Metal Parts

Others

iPhone XR Parts

LCD Related Parts

Back Cover

Flex Cable

Camera Series

Metal Parts

Others

iPhone X Parts

Back Cover

LCD Related Parts

Flex Cable

Camera Series

Metal Parts

Others

iPhone 8 Parts

LCD Screen

Glass Lens

Back Cover

Camera Series

Card Tray

Flex Cable

Metal Parts

Others

iPhone 8 Plus Parts

LCD Screen

Glass Lens

Back Cover

Camera Series

Button & Card Slots

Flex Cable

Metal Parts

Others

iPhone 7 Parts

LCD Screen

Glass Lens

Back Cover

Camera

Flex Cable

Metal Parts

Others

iPhone 7 Plus Parts

LCD Screen

Glass Lens

Back Cover

Camera

Flex Cable

Metal Parts

Others

Other iPhone Parts

iPhone 6S/6S Plus Parts

iPhone 6/6 Plus Parts

iPhone 5 Parts

iPhone 4/4S Parts

iPhone SE 2020 / 2022 Parts

SE 3rd Generation Parts

SE 2nd Generation Parts

SE 1st Generation Parts

iPad Pro Series Parts

12.9 inch

10.5 inch

9.7 inch

iPad Air Series Parts

iPad Air 2 Parts

iPad Air Parts

vivo Parts

LCD Screen

Outer Glass Lens

Touch Panel

Frame Bezel Plate

Back Cover

Flex Cable

Camera Parts

Charging Port Board

Single Tail Connector

Speaker Ringer Buzzer

Card Socket

Home key & Side Key

Others

iPad mini Series Parts

iPad mini 4 Parts

iPad mini 3 Parts

iPad mini 2 Parts

iPad mini Parts

OPPO Parts

LCD Screen

Outer Glass Lens

Touch Panel

Frame Bezel Plate

Back Cover

Camera Series

Flex Cable

Single Tail Connector

Speaker Ringer Buzzer

Card Socket

Home key & Side Key

Small Board

Others

Tecno Spare Parts

LCD Screen

Outer Glass Lens

Back Cover

Small Board

Single Tail Connector

Camera Parts

Flex Cable

Card Tray

Infinix Spare Parts

LCD Screen

Outer Glass Lens

Small Board

Single Tail Connector

Camera Parts

Flex Cable

Earpiece & Loundspeaker

Card Tray

itel Spare Parts

Alcatel Spare Parts

LCD Screen

Outer Glass Lens

Touch Panel

Back Cover

Flex Cable

Single Tail Connector

Small Board

Card Tray

OnePlus Parts

LCD Screen

LCD Related Parts

Frame Bezel Plate

Back Cover

Camera Series

Flex Cable

Tail Connector

Speaker Ringer Buzzer

Card Tray

Earpiece

Home key & Side Key

Adhesive Sticker

Others

Game Spare Parts

Switch Lite Spare Parts

Switch Spare Parts

PS5 Spare Parts

PS4 Spare Parts

NDS Spare Parts

3DS Spare Parts

Wii Spare Parts

PSP Spare Parts

PS3 Spare Parts

PS2 Spare Parts

XBOX Spare Parts

Steam Deck Spare Parts

Tools

iPad Series Parts

iPad 4 Parts

iPad 3 Parts

iPad 2 Parts

iPad Parts

Galaxy Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Frame Bezel Plate

Back Cover

Camera

Card Socket

FPC Connector

Single Tail Connector

Charging Port Board

Wireless Charging Module

Home key & Side Key

Flex Cable

Earpiece & Loundspeaker

Vibrating Motor

Adhesive Sticker

Polarizing Film

OCA & LCD Backlight

Others

Huawei Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Adhesive Sticker

OCA & Polarizing Films

Camera

Card Socket

FPC Connector

Tail Connector

Back Cover

Full Housing Cover

Flex Cable

Home key & Side Key

Fingerprint Ring

Earpiece & Loundspeaker

Earphone Jack

Others

Xiaomi Spare Parts

LCD Screen

Touch Panel

LCD Related Parts

Back Cover

Frame Bezel Plate

Backlight Plate & OCA

Camera

Tail Connector

Card Tray

Flex Cable

Speaker Ringer Buzzer

Earpiece Speaker

Vibrating Motor

Home key & Side Key

Adhesive Sticker

Others

Meizu Spare Parts

LCD Screen

Outer Glass Lens

Touch Panel

Frame Bezel Plate

Camera

Back Cover

Full Housing Cover

Tail Connector

Card Socket

Flex Cable

Home key & Side Key

Earpiece & Loundspeaker

Apple Serie Parts

Airpods Series

Apple Pencil Series

Batteries

For iPhone

For iPad & iPod Series

For Mac

For Samsung

For Xiaomi

For Huawei

For Sony

For LG

For Nokia

For Motorola

For Lenovo

For HTC

For OnePlus

For OPPO

For Watch

Others

Apple Watch Parts

LCD Related Parts

Back Cover

Flex Cable

Vibrating Motor

Middle Frame

Adhesive Sticker

Other Parts

Watch Spare Parts

For Samsung

For Huawei

For Xiaomi

For Fitbit

For Garmin

Other

Sony Spare Parts

LCD Screen

Touch Panel

Back Cover

Frame Bezel Plate

Flex Cable

Camera

LCD Backlight Plate

Tail Connector

Speaker Ringer Buzzer

Earpiece Speaker

Adhesive Sticker

Card Tray

Dust Plug

Others

HTC Spare Parts

LCD Screen

Touch Panel

Back Cover

Full Housing Cover

Camera Series

Tail Connector

Flex Cable

Speaker Ringer Buzzer

Adhesive Sticker

Others

Nokia Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Replacement Keypad

Flex Cable

Back Cover

Adhesive Sticker

Full Housing Cover

Earpiece & Loundspeaker

Card Tray

Camera

Charging Port Connector

Charging Port Board

Lenovo Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Tail Connector

Back Cover

Camera

Flex Cable

Others

Google Spare Parts

LCD Screen

Outer Glass Lens

Frame Bezel Plate

Back Cover

Flex Cable

Small Board

Camera Parts

Earpiece & Loundspeaker

Vibrating Motor

Card Tray

Adhesive Sticker

Others

ASUS Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Camera

Tail Connector

Back Cover

Flex Cable

Speaker Ringer Buzzer

Frame Bezel Plate

Card Tray

Others

Microsoft Spare Parts

LCD Screen

LCD Related Parts

Flex Cable

Back Cover

Full Housing Cover

Camera Series

Others

Motorola Spare Parts

LCD Screen

Touch Panel

Outer Glass Lens

Frame Bezel Plate

Charging Port Board

Card Socket

Back Cover

Camera Accessories

Flex Cable

Earpiece & Loundspeaker

Others

More Brand Parts

For LG

For Amazon

For BlackBerry

For ZTE

For Acer

For BQ Aquaris

For Wiko

For Letv

For Vodafone

For 360

For CAT

For TCL

For T-Mobile

Others

iPod Parts

Touch Series

Other Parts

Shenzhen Brand Phone Parts

AGM

Doogee

LEAGOO

Blackview

Ulefone

UMIDIGI

Cubot

IIIF150

Others

IC Chipset

IC for iPhone

IC for Samsung

IC for Huawei

Power IC

Audio IC

Hard Disk for iPhone

Repair Tools

Screwdriver

Screwdriver Set

Tool Kits

Test Tools

Repair Fixture

Repair Programmer

Power Supply

Repair Glue Series

Adhesive Sticker

Laminator Machine

Separation Equipment

Laser Machines

Polishing Repair

Defoaming Equipment

Laminating Machines

Repair Platform

Crowbar

Brushes

Working Mat

Magnetic Screws Mat

Magnetizer Demagnetizer Tool

Sucker

Tweezers

Glove

Dust Remove Tool

BGA Stencils

Mould

Microscope Magnifier Series

Tool Boxes & Bags

Phone Film Cutter

Others

Sign In

3.Enter "account center"->"My inquiries" and check the status of your inquiries
liveTop

Dear customers, due to the implementation of the GDPR policy in Europe, UTSOURCE has also made adjustment accordingly to meet the policy requirements. Please read the new privacy policy carefully and this window will no longer pop up after you accept it.

I agree all UTSOURCE Terms & Conditions,Privacy Statement
Agree Later Submit

Delivery Address

Alternate Text

+ Add Address

Confirm

The new shipping address

*Country/Region :
*Contact :
*Cell Phone:
+

* Please fill in the cell phone number correctly to make sure that you can receive the tracking info in time.

Country Code
*Address :
*City :
Province/State :
*Province/State :
*Post Code :
Please enter a new 5-digit zip code..
Company :
Cancel
Submit

DIY Electronic Project: Building a Microcontroller-Based Temperature Logger with STM32F103C8T6

PViews:24

2024-11-06 17:25:25 source:Utsource author:
more information,enter the information center

Introduction

In this DIY electronics project, we will explore the process of building a simple temperature logging system using the STM32F103C8T6 microcontroller. This project is an excellent way to get hands-on experience with microcontroller programming, sensor integration, and data logging. The STM32F103C8T6 is a 32-bit ARM Cortex-M3 microcontroller, offering plenty of features for DIY enthusiasts and hobbyists, including GPIO pins, UART, I2C, SPI communication, and timers. We’ll be using the STM32F103C8T6 to read data from a temperature sensor (the widely-used DS18B20) and log this data for later analysis.

Project Overview

The goal of this project is to build a temperature logger that continuously measures the temperature at regular intervals, stores the data, and provides a way to access the logged information. We'll use the STM32F103C8T6 to:

1) Interface with the DS18B20 temperature sensor.

2) Store temperature readings in EEPROM or an SD card.

3) Optionally, display the readings on an LCD screen or send data via UART for logging.


Components Required

1) STM32F103C8T6 Microcontroller: The central processing unit for the project.

2) DS18B20 Temperature Sensor: A digital temperature sensor that communicates over a 1-Wire bus.

3) 16x2 LCD Display: To display the temperature readings.

4) EEPROM Module: To store temperature data.

5) Push Buttons: For user input (e.g., to start logging).

6) Resistors, Capacitors, and Jumpers: For general circuit construction.

7) Breadboard and Wires: For assembling the circuit.

8) Power Supply (5V): To power the microcontroller and sensors.

9) ST-Link/V2 Programmer: For programming the STM32F103C8T6.


Step-by-Step Build

1. Setting Up the STM32F103C8T6

The first step in building this temperature logger is to set up the STM32F103C8T6 microcontroller. This is a relatively easy task, but it’s essential to know how to program the STM32F103C8T6.

Programmer/Debugger Setup: The STM32F103C8T6 doesn’t have a built-in USB interface for programming, so you’ll need an external programmer/debugger, like the ST-Link/V2.

Development Environment: We will use STM32CubeIDE, which is an integrated development environment for STM32 microcontrollers. It comes with the STM32CubeMX tool for generating initialization code and setting up peripherals.

a. Download and install STM32CubeIDE from STMicroelectronics. b. Launch STM32CubeIDE and create a new project for the STM32F103C8T6. c. Select the appropriate settings for the board (e.g., the correct part number or custom board if you’re using a development board).

Pin Configuration: Using STM32CubeMX, configure the microcontroller’s pins for I2C (for the LCD) and GPIO for the DS18B20 temperature sensor. The DS18B20 uses a single-wire interface, so you'll need to assign a pin for the 1-Wire bus.

2. Wiring the Components

Once your microcontroller is set up and ready for programming, you can begin connecting the components to your STM32F103C8T6.


DS18B20 Temperature Sensor:

2) The DS18B20 communicates over a 1-Wire bus, which means you need to connect a single wire from the sensor to the selected GPIO pin on the STM32. Additionally, connect the VCC pin of the DS18B20 to 3.3V (or 5V, depending on the model) and the GND pin to the ground of the system. A 4.7kΩ pull-up resistor is also needed between the GPIO pin and VCC.


 DS18B20 Connections:

2) VCC → 3.3V (or 5V)

3) GND → GND

4) Data → GPIO pin (configured in CubeMX)

5) Pull-up Resistor (4.7kΩ) between Data and VCC

6) 16x2 LCD Display:

7) The LCD display uses I2C communication, which simplifies wiring. The I2C interface uses two pins: SDA (data) and SCL (clock). Connect these pins from the STM32F103C8T6 to the corresponding pins on the LCD, with appropriate pull-up resistors (typically 4.7kΩ).


 LCD Connections:

2) SDA → I2C Data pin (from STM32)

3) SCL → I2C Clock pin (from STM32)

4) VCC → 5V

5) GND → GND

6) EEPROM or SD Card:

7) For storing data, we will use an external EEPROM or an SD card module. This is an optional feature depending on how much data you need to log. The SD card uses SPI or SDIO communication, while the EEPROM usually communicates via I2C or SPI.

1) EEPROM Connections:

2) SDA → I2C Data pin (from STM32)

3) SCL → I2C Clock pin (from STM32)

4) VCC → 3.3V

5) GND → GND

6) SD Card Connections (if using SPI):

7) MISO, MOSI, SCK, CS → SPI pins on STM32


3. Writing the Code

Now that the hardware is set up, we can begin programming the STM32F103C8T6. Here's a breakdown of the code:

Initialization:

Initialize the I2C peripheral for communication with the LCD. Initialize the GPIO pin for the 1-Wire interface to communicate with the DS18B20 temperature sensor.

1-Wire Protocol:

Implement the 1-Wire protocol to read temperature data from the DS18B20 sensor. This involves sending a command to the sensor to start a conversion and then reading the raw temperature data. You can use the STM32 HAL library to make this process easier.

Reading Temperature Data:

Once the temperature is converted, the DS18B20 provides the result as a 16-bit value that needs to be processed into a human-readable temperature.

Logging the Data:

Store the temperature readings in EEPROM or an SD card, depending on the storage option you have selected. If you choose to log to EEPROM, you can store the data periodically, while the SD card may allow you to store more data for extended periods.

Display on LCD:

The temperature data can also be displayed on a 16x2 LCD screen. To do this, you’ll need to use the I2C interface to communicate with the LCD.

Data Upload:

Optionally, you can add functionality to upload the logged data to a computer via UART or even display it in real-time.


4. Sample Code Snippets

Here is a simplified version of the code to get you started:

#include "stm32f1xx_hal.h"
#include "ds18b20.h"  // Custom library for DS18B20
#include "lcd_i2c.h"  // Custom library for LCD

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
static void MX_USART1_UART_Init(void);

I2C_HandleTypeDef hi2c1;
UART_HandleTypeDef huart1;

int main(void)
{
  HAL_Init();
  SystemClock_Config();
  
  MX_GPIO_Init();
  MX_I2C1_Init();
  MX_USART1_UART_Init();
  
  DS18B20_Init();  // Initialize DS18B20 sensor
  LCD_Init();      // Initialize LCD
  
  char temp[10];
  
  while (1)
  {
    float temperature = DS18B20_ReadTemperature();
    sprintf(temp, "Temp: %.2fC", temperature);
    LCD_DisplayString(temp);  // Display temperature on LCD

    HAL_UART_Transmit(&huart1, (uint8_t*)temp, strlen(temp), 1000);  // Optionally transmit via UART
    HAL_Delay(1000);  // Delay for 1 second
  }
}

void SystemClock_Config(void)
{
  // System Clock Configuration (auto-generated by STM32CubeMX)
}

static void MX_GPIO_Init(void)
{
  // GPIO Initialization (auto-generated by STM32CubeMX)
}

static void MX_I2C1_Init(void)
{
  // I2C Initialization (auto-generated by STM32CubeMX)
}

static void MX_USART1_UART_Init(void)
{
  // UART Initialization (auto-generated by STM32CubeMX)
}

5. Testing the System

Once the code is programmed into the STM32F103C8T6, it’s time to test the system. Power on the circuit and monitor the LCD screen. You should see the temperature displayed in real-time. If you have implemented data logging, the system will store the readings in EEPROM or SD card, which can later be accessed or analyzed.


Conclusion

This project provides a solid introduction to working with the STM32F103C8T6 microcontroller. By completing this temperature logger project, you will learn how to interface with sensors, use communication

 

Key words: STM32F103C8T6

participate in discussions

New customer

Please login ? to participate in the comments

New customer Start here.

Submit

Comments

Toll-Free Call

(888) 766 5577 USA & Canada

+52 5515436027
+52 5515436028 Mexico

+49 6931090199 Germany

Whatsapp

+1 (657) 605-6198 USA

+49 15217848563 Germany

+52 55 7637 4368 Mexico

Email

sales@utsource.com

GLOBAL PAYMENTS

Global logistics

footShip
Copyright © 2022 Power by UTSOURCE HOLDING COMPANY LIMITED ISO/IEC 20000-1:2011,ISO/IEC 27001:2013 鄂ICP备2021003526号-1