Skip to content

rustyongithub/dB-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

dB Calculator (dBm โ†” mW, Frequency โ†” Wavelength)

A tiny, client-side RF utility that runs in any modern browser. It converts:

  • dBm โ†’ mW
  • mW โ†’ dBm
  • Frequency โ†” Wavelength (in free space)
  • A simple mW โ†’ dB relative to 1 W helper (see notes)

This is the HTML tool you placed at /db-calc.html and also embedded on your portfolio homepage.


๐ŸŽฏ Features

  • Zero dependencies (plain HTML + JavaScript)
  • Instant results, no backend
  • Works offline
  • Minimal UI that fits a portfolio site

๐Ÿงฎ Conversions & Formulas

dBm โ†’ mW

  • Formula: ( P_{\text{mW}} = 10^{\frac{P_{\text{dBm}}}{10}} )
  • Example: 0 dBm โ†’ 1 mW; 30 dBm โ†’ 1000 mW

mW โ†’ dBm

  • Formula: ( P_{\text{dBm}} = 10 \log_{10}(P_{\text{mW}}) )
  • Example: 1 mW โ†’ 0 dBm; 0.1 mW โ†’ โˆ’10 dBm

Frequency โ†’ Wavelength (free space)

  • Formula: ( \lambda = \frac{c}{f} )
  • Where: ( c = 299{,}792{,}458 ) m/s
  • Units: ( f ) in Hz, ( \lambda ) in meters
  • Example: 1 GHz โ†’ 0.299792458 m

Wavelength โ†’ Frequency (free space)

  • Formula: ( f = \frac{c}{\lambda} )
  • Units: ( \lambda ) in meters, ( f ) in Hz
  • Example: 0.5 m โ†’ 599,584,916 Hz (~0.6 GHz)

โ€œConvert to dBโ€ helper (relative to 1 W)

  • Current formula in the tool: 10 * log10(1000 / mW)
    This equals ( 30 - 10\log_{10}(P_{\text{mW}}) ) which is โˆ’dBW (dB relative to 1 W).
    • If you actually want dBW, use ( \text{dBW} = 10\log_{10}(P_{\text{W}}) = 10\log_{10}(P_{\text{mW}}) - 30 ).
    • The current helper is useful when you want the attenuation to 1 W as a positive dB number.

โœ… If youโ€™d like, I can switch this helper to output dBW directly and label it accordingly.


๐Ÿ“ฆ File

  • db-calc.html โ€” Standalone page containing the UI and JS.

๐Ÿš€ Run locally

Just open the file in a browser:

# macOS
open db-calc.html

# Windows
start db-calc.html

# Linux (GNOME)
xdg-open db-calc.html

About

dB Calculator tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages