Electrical conductivity of porous silicon fabricated form heavily doped p-type silicon is very sensitive to NO$_2$, even at concentrations below 100 ppb. However, sensitivity strongly depends on the porous microstructure. The structural difference between sensitive and insensitive samples is independently confirmed by microscopy images and by light scattering behavior. A way to change the structure is by modifying the composition of the electrochemical solution. We have found that best results are achieved using ethanoic solutions with HF concentration levels between 13% and 15%.