Last modified: 21.08.2019

started: 10.07.2019

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

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 computer. 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

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

Progress

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

Steps

1. Libraries

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

IRemote
I will need to download the IRemote library to be able to send and receive infrared signals
RF24
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
RF24Network
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 RV24Network 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

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 Arduino Nanos 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

Working server

I will provide a working server below, which can process commands from VoffCon and send them to the Spotlight Infrared Remote Controller. It's a relief that after all this work, this project can actually work. I'm looking forward to finishing this step.

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

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


Arduino Nanos will need to relay messages to other Nanos out of esp32 range. I need to know how to create a network because I want many device controllers around the garden but I want only one commander in the house. The wireless signals do not travel well through trees so the relays are necessary. I think this will be easy using the RF24Network library. But how do I integrate that network into VoffCon so other VoffCon users can use this feature to.



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.