This example demonstrates how to use a CH32V003 microcontroller to communicate with DS18S20, DS1820, DS18B20, or DS1822 temperature sensors using the OneWire protocol. The CH32V003 is a cost-effective 48 MHz RISC-V microcontroller with 16kB of flash and 2kB of RAM, suitable for various applications.
- Searches for temperature sensors on Pin C4.
- Iterates over each sensor to prompt a temperature read.
- Waits for the read to occur and then prints the temperatures.
- Utilizes
printf()
over the CHLINK single-wire serial interface for output.
- For detailed installation instructions of the development environment, refer to the ch32v003fun project wiki.
- The project supports
printf
debugging and gdbserver-style debugging via minichlink. - Building and flashing instructions can be found in the
examples/blink
directory.
SWIO
onPD1
is required for programming/debugging.PC4
connected to DS18x20 sensor data. (Don't forget the external pull-up resistor to VCC)
- For more examples and third-party tools, check out ch32v003fun_wildwest and ch32v003fun_libs.
- Join the Discord community for support and discussion.
- Setting up the Development Environment for CH32V003: Compile and Run first example code
- CH32V003: GPIO as Output
- CH32V003: GPIO as Input (Polling, Interrupt)
- CH32V003: UART Transmit / Receive data
- CH32V003: PWM output with Frequency and Duty Cycle Control
- CH32V003: ADC for analog signal measurement
- CH32V003: I2C Interface
- CH32V003: SPI Interface
- CH32V003: Timer Interrupt
- CH32V003: How to read 64-bit Unique ID
- The example is compatible with DS18S20, DS1820, DS18B20, and DS1822 temperature sensors.
- The simplified Maximum OneWire library is designed to efficiently handle communication with multiple sensors over a single wire.
- The CH32V003 operates at different performance levels depending on whether it runs from RAM or FLASH due to varying wait states.
- For further technical details, refer to the Debugging Manual and Processor Manual.
- An external oscillator was used during testing.
- CH32V003 Microcontroller Details
- Features a 48MHz system main frequency, 2KB SRAM, 16KB Flash.
- Includes a variety of peripherals such as USART, I2C, SPI, ADC, and timers.
- Offers multiple low-power modes and a 1-wire serial debug interface.
In a tiny world of silicon and wire,
Lives a microcontroller, CH32V003, with a desire.
To speak in tongues of RISC-V, so clear,
Whispering to sensors, both far and near.
Through OneWire it travels, a single thread,
Carrying tales of temperatures, both blue and red.
"Too hot or cold?" the sensors keenly measure,
In a dance of bytes, they find their treasure.
In this realm of circuits, small and spry,
Micro wonders unfold, under the digital sky.