Mathematical calculations were not calculated or displayed in terminal

I am calculating the capacitance time constant on a nRF52840 Dongle module, where i am able to get the time needed in microseconds. But the programme doesn’t want to calculate or show the complex divisions and multiplications.

here is my code output :

2024-08-28 00:48:35,597 # Start Time: 398216022
2024-08-28 00:48:35,597 # End Time: 398216115
2024-08-28 00:48:35,597 # Elapsed time: 93 microseconds
2024-08-28 00:48:35,597 # Elapsed time to sec: 
2024-08-28 00:48:35,597 # Tau: 
2024-08-28 00:48:35,597 # Capacitance:  pF
2024-08-28 00:48:35,597 # Capacitance Measurement:  pF

here is my code :

    // Convert elapsed time to seconds
    float elapsed_time_sec = elapsed_time / 1000000.0f;
    printf("Elapsed time to sec: %f\n", elapsed_time_sec);   // NO OUTPUT

    // Calculating the time constant tau for the capacitor using ln(2) for 50% V
    float tau = elapsed_time_sec / LN2;
    printf("Tau: %f\n", tau);  // NO OUTPUT

    // Calculate capacitance
    float capacitance = tau / R_REFERENCE; // in Farads
    capacitance *= 1e12f; // Convert to picofarads (pF)
    printf("Capacitance: %f pF\n", capacitance);  // NO OUTPUT

here are the include headers

#include <stdio.h>
#include <math.h>
#include <xtimer.h>
#include "periph/gpio.h"
#include <string.h>

I am confused as what is going wrong. where shall i focus on to solve simple issue?

To print floating point numbers, you need to include the printf_float module - or multiply with 1000 and print as an integer.

1 Like