 // Example testing sketch for various DHT humidity/temperature sensors
 // Written by ladyada, public domain
+
+#define DHT_DEBUG
 
 #include "VirtualWire.h"
 #include "DHT.h"
 
-#define POWERPIN 5 // power for DHT sensor
-#define DHTPIN 6 // data pin for DHT sensor
-#define RFTXPIN 12 // data pin for RF Transmission
+// pins
+#define BUTTONPIN 2
+#define SENSOR_POWER_PIN 5              // power for DHT sensor
+#define DHTPIN 6                        // data pin for DHT sensor
+#define RFTX_PIN 12                     // data pin for RF Transmission
+#define THERMISTOR_PIN 0                // analog pin of the thermistor
 
-#define DHTTYPE DHT22   // DHT 22  (AM2302)
+// other config options
+#define RFTX_RATE 2000                  // bits per second
+#define DHTTYPE DHT22                   // DHT 22  (AM2302)
+#define SENSOR_POWER_HEATUP_DELAY 500   // wait for power stabilization
 
-char* sensor_id = "Sensor1";
-const int transmit_pin = 12;
+char* sensor_id = "Sensor1"; // TODO: this will be later loaded from EEPROM
 
 DHT dht(DHTPIN, DHTTYPE);
 
 void setup() {
-  Serial.begin(9600);
-  Serial.println("DHTxx test!");
+  
+  #ifdef DHT_DEBUG
+    Serial.begin(9600);
+  #endif
+  
+  DEBUG_PRINT("Hello, I'm sensor: ");
+  DEBUG_PRINTLN(sensor_id);
 
-  Serial.print("Powering DHT22 from pin ");
-  Serial.println(POWERPIN);
-  pinMode(POWERPIN, OUTPUT);
-
-  vw_set_tx_pin(transmit_pin);
-  vw_setup(2000); // Bits per sec
+  DEBUG_PRINT("Powering sensors from pin ");
+  DEBUG_PRINTLN(SENSOR_POWER_PIN);
+  pinMode(SENSOR_POWER_PIN, OUTPUT);
 
   dht.begin();
 
-  Serial.println("Setting up RF TX module");
-//  vw_set_tx_pin(RFTXPIN);
-//  vw_setup(2000); // Bits per sec
+  DEBUG_PRINT("Setting up RF TX module on pin ");
+  DEBUG_PRINT(RFTX_PIN);
+  DEBUG_PRINT(" using bitrate ");
+  DEBUG_PRINTLN(RFTX_RATE);
+  
+  vw_set_tx_pin(RFTX_PIN);
+  vw_setup(RFTX_RATE);
 }
 
 void loop() {
 
-  digitalWrite(POWERPIN, LOW);
+  digitalWrite(SENSOR_POWER_PIN, LOW);
 
   // Wait a few seconds between measurements.
   delay(2000);
-  digitalWrite(POWERPIN, HIGH);
-  delay(500); // wait for stabilisation
+  digitalWrite(SENSOR_POWER_PIN, HIGH);
+  delay(SENSOR_POWER_HEATUP_DELAY); // wait for stabilisation
 
   // Now reading value from termistor
-  double temp = Thermister(analogRead(0));
-  Serial.print("Thermistor: ");
-  Serial.print(temp);
-  Serial.print(" °C, ");
+  const double temp = thermistor_to_temp(analogRead(THERMISTOR_PIN));
+  DEBUG_PRINT("Thermistor: ");
+  DEBUG_PRINT(temp);
+  DEBUG_PRINT(" °C, ");
 
   // Reading temperature or humidity takes about 250 milliseconds!
   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
-  float h = dht.readHumidity();
-  float t = dht.readTemperature();
+  const float h = dht.readHumidity();
+  const float t = dht.readTemperature();
 
-  // Check if any reads failed and exit early (to try again).
-  if (isnan(h) || isnan(t)) {
-    Serial.println("Failed to read from DHT sensor!");
-    return;
-  }
+//  // Check if any reads failed and exit early (to try again).
+//  if (isnan(h) || isnan(t)) {
+//    Serial.println("Failed to read from DHT sensor!");
+//    return;
+//  }
 
-  // Compute heat index in Celsius (isFahreheit = false)
-  float hic = dht.computeHeatIndex(t, h, false);
+  DEBUG_PRINT("DHT-Temp: ");
+  DEBUG_PRINT(t);
+  DEBUG_PRINT(" °C, ");
+  DEBUG_PRINT("DHT-Hum: ");
+  DEBUG_PRINT(h);
+  DEBUG_PRINTLN(" %");
 
-  Serial.print("DHT-Temp: ");
-  Serial.print(t);
-  Serial.print(" °C, ");
-  Serial.print("DHT-Hum: ");
-  Serial.print(h);
-  Serial.print(" %, ");
-  Serial.print("Heat idx: ");
-  Serial.print(hic);
-  Serial.print(" °C");
-  Serial.println();
-
-  char msg[32];
+  // Now sending a the message through RF module
+  char msg[32]; // this buffer is used for sending messages through the RF module
   sprintf(msg, "%s %d.%d %d.%d %d.%d",
     sensor_id,
     (int) temp, frac2(temp),

  );
  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx(); // Wait until the whole message is gone
  Serial.println(msg);
}

int frac2(double x) {

 * Reads the voltage from a 10K thermistor and transforms
 * it into temparature (celsius).
 */
double thermistor_to_temp(int RawADC) {
  double Temp;
  // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
  Temp = log(((10240000 / RawADC) - 10000));
