Sketch Notes

Basic steps to configure the sketch (you can try it also without Andruino App installed on iPhone)

(The current sketch is 100% ready for use, the minimum requirement is only to adapt the IP address according your home network router. The sensors/relays configurations will be done using iPhone AndruinoApp)

You can:

  1. Use only the Andruino Base Sketch without NRF network. In this case all the sensors/relay has to be connected to the unique Arduino hardware board (NRF disabled)
  2. Use the Andruino Base Sketch enabling the NRF network. In this case you can connect sensors sensors/relay to the Base and have other Arduino boards connected wireless to the Base; these are called Nodes and use the Andruino Node Sketch.

First step – install the libraries (video guide)

  • Download the official Arduino IDE. External link
  • Download my latest release of Andruino sketch – Firmware page
  • Extract  and open the folder. You will see above files.
  • Copy all the .zip files found inside the folder named (unzip_these_libraries_into_Arduino_libraries_folder) into your Arduino libraries directory and unzip them
  • Position (MAC/PC): Documents/Arduino/libraries
  • See the video guide (to be updated with the sketch v8.0)














Andruino Base sketch


From the sketch versions 9, Andruino can work in two different ways:

  1. CLIENT MODE: this is the “Zero Configuration network”. Is not yet necessary to modify the router setting to open the port etc. Andruino is immediatly online
  2. DIRECT or SERVER MODE: old mode, the connection is from AndruinoApp to Arduino board. Is necessary to open the router port to connect over 3G. This can be used if no internet connection is avaiable

CLIENT mode (recommended):

  1. Open “ANDRUINO_BASE_MAIN_SKETCH.ino” with Arduino IDE
  2. Edit these filed:
    1. ANDRUINO_USERNAME_EMAIL: set the email used on Andruino App
    2. ANDRUINO_PIN: set the PIN given by AndruinoApp
    3. ARDUINO_NAMEset the board name (you can use arduino, arduino2, etc)
  3. If ESP8266 shield is used, select the SSID and password of your Wifi network.
  4. GATEWAY_DNS: not enabled by default. You can select a DNS and use it (#define GATEWAY_DNS) if you have network issue




SERVER/DIRECT mode (optional):

  1. Open “ANDRUINO_BASE_MAIN_SKETCH.ino” with Arduino IDE
  2. Opening the file “A_SET_CONFIG.ino” –> #define SERVER_MODE  1 (default)
  3. Configure same above A+B+B point (as CLIENT)
  4. Configure these parameters:
    1. ETHERNET_DHCP: DHCP by default is enabled (leave as default = 1)
    2. byte ip: set the IP address according to your router base IP ( is the default)
    3. ETHERNET_PORT: set the port number (8888 is the default)
  5. GATEWAY_DNS: not enabled by default. You can select a DNS and use it (#define GATEWAY_DNS) if you have network issue



NOTES about network (only for Server/Direct mode):

  • The MAC address should be unique, if you have two or more Arduino change the last digit.
  • Adapt the IP number according to your local network.
  • If your router address is
    • this is your gateway IP Address (
    • Your Arduino IP can be
  • PORT: can be 8888 or others
  • PORT FORWARDING for SERVER/DIRECT mode: remember that if you want to see your Arduino from internet (WAN) you have to open the port (ex: 8888). Enter in your modem setup and configure the  port-forwarding to connect the port to the internal address (ex:8888 attached to
  • DDNS: with AndruinoApp the DDNS is automatically managed using the “ddns” option in the network config. panel.


Sketch configuration files: PINS and SENSOR

  • A_SET_CONFIG.ino: used to select the right shield or the sensor libraries
  • B_SET_NETWORK.ino: configure the SERVER/DIRECT mode (above list)
  • C_SET_PIN.ino: choose the PIN used as INPUT and OUTPUT. Select the inversion is is needed


Save and upload it in your Arduino board using the official Arduino sdk (with USB cable). Attach the ethernet shield to Arduino board and plug the cable RJ45 to the router


NOTE: in SERVER/DIRECT mode you can try without App, only with the browser:

Open the web browser and type the url:

The browser will respond with JSON protocol displaying the analog/digital Arduino channels.
Now, you can use Andruino App to communicate with Arduino board.

JSON string




Andruino Node sketch (for NRF Andruino Network)

The Andruino_Node_Sketch is used to:

  1. Create Andruino Router
    • Is always awake
    • Read sensors and activate output pins in short time
    • Manage the network packets of the other Nodes
  2. Create Andruino Leaf
    • After 60 seconds it will go in sleep mode
    • Can activate output pins but after a latency
    • Can work with batteries (3V) but for now the consumption is not low…. 🙁 (T.B.D.)


See above picture to understand Base, Node as Router and Node as Leaf:

  1. 00 is the Base
  2. 04,01,014,114 are Router
  3. 024,1114,2114 are Leaf



Sketch configuration: NRF Network

Open Andruino_Node_Sketch.ino

  1. #define  DEFAULT_NODE_ADDRESS  1      —> means that you are configuring the node with the first level of hierarchy (02)
  2. bool  FORCE_NODE_ADDRESS =  false;       —> means that the first time the address is kept by DEFAULT_NODE_ADDRESS, but after is read from flash. (so, after the first programming you can’t touch these field so each node will maintain its address. This is used to speed-up the firmware update)
  3. node_e  NODE_CONFIG = ROUTER;    —> this is to configure the node as ROUTER or as LEAF


Sketch configuration: PINS and SENSOR

don’t use PIN: 2,7,8,11,12,13 (0 and 1 are used for serial port, so can be used for serial debug or as pins, 11, 12, 13 for SPI, 2 for interrupt on LEAF node, 7,8 as CE and CSN of NRF)

  1. uint8_t digital_pins[] = {3, 4, 5, 9};                      PINS 3,4,5,9 used as digital
  2. bool digital_pins_inv[]  = {0, 0, 0, 0, 1};                 PIN 3,4,5 are in direct logic (OFF=0V, ON=5V), 9 is inverted logic (OFF=5V, ON=0V)
  3. bool digital_pins_mode[] = {I, I, O, O};  pin 3,4 as INPUT, PINS 5,9 as OUTPUTS
  4. uint8_t analog_pins[] = {0,1,2,3};                          Analog pins A0,A1,A2,A3 used

this will be the configuration:

  • PIN3 —> INPUT
  • PIN4 —> INPUT
  • PIN5 —> OUTPUT
  • PIN9 —> OUTPUT
  • A0,A1,A2,A3: analogs

About the Hardware node, I’m using this one, but you can build it using an Arduino nano or UNO:

Andruino App with NRF

the new sketches will work with the new App 2.3. The Nodes will be found on pin group selection.

App nrf2

 App nrf1


  1. jean-philippe MOTTE

    Hi Andrea,

    If i want to implement my own sensor (in that case a soil moisture sensor), can i add my code to arduino node scketch ? and where ?



    • hello,

      yes, for sure,

      if you open the NODE sketch, there is the main loop:

      void loop() {

      you can go to the ReadSensors() function and add your code there:

      void ReadSensors() {

      unsigned long now = millis();
      if ( now – last_time_check < INTERVAL_SENSOR ){ return; } last_time_check = now; .. .. .. add your code of the moisture sensor as is done for the other sensors, like the DHT22, let me known, 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