Connections

 


Connect DHT22 temperature sensors

Code enable:

  • #define THERMO_ADAFRUIT_DHT     1
  • #define THERMO_ADAFRUIT_DHT2   1 (for a second DHT22)

Arduino PINS:

  • PIN2 (digital data line). Can be changed modifying the #define (see picture)
  • VDD (5V), GND
  • Pullup resistor (10Kohm)

AndruinoApp sensor:

  • add a new sensor (DHT11/22 temp/umidity)
  • select variable N0 for humidity
  • select variable N1 for temperature

temperature_dht22_bb


Connect DS18B20 Dallas temperature sensors

Code sketch enable:

  • #define Dallas_DS18B20  1
    • Arduino_User_var[7].value = sensors.getTempCByIndex(0);       //first DS18B20 sensor
    • Arduino_User_var[8].value = sensors.getTempCByIndex(1);       //uncomment it to have more than one sensor on the same digital line
  • #define ONE_WIRE_BUS 4
    • Used to change the digital pin connected to the DS18B20 (PIN4 is the default)

NOTE: if you use for example PIN4 (ONE_WIRE_BUS 4), you have to skip it from the device pin list (delete pin4 from SET_PIN.ino):

const byte base_digital_pins_used[]     = {2,3,4,5,6,7,8,9,10,13,14,15,16,17,21,22,23,24,25,26};          //pin number used (pins can be not sequencial)
const bool base_digital_pins_inv_used[] = {0,0,0,0,0,0,0,0,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 , 0};          //=1 if the pin has to be INVERTED POLARITY, 0 standard (DIG21 is inverted for example)
const byte base_digital_pins_mode_used[]= {I,P,O,O,O,O,O,I,O ,O ,O ,O ,O ,O ,O ,I ,I ,I ,I , O};          //I=INPUT, O=OUTPUT, P=PWM (pins can be not sequencial)

 

Arduino PINS:

  • PIN4 (digital data line). Can be changed modifying the above #define
  • VDD (5V), GND
  • Pullup resistor (4,7 Kohm)

AndruinoApp sensor:

  • add a new sensor (DS18B20)
  • select variable 7 (var 8 for other DS18B220 on the same line)

temperature_dallas_bb


Connect LM35 Analog temperature sensors

Code enable:

  • not necessary

Arduino PINS:

  • Ao (analog line). Can be one of the analog channels
  • VDD (5V), GND

AndruinoApp sensor:

  • add a new sensor (Analog TMP35/36/37)
  • select analog channel connected to the sensor (A0 as below, but can be changed)

temperature_lm35_bb


Connect a non invasive AC current sensor to measure the home power consumption

Code enable:

#define POWER_CONSUMPTION_ENABLE     1 (by default enable two power sensors)

from IRMS.ino

  • #define IRMS_CTRATIO 2000          //parameter from sensor data sheet (turn ratio)
  • #define IRMS0_ADC_CH 0               //ADC channel used for lights
  • #define IRMS1_ADC_CH 1                //ADC channel used for Plugs
  • #define IRMS0_RSENSE 384          //Rsense value used for Hall sensor (lights)
  • #define IRMS1_RSENSE 264           //Rsense value used for Hall sensor (plugs)

from SENSORS.ino

if (swap_timer == 0)
Arduino_User_var[5].value = irms_CurrentIrms(IRMS0_ADC_CH, IRMS_CTRATIO, IRMS0_RSENSE, 500, ADC_STEP); //read power from lights (first)
else
Arduino_User_var[6].value = irms_CurrentIrms(IRMS1_ADC_CH, IRMS_CTRATIO, IRMS1_RSENSE, 500, ADC_STEP);   //read power from plugs (second, comment if not used)

 

Arduino PINS: (for two power sensors)

  • A0. Can be changed modifying the #define (above IRMS0_ADC_CH)
  • A1. Can be changed modifying the #define (above IRMS1_ADC_CH)

AndruinoApp sensor:

  • add a new sensor (power consumption)
  • select variable Var5 to read the power from lights
  • select variable Var6 to read the power from plugs

power_consumption_bb


Connect NRF24L (Network Base Unit) to Arduino MEGA2560

Code enable:

  • #define NRF24L_ENABLE               1

Arduino PINS:

  • RF_CSN pin: Arduino Mega PIN48 (can be changed by #define)
  • RF_CE pin: Arduino Mega PIN49 (can be changed by #define)
  • SPI:
    • RF_MISO pin: Arduino Mega PIN50
    • RF_MOSI pin: Arduino Mega PIN51
    • RF_SCK pin: Arduino Mega PIN52
  • RF_IRQ pin: not necessary for Arduino Mega

NOTE: suggested wires lenght is 10-15 cm

andruino-nrf_bb

 

 

 

 

 

 


Connect NRF24L (Network Node Unit) to Arduino UNO

Arduino PINS:

  • RF_CSN pin: Arduino UNO PIN7 (can be changed by #define)
  • RF_CE pin: Arduino UNO PIN8 (can be changed by #define)
  • SPI:
    • RF_MISO pin: Arduino UNO PIN12
    • RF_MOSI pin: Arduino UNO PIN11
    • RF_SCK pin: Arduino UNO PIN13
  • RF_IRQ pin: necessary only for Node configured as leaf (auto wakeup)

NOTE: suggested wires lenght is 10-15 cm

andruino-nrf_node_bb


Connect ESP8266 (wifi connection) to Arduino MEGA2560

Code enable:

  • #define WIFI_ESP8266_SHIELD         1

 

Arduino PINS:

  • TX (esp): D19 (RX1 Arduino Mega)
  • RX (esp): D18 (TX1 Arduino Mega)  —> using a level shifter 5V to 3.3V
  • PD (esp): 3.3V
  • RST (esp): D20 (used to reset ESP8266), you can change it according to the sketch, find: ESP8266_RESET_PIN
  • VCC (esp): 3.3V (since that are needed 200mA, an external regulator is mandatory)
  • GND (esp): 0V
  • GPIO2,GPIO0 (esp): floating

NOTE: suggested wires lenght is 10-15 cm

 

 

andruino-esp8266_02_bb

TIP:

To avoid external components, can be used a Breadboard Adapter Level Converter 3.3V- 5V: link

Using this adapter, the wires can be connected directly from Arduino Mega to it.

adp-01

Comments are closed.