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

14 Comments

  1. wemerson vitor silva

    How to do for connect AC current sensor 100A:50mA SCT 013?

    • hello,

      I have added a connection scheme in the web site:
      http://andruino.it/connections/#ACSensor

      In your case, the turn ratio of the SCT013 is 100/0,05=2000 (as the example in the picture), so you can use 270ohm resistor.
      To have more accuracy, measure using a tester the real value of the resistor used and modify the sketch IRMS.ino (IRMS0_RSENSE 270)

      Open IRMS.ino
      #define IRMS_CTRATIO 2000 //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 270 //Rsense used for Hall sensor (lights)
      #define IRMS1_RSENSE 264 //Rsense used for Hall sensor (plugs)

      If you will use only one AC sensor, you can comment the second sensor.
      Open 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
      // else
      // Arduino_User_var[6].value = irms_CurrentIrms(IRMS1_ADC_CH, IRMS_CTRATIO, IRMS1_RSENSE, 500, ADC_STEP); //read power from plugs
      // swap_timer = !swap_timer;

      bye,
      Andrea

  2. Hello, Andrea!! Thanks for a good app. Can you help me to write a sketch for ds18b20 on iboard pro.(only part for few ds18b20) Thanks. Sorry for my bad English.

    • Hello Roman,

      try to follow the above guide: http://andruino.it/connections/#DS18B20

      1. connect the Dallas sensor as the schematic in the figure
      2. open the file “SET_CONFIG.ino”: and enable #define Dallas_DS18B20 1
      3. if you are using a different pin, change it changing the file “SENSORS.ino”: #define ONE_WIRE_BUS 4 (4 is digital pin4)
      4. compile and upload the sketch on Arduino
      5. Open the App and add a new sensor as DS18B20, select variable number 7

      for multiple sensors on the same digital pins:
      1. connect more than one DS18B20 on the same line
      2. uncomment the following: (SENSOR.ino)
      Arduino_User_var[7].value = sensors.getTempCByIndex(0);
      Arduino_User_var[8].value = sensors.getTempCByIndex(1);

      let me know,

      bye,
      Andrea

  3. jean-philippe MOTTE

    Hi andrea,when i enable nrf24 (1) in the sketch, the iphone app won’t connect to arduino board, when i disable it, it works fine.

    • Hi Jan,
      please check the NRF connection and send me the serial monitor datalogs,
      To understand the connections between the NRF base and the NRF node, send the two serial monitors to understand if the NRF24L modules are running correctly,
      thanks,
      Andrea

  4. jean-philippe MOTTE

    Hi Andrea,At this moment i have a nrf connection, and i can activate a relay but only with basic module. I have a command error in the arduino serial monitor, when i use the modules with PA and LNA, there is connection but i can\\’t interact with the relay. May be another hardware problem, i waiting for 2 new module to test. Thanks for the support.

    • ok,
      if you are using the NRF with PA, you have to supply it with an external power supply (3,3V, minimum of 200mA). The 3.3V from the Arduino board is not capable to supply it.
      let me know,
      Andrea

  5. Ciao Andrea, volevo capire che utilizzi si possono fare con il sensore KY-022 Infrared IR. Grazie

    • ciao,
      non conosco il sensore ma sicuramente puoi usare ad esempio un telecomando IR per accedere luci o altro,
      Quindi il telecomando manda una sequenza che viene riconosciuta da Arduino e in base ad una tabella attiva o disattiva dei relè.

      generalmente io consiglio di trovare uno sketch esempio e poi integrarlo nello sketch Andruino,

      bye
      Andrea

  6. Ciao Andrea, sto cercando di connettere arduino con ESP8266.Il mio adattatore https://www.banggood.com/ESP8266-Serial-Wi-Fi-Wireless-ESP-01-Adapter-Module-3_3V-5V-Compatible-For-Arduino-p-1047322.html?rmmds=detail-top-buytogether non ha il pin di reset.Come posso collegarlo? E\\\\\’ necessario? Continuo ad avere questa risposta nel serial monitor:BOARD:arduinoEsp8266 init…[WiFiEsp] Initializing ESP module[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] Cannot initialize ESP module[WiFiEsp] >>> TIMEOUT >>>[WiFiEsp] No tag foundWiFi not presentGrazie saluti Fabio

    • ciao Fabio,
      hai ragione, purtroppo l’adattatore che hai comprato non ha il level shifter per il reset, dallo schema vedo che il pin è lasciato floating, quindi non pilotato.
      Devi mettere un partitore di tensione fra il pin di uscita dell’arduino (default sketch #define ESP8266_RESET_PIN 20). Il partitore deve portare 5v a 3.3V circa, quindi io suggerisco come da schema http://andruino.it/connections/#ESP8266
      di mettere una resistenza da 1K in serie e poi una da 2,2K verso massa (o due in serie da 1K).

      aggiornami sullo stato,
      bye,
      Andrea

Leave a Reply

Your email address will not be published. Required fields are marked *

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box