Sketch Notes

Basic steps to configure the sketch

(The current sketch is 100% ready for use. The sensors/relays configurations will be done using iPhone AndruinoApp)

You can:

  1. Using the sketch named: ANDRUINO_IOT_SKETCH you can configure a lot of Arduino boards connected to internet (IoT Nodes). Using AndruinoApp, you can control and monitor all the relays and sensors running on the different boards.
  2. ANDRUINO_IOT_SKETCH can be used also as router of an NRF network if you want to use other boards not connected with WiFi but with a NRF24L radio modules . In this case the router will be called “NRF Base” and the others Arduino submodules connected through NRF network will be called “NRF Nodes”.

First step – install the libraries

  • Download the official Arduino IDE. External link
  • Download my latest release of Andruino sketch – Firmware page
  •  and open the folder. You will see above files.
  • Copy all the folder libraries found inside the folder named:(unzip_these_libraries_into_Arduino_libraries_folder) into your Arduino libraries directory.
  • Position (MAC/PC): Documents/Arduino/libraries


Video guides:














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 ArduinoIDE (with USB cable). Attach the ethernet shield to Arduino board.


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 “NRF Node” sketch (for NRF Andruino Network)

The Andruino_Node_Sketch is used to:

  1. Create Andruino “NRF Node Router”
    • Is always awake
    • Read sensors and activate output pins in short time
    • Manage the network packets of the other Nodes
  2. Create Andruino “NRF Node 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 Nodes will be found on pin group selection.

App nrf2

 App nrf1

Comments are closed.