Last modified: 06.08.2020

started: 10.07.2019

I want to be able to control a number of Garden Lights from a web page.

Plan 1, last modified: 06.08.2020 22.09.2019

These lights are Infrared remote controlled rgb flood lights I bought cheap from ali Express. I can control these lights by sending a IR signal with a micro controller. But I want to control them from a web page using the VoffCon system. I want to use the Arduino Nano to control one or two the flood light by sending signals with a transmitting ir diode module. To tell the arduino what to do I am going to use the Nrf24L01 which is a cheap universal ISM band monolithic transceiver which works on 2.4-2.5GHz to communicate with a Wifi micro controller connected to VoffCon. So from VoffCon I can send commands to the esp32 via LAN (WiFi) and the esp32 will send the command to the Arduino Nano using a Nrf24L01.

I will also need a VS1838B infrared sensor to learn all the codes the Food light remote control can send.

The Plan

I experimented with a new plan starting from 16.7.2020. In that plan I tried to skipp usagne of the Nrf24L01 see below: A new approach (Plan 2). But I was not happy with the result so I will continue working with this plan but change it by not making the Esp32 change any spotlight directly. The esp32 will be used as a hub to relay messages to Arduino Nanos, and only the nanos will command the floodlights.

This is how I plan to setup the devices needed. The blue part of the image in the middle is my house. the little icons "01" and "00" are two micro controllers located in windows in my garage.

We will have two micro controllers inside my garage. One Esp32 and one Arduino nano. Out side in the garden we will have six flood lights of two types. The color of one type is silver and the color of the other type is black. I own two silver and four black. The two types have different IR remote control codes but every thing else is the same.

Control card image

Component needed

I will need these items for the project

  • Flood light controlled with a normal infra red controller. I bought two of these, four black and two silver.
  • Infrared transmit module
  • VS1838B infrared sensor
  • Nrf24L01 a wireless sender and receiver
  • Arduino Nano
  • 5V or 12V power supply for the Arduino Nano
  • Esp32 development module
  • 3 or 5 V Power supply for the ESP


Work in progress
  • Outside in the garden
  • Inside the house
    • Make a working DeviceServerEsp32 in VoffCon so I can use the device page to send commands to the SpotlightRemoteCommander.
    • Create the Garden control card in VoffCon
    • Create the Garden control in VoffCon
    • Make build into VoffCon a Nrf24L01 network solution (nice to have in the future but not necessary for this project)

Units in the garden

Nrf24l01 wireless module image Arduino Nano image Image of Infrared transmit module KY-005 Flood light image Black Flood fill light image

Unit inside the house

Nrf24l01 wireless module image Arduino Nano image Esp32 development module image


1. Libraries

First things first, start by getting the three Libraries I need.

I will need to download the IRemote library to be able to send and receive infrared signals
I will need to download the RF24 library to be able to send and receive commands without wires more distances than IR signals can travel. This library can also be found from the Arduino IDE by going to menu Sketch->Include LIbrary->Manage Libraries... and search for "RF24". Im going to use "RF24 by TMrh20". Additional info
I will need to download the RF24Network library. To have more than one spotlight, or maybe have more devices than just spotlights, I will need to connect them to some sort of network which the RF24Network library provides. It is also provided by TMrh20 and can be downloaded from the Arduino IDE like the RF24 library. Search for the library "RF24Network by TMrh20". Additional info and thistutorial with video.

2. Detect the remote control signals

Information on how I connected the sensor to the arduino. I did not use the 100Ω resistor like I was suppose to.

TL1838 infrared sensor image

This is the sketch I used to detect signal from the remote control. It is located in IRemote examples and is named IRrecvDemo.ino.


3. Learn how to send the signals to the flood light using the Nano

Information on how I connected the transmitter to the arduino. And a image of the remote control. If you view the code you should see that the irCommand array is set up like the buttons are located on the remote.

After detecting all the signal I was able to create this sketch to control the flood light. The sketch sends commands typed to the serial and then send on to the flood light.SendIRtoFloodlight.ino The data pin (send pin) must be D3. For example if a user types "ON" without the quotes then the micro controller sends the "ON" IR code to the flood light. If a user types "RED" then the flood light turns red.


4. Communicate between two Micro-controllers Arduino Nanos and also the Esp32 using the Nrf24L01

I downloaded the RF24 library, connected each Arduino Nano to a Nrf24L01 by using the wiring information from the table below. Turned on both nanos, and they started communicating. easy peasy 😀.

PINNRF24L01 Arduino Nano Esp32 Development module NodeMCU Development module ATtiny25/45/85 [0] ATtiny44/84 [1] LittleWire [2] RPI RPi -P1 Connector
1 GND GND GND GND pin 4 pin 14 GND rpi-gnd (25)
2 VCC 3.3V 3V3 3V3 pin 8 pin 1 regulator 3.3V required rpi-3v3 (17)
3 CE D7 D12 D?? pin 2 pin 12 pin to 3.3V rpi-gpio22 (15)
4 CSN D8 D14 D?? pin 3 pin 11 RESET rpi-gpio8 (24)
5 SCK D13 D18 D?? pin 7 pin 9 SCK rpi-sckl (23)
6 MOSI D11 D23 D?? pin 6 pin 7 MOSI rpi-mosi (19)
7 MISO D12 D19 D?? pin 5 pin 8 MISO rpi-miso (21)
8 IRQ - - - - - - - -

