Introduction: An Arduino WiFi Network (Sensors and Actuators) - the Sensor of Color
How many times in your applications do you have some sensor or some actuator far from you? How much could be comfortable use just one master device near your computer to manage different slave devices connected through a wi-fi network?
In this project we will see how to configure a wi-fi network, composed by a master module and one o more slave devices. Each device will be driven by an Arduino Nano and an NRF24L01 wireless module. Finally to show the feasibility of the project we make a simple network where a slave module can detect a color and transmit its RGB model to the master module.
Step 1: The Communication Protocol
The basic idea behind this project is the creation of a network composed by sensor modules and actuator modules, driven by a master module which communicates with the slave through a wi-fi connection.
The master module is connected to the computer through a serial communication and it offers a small interface which allows the user to search the devices connected, to obtain the list of possible operations for each device and to act on them. So the master module does not need, a priori, to know, how many and what kind of devices are connected to the network but it is always able to scan and find the devices and to receive informations from them as their configurations or their characteristics.
The user, at each time, can add or remove the modules from the network and needs only a new scan of the network to start to communicate with the new devices.
In this project we show a simple example of network composed by a master module and by two slaves, the first one is a "Led Module", or rather a simple module, which can switch on a led (red or green), turn off these leds or send information about their status to the master. The second one is a "Sensor Color Module" which, using the color sensor (TCS3200), is able to detect a color and return its RGB model if it receives a command by an user (through a button) or a request by the master module.
Summing up, each device used in this project is composed by a wireless module (NRF24L01) and an Arduino Nano which manages the wireless module and the other simple operations. While the "Led Module" contains two additional leds and the "Sensor Color Module" contains the color sensor and a button.
Step 2: The Master Module
The most important module is the "Master Module" as said, using a small intuitive interface, it manages the communication between user and slave modules connected to the network.
The hardware of the master module is simple and it is composed by few components, in particular there is an Arduino Nano which manages the serial communication with the computer and so with the user, and the communication with the other devices.
This last one is created by the NRF24L01 wireless module, which is connected to the Arduino board using an SPI communication. Finally there are two leds to give to user a visual feedback about data incoming or outcoming by the module.
The electronics board of the master module has a relatively small size, about 65x30x25 mm, so it can be, easily, inserted in a small box. Here the stl files of the box (top and bottom part).
Step 3: The Led Module
The "led module" mounts the Arduino Nano the NRF24L01 module and four leds. The Arduino and the NRF24L01 module are used to manage the communication with the master module, while two of the leds are used to give to user a visual feedback about the incoming and outcoming data and the other two leds are used for the normal operations.
The major task of this module is to show if the network is working, allowing the user to switch on one of the two leds, switch off them or obtain their current status. In particular this module is a sort of proof of concept, or rather we decided to use it to show how it is possible to interact with actuators and using leds with different color it is possible to test the operation of the color module.
Step 4: The Color Sensor Module
This last module is a little bit more complex with respect the other, in fact, it contains the same hardware of the others (Arduino Nano, NRF24L01 module and the two visual feedback leds) and other hardware to detect the color and manage the battery.
To detect a color and return its RGB model, we decide to use the TCS3200 sensor, this is a small and low cost sensor commonly used in this kind of applications. It is composed by a photodiode array and a current-frequency converter. The array contains 64 photodiodes, 16 have red filter, 16 green filter, 16 have the blue filter and the last 16 are clear with no filters. All photodiodes of the same color are connected in parallel and each group can be activated by two special pins (S2 and S3). The current-frequency converter returns a square wave with a duty cycle of 50% and frequency directly proportional to light intensity. The full-scale output frequency can be scaled by one of three preset values via two control input pins (S0 and S1).
The module is powered by a small, two cell Li-Po battery (7.4V), and it is managed by the Arduino. In particular one of the two cell is connected to an analog input of this one, and this allows the Arduino to read value of the power of the cell.
When the power level of the cell falls below a certain value, to preserve the battery, the Arduino switches on a led, which warns the user to turn off the device. To turn on or off the device, there is a switch that connects the positive pin of the battery to the Vin pin of the Arduino board or to a connector which can be then used by the user to charge the battery.
As for the master module, the sensor color module has small size (40x85x30) and it was inserted inside a 3D printed box.