No data from Fermion C4002 to FireBeetle 2

userHead Matha.Goram 2026-08-01 21:21:53 7 Views0 Replies

Hello!

 

I need some newbie guidance, please!

 

While using VIN for the C4002 sensor and connecting the sensor's TX to FireBeetle 2's 17 and the sensor's RX to 16 (hardwired), I get the following output in the Serial Monitor window:
 

[TIMEOUT] No data received for 10 seconds. Swapping pins...
[CONFIG] Reverting to Normal Pinout -> RX: 17 | TX: 16


[TIMEOUT] No data received for 10 seconds. Swapping pins...
[CONFIG] Trying Swapped Pinout -> RX: 16 | TX: 17
 

The baud rate is 115200 for the window and the sensor. I was successful with the sensor at 9600 temporarily with a blind loop-back test. I have tried pins 4 & 5 and 18 & 19 but it was more like whistling in the dark.

 

The FireBeetle 2 passes many, many non-UART tests. I haven't been able to do anything with the C4002. I have posted my code below for guidance and feedback. Thanks.

 

Regards.

 

#include <Arduino.h>

#define C4002_RX_PIN 17
#define C4002_TX_PIN 16
#define C4002_BAUD   115200

void setup() {
 Serial.begin(115200);
 delay(2000);

 Serial.println("\n[STEP 2] Auto-Swap & Hardware Warm-up Routine...");

 // Implement a customized countdown window that overrides the sensor's baseline hardware reset timing loop
 Serial.println("[WAIT] Executing customized countdown window for sensor baseline reset and warm-up...");
 for(int i = 15; i > 0; i--) {
   Serial.printf("... %d seconds remaining\n", i);
   delay(1000);
 }
 Serial.println("[WAIT] Warm-up complete.");

 // Start with the standard pin mapping
 Serial.printf("[CONFIG] Trying Normal Pinout -> RX: %d | TX: %d\n", C4002_RX_PIN, C4002_TX_PIN);
 Serial1.begin(C4002_BAUD, SERIAL_8N1, C4002_RX_PIN, C4002_TX_PIN);
}

void loop() {
 static unsigned long lastSwitch = millis();
 static bool swapped = false;

 // Check for incoming data
 if (Serial1.available()) {
   uint8_t incomingByte = Serial1.read();
   Serial.printf("%02X ", incomingByte);
   lastSwitch = millis(); // Reset the flip timer because we have a successful connection
 }

 // If 10 seconds pass with absolutely zero data, automatically flip the pins in software
 if (millis() - lastSwitch > 10000) {
   swapped = !swapped;
   Serial.println("\n\n[TIMEOUT] No data received for 10 seconds. Swapping pins...");

   Serial1.end();
   delay(500);

   if (swapped) {
     Serial.printf("[CONFIG] Trying Swapped Pinout -> RX: %d | TX: %d\n", C4002_TX_PIN, C4002_RX_PIN);
     Serial1.begin(C4002_BAUD, SERIAL_8N1, C4002_TX_PIN, C4002_RX_PIN);
   } else {
     Serial.printf("[CONFIG] Reverting to Normal Pinout -> RX: %d | TX: %d\n", C4002_RX_PIN, C4002_TX_PIN);
     Serial1.begin(C4002_BAUD, SERIAL_8N1, C4002_RX_PIN, C4002_TX_PIN);
   }

   lastSwitch = millis();
 }
}

 

platformio.ini settings:

[base:esp32c6]
; Using the upstream development branch to ensure Arduino framework
; support for the ESP32-C6 architecture.
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = esp32-c6-devkitc-1
framework = arduino
monitor_speed = 115200

 

[base:c6_local_test]
extends = base:esp32c6
upload_protocol = esptool
upload_port = /dev/ttyACM0
monitor_port = /dev/ttyACM0
monitor_rts = 0
monitor_dtr = 0
build_flags =
   -DARDUINO_USB_CDC_ON_BOOT=1
   -DARDUINO_USB_MODE=1
 

[env:fermion_c4002_test_c6]
extends = base:c6_local_test
lib_deps = dfrobot/DFRobot_C4002 @ ^1.0.0
build_flags =
   -D DEVICE_ID=\"${sysenv.WIFI_HOSTNAME_DEFAULT}\"
   -DARDUINO_USB_CDC_ON_BOOT=1
   -DARDUINO_USB_MODE=1
build_src_filter = +<tests/fermion_c4002_test.cpp> -<main.cpp>