The code running on both Arduino Nanos are form a RF24 example sketch called GettingStarted.

The only difference between the codes on the Nanos is line 22. where role is changed from 0 to 1.

Arduino Nano one
bool role = 0;
Arduino Nano two
bool role = 1;
// Coming soon

5. Commands from Serial on Nano A sent wireless's to Nano B to be executed

I decided to use the RF24Network library to test how hard it would be. It turns out that it's easy. View the code on both Nanos to see how easy it really is. 😊

Spotlight Infrared Remote Controller listens for commands from the Spotlight Commander and execute them by sending Infrared signal commands to the spotlight.

// Coming soon

Spotlight Commander will listen for commands from the serial port and send them wireless's to the Spotlight Remote Controller.

// Coming soon

6. Move the SpotLight Commander sketch to Esp32 and make it work

If it works on Nano it is not certain it will work on the esp32. But surprisingly it worked on the Esp32 dev module by connecting it like described in the sketch. Only thing I had to change was line 22 because I am using other pins for the CE and the CSN. Change pin 7 to 12 and pin 8 to 14.

By viewing the pin-out for the Esp32 Development model I was able to add the "Esp32 dev module" column in to the table above making it easy to connect the Nrf24L01 to the controller.

Image of the pin-out of the Esp32 Development Module

Here is the modified Spotlight Commander sketch for the Esp32

// Coming soon

7. Testing how far the signals go

I put one Arduino Nano in the garage window running the Spotlight Commander sketch. In the loop() I un-commented the function call "sendContinuously();" and commented out "getCommandsFromSerial();" call (in line 127) to send a continuos test signal from the commander. I connected another Arduino Nano to my laptop and ran the Spotlight Infrared remote controller sketch there. When I had a signal I saw blinking lights because it was writing to the serial and when it does that, a little yellow LED lights up.

I found that when trees were between the sender and the receiver the signal diminished dramatically but, when there was a direct line of sight between the Nanos the signal was strong and reached to the edge of my garden. I concluded that I will need a network to relay messages to nodes behind or near trees. I tested the RF24Network on the Esp32 and it just works. So, I will be using that.

8. Integrating the Spotlight Commander into the VoffCon Esp32 Device server

I was able to run the DeviceServer and the Spotlight Commander in the same sketch.

Hello World

Hello VoffCon Spotlight Commander world. This is a prove of concept and now I know WiFi and NRF24L01 will be able to work to gether. The prove is in two files see below. When running the code the spotlight changes the light but does that much slower than in the sketches above. I am changing the light after each WiFi client check which takes time. So slower is as expected.

 // Coming soon 

// Coming soon

9. Learn how to create a wireless network using the Nrf24L01.

Here I have a working solution. VoffCon sends commands to the server running on Esp32 and the server relays those commands to the clients. There is one client per floodlight.

Working server

Below, is a working server running on the Esp32. The server Nrf24L01 address is 00. It can process commands from VoffCon via WiFi (lan) and send them via Nrf24L01 to the Spotlight Infrared Remote Controllers. It's a relief that after all this work, this project can actually work.

            // Coming soon
            // Coming soon
            // Coming soon

Working client

Here is the code for the flood lights. It consists of 3 files, SpotlightIRemoteController.ino, FloodLightRemote.cpp and FloodLightRemote.cpp. Each nano will listen for commands from the server and execute them by sending a Infrared signal to the flood light. The client Nrf24L01 addresses are from 01 to 04.

The client address is set in the beginning of the file SpotlightIRemoteController.ino (see: const uint16_t this_node =).

The remotes for each floodlight do not send exactly the same signals. To handle that each client must select the correct remote by defining a specific keyword in the file "FloodLightRemote.h". For example, to select the "SILVER_REMOTE_50W_1" remote, then the following must be un-commented #define SILVER_REMOTE_50W_1. Only one of the remote keywords should be un-commented. See code below.

            // Coming soon

            // Coming soon
            // Coming soon

10. Make a compact waterproof package around the arduino nano and it's components

This part will take time. I will need to create a circuit, provide it with power and make it waterproof.

Tasks needed

Build the circuit
I would like to use my milling machine to mill the circuit. This will take time because I have never used it and have no idea how to work it. I've assembled it, turned it on and run some tests. That's about it.
Create a waterproof box around the nano and the NRF24L01
This box needs to provide an easy access to the components inside it.
Provide Arduino Nano with power
I could add a power adapter inside the box for each Nano, but I think it would be better to use one big 12 voltage power supply through out the garden. The VIN pin on the Nano will accept 7-12V so I could just use that for power. Also it's easy to step down from 12V to 5V or 3.3V if needed for other devices.

