🧪 New tutorials are being published — build from robot arms to sensors step by step
Skip to content

PC · Running Python ​

Contents ​

  1. Hardware preparation
  2. Hardware connection
  3. Software environment setup
  4. Running the example program
  5. FAQ

Hardware Preparation ​

Required Materials ​

MaterialDescription
JUXI_HeartRate_SPO2 sensorHeart rate & SpO2 module
USB-to-TTL moduleCH340 / CP2102 / FT232, etc.
Jumper wires4 (female-to-female)
Windows computerWin7/Win10/Win11

Hardware Connection ​

Wiring ​

Sensor pinUSB-to-TTL pinDescription
VCC3.3V or 5VPower positive
GNDGNDPower negative
TXRXSensor transmit → module receive
RXTXSensor receive → module transmit

Illustration

⚠️ Important notes:

  1. Slide the module switch to UART!!!
  2. TX and RX must be cross-connected!
  3. The sensor supports 3.3V and 5V; do not connect the wrong voltage
  4. Connect all wires first, then plug the USB into the computer

Wiring Diagram ​

text
传感器        USB转TTL模块
┌──────┐      ┌──────────┐
│ VCC  │──────│ 3.3V/5V  │
│ GND  │──────│ GND      │
│ TX   │──────│ RX       │  ← 交叉连接
│ RX   │──────│ TX       │  ← 交叉连接
└──────┘      └──────────┘

Software Environment Setup ​

Installing the Driver ​

Install the corresponding driver according to your USB-to-TTL chip model:

After installation is complete, plug in the USB-to-TTL module.

Checking the COM Port ​

Method 1: Device Manager ​

  1. Press Win + X and select "Device Manager"
  2. Expand "Ports (COM & LPT)"
  3. Find the COM port number corresponding to your USB-to-TTL adapter (e.g., COM3)

Method 2: Automatic Detection ​

When running the example program, all available serial ports are listed automatically.

Installing Python Dependencies ​

Open Command Prompt (CMD) or PowerShell and run:

bash
pip install pyserial

Running the Example Program ​

Download the archive JUXI_HeartRate_SPO2.zip and extract it

File Location ​

text
JUXI_HeartRate_SPO2/python/windows/
├── gain_heartbeat_SPO2.py  ← 主程序(直接运行这个)
├── JUXI_HeartRate_SPO2_Windows.py
├── JUXI_RTU_Windows.py
└── README_CN.md        ← 本文件
└── README.md

Run Steps ​

  1. Confirm the hardware connection is correct
  • VCC → 3.3V/5V
  • GND → GND
  • TX → RX (crossed)
  • RX → TX (crossed)
  1. Plug the USB into the computer
  2. Run the program
bash
cd D:\JUXI_HeartRate_SPO2\python\windows
bash
python gain_heartbeat_SPO2.py
  1. Follow the prompts
  • The program lists all available serial ports
  • Enter your COM port number (e.g., COM3)
  • The program automatically detects the sensor and starts measuring

Expected Output ​

python
==================================================
JUXI Blood Oxygen Sensor - Windows Test
==================================================
Available serial ports:
  COM3

Please enter the COM port number (e.g., COM3):

Connecting to COM3 at 9600 baud...
Initializing sensor...
Sensor initialized successfully!

Starting data collection...
Sensor LED should be ON now!

Place your finger on the sensor...

SPO2 (血氧): 97 %
Heart Rate (心率): 82 BPM
Temperature (温度): 26.5 °C
SPO2 (血氧): 98 %
Heart Rate (心率): 78 BPM
Temperature (温度): 26.6 °C
...

Press Ctrl + C to stop the program.


Program Features ​

Main API ​

bash
# 创建传感器对象
sensor = BloodOxygenSensor("COM3", 9600)

# 初始化传感器
sensor.begin()

# 开始采集(LED亮起)
sensor.sensor_start_collect()

# 读取心率血氧
sensor.get_heartbeat_SPO2()
print(f"SPO2: {sensor.SPO2}%")
print(f"Heart Rate: {sensor.heartbeat} BPM")

# 读取温度
temp = sensor.get_temperature_c()

# 停止采集(LED熄灭)
sensor.sensor_end_collect()

# 关闭串口
sensor.close()

FAQ ​

Q1: What should I do if the COM port cannot be found? ​

A:

  1. Check whether the USB-to-TTL adapter is plugged in properly
  2. Reinstall the driver
  3. Try another USB port
  4. Check Device Manager for any "Unknown device"

Q2: What should I do if sensor initialization fails? ​

A:

  1. Check the wiring:
  • Whether VCC and GND are connected correctly
  • Whether TX and RX are cross-connected (the most common problem)
  1. Confirm the baud rate is 9600
  2. Check whether the USB-to-TTL module works properly
  3. Unplug and replug the USB

Q3: What should I do if the data keeps showing -1? ​

A:

  1. Confirm your finger is placed correctly on the sensor (completely covering the LED area)
  2. Keep your finger steady and do not move
  3. Wait a few seconds for the data to stabilize
  4. Check whether the sensor LED is on

Q4: The LED is off but communication works? ​

A:

  • It may be an LED hardware problem, but the sensor functions normally
  • As long as the data is normal, the LED being off can be ignored

Q5: What should I do if the serial port is occupied? ​

A:

  1. Close other serial software (serial assistant, Arduino IDE, etc.)
  2. Check whether another Python program is running
  3. Unplug and replug the USB

Q6: What should I do if the data is inaccurate? ​

A:

  1. Make sure your finger completely covers the sensor's optical area
  2. Stay quiet during measurement; do not talk or move
  3. Wait more than 30 seconds for the data to stabilize
  4. Take multiple measurements and average the results

Technical Specifications ​

ParameterSpecification
CommunicationUART (TTL level)
Baud rate9600 bps (default)
Data format8N1 (8 data bits, no parity, 1 stop bit)
Supply voltage3.3V / 5V
SPO2 measurement range35% - 100%
Heart rate measurement range30 - 250 BPM
Modbus device address0x20

Modbus Registers ​

Register addressFunctionDescription
0x02Device IDRead: returns 0x0020
0x06-0x09Heart rate & SpO2 dataRead: SPO2 + heart rate
0x0ATemperatureRead: onboard temperature
0x10Collection controlWrite: 0x0001=start, 0x0002=stop