Plan 2 (canceled), last modified: 22.07.2020

Only going to use the Esp32 to control the flood lights.

I am not going to use the Nrf24L01 which should simplify and reduce the maintenance. I bought a out-door WiFi router and fitted it on my house chimney, allowing devices to connect to my local network from my garden. Each flood light will be controlled by one Esp32. For this to work I will need to be able to use the infrared transmit module with the Esp32 Micro-controller.

I bought four new 50W RGB floodlights which came with a remote control. I had some problems with the IR signals for these flood lights. I think the IR receiver is a little weaker than on my other flood lights. But I got these to work also. I used the sketch IRrecvDemo.ino in step 2 of the old plan to record the remote commands for the 50W floodlights. After that was done I changed the SendIRtoFloodlight.ino sketch in step 3 of the old plan. to include commands from this new remote control.

I put the new code into a class so, it will be easier to add the IR transmitter code to VoffCon

Here are the two files for the class FloodLightRemote



And here is the example ".ino" file which gets commands from the serial and send them to the flood light by using the class FloodLightRemote.


While testing, I found out when using the Esp32 to send IR signals, it did not work every time. The Esp32 pins are probably not powerful enough. For that reason I added a BC547B to the circuit to be able to use 5V instead of 3.3V pins and that made things reliable enough to be usable. I needed to position the IR Transmitter much closer to the floodlight than, when using the Arduino Nano, but that should be OK for this project.

When positioning the IR Transmitter, try to give commands while the flood light is showing the color BLUE or color CYAN on full power. These colors seem to interfere with the IR Transmission. If the flood light responds to the Esp32 commands when these two colors are lit, all other commands should work. Positioning the IR transmitter about 8cm from the IR receiver on the flood light seemed to be best for my project.

Images of the new flood light and how to wire the Esp32 to the IR transmitter using the BC547B Transistor.

Image of the flood light Wiring image for the ESP32, IR transmission

Adding the class and connecting it to the VoffCon

To add the class to VoffCon I will need to:

  1. Create a folder called DeviceServerEsp32FloodLight.
  2. Add a device to VoffCon and download it's program to the created folder. (See here on how to do that)
  3. Rename the downloaded sketch DeviceServerEsp32.ino to DeviceServerEsp32FloodLight.ino.
  4. Download the two files floodlightRemote.h and floodlightRemote.h into the folder DeviceServerEsp32FloodLight.
  5. Change the code of DeviceServerEsp32FloodLight.ino to use the class FloodLightRemote
  6. Create a new VoffCon Control called GardenLightsCtrl
  7. Create a new VoffCon Card called Garden lights

See below changed DeviceServer after including the class FloodLightRemote. VoffCon Cards (clients) can change the value of pin 32 to call the various IR commands.

Modifications to the VoffCon DeviceServerEsp32. I added these lines: (you can find most of them by searching for "fRemote".

27 - 29
Include the class and define the class variable fRemote
1028 - 1033
(Make it possible to give commands via Wifi. When new pinValues come from client check the pinValue on pin 32, and if it's valid, execute it by using the fRemote.sendButtonCommand to command the floodlight.)
1503 - 1512
(Setup the FloodLightRemote class (fRemote), test all buttons and print out available commands.)
1544 - 1569
(CheckSerialAndExecuteCommand - Make it possible to give commands to the device via Serial.)


The 25 available commands on pin 32 are:

0 : UP 1 : DOWN 2 : OFF 3 : ON
4 : RED 5 : GREEN 6 : BLUE 7 : WHITE
16 : ORANGE_LIGHT 17 : CYAN 18 : PINK 19 : FADE
24 : FF

You can always get them by connecting the device to a USB serial and give send the text string "NUMBERS" to the device via the serial.

The VoffCon control, the javascript class part

            //comming soon 

The VoffCon control, the html and css part

            //comming soon 

The VoffCon card

                // Comming soon

                // Comming soon

The result

This is how the card looks like when it's run in VoffCon. It contains a picture where the floodlights are located around the house, and a remote control with clickable buttons allowing you to give the same command to one or more flood light. By clicking the flood lights on the card you can select and deselect the flood lights which will receive the command when you press the button on the remote control.

Control card image

When trying to use the 3.3V micro controller to feed the transmitter via the 5V/VIN pin on the esp32, the signal is weak. I need to keep the transmitter about 8 cm away from the IR receiver on the flood light, it cannot be too close ether. This is bad because the light from the flood light especially cyan on full power interferes with the transmitted signal.

I tested four Esp32s in the same test, where the IR transmitters pointed to four different flood lights. I was not happy with the results. Sending commands to all of them did almost never work, I had to send the same command at least twice to make them all change to the same color. So I think I will continue with the first plan, giving command to one Esp32 which then will send commands to 5V micro controllers via Nrf24L01.