/nrf24le1-espnrf_gateway_and_remote_switch_for_livolo_etc

ESP8266+NRF24LE1 gateway and NRF24LE1 remote switch for livolo etc.

Primary LanguageAssemblyMIT LicenseMIT

ESP8266+NRF24LE1 MQTT gateway and NRF24LE1 wireless switch for integration into livolo, Maifom, Vhome switches, etc.

PROJECT_PHOTO PROJECT_PHOTO PROJECT_PHOTO PROJECT_PHOTO

After the latest release, support for Home Assistant Mqtt Discovery has been added. Added support for 4 local switches, lock or gate. Selectable in settings. It is also possible to flash ready-made devices based on esp8266, but adding NRF24LE1 to them usually leads to unstable operation of the latter due to the limited power of their power supply. But only for local control in these devices (without using the gateway function and modifications) the firmware works stably for me.

Current version is 2024.02.05.

  • 2024.02.05. At startup, the gateway scans all WIFI APs with the required parameters and selects the AP with the best level. Relevant for mesh systems. Added selection of WIFI 802.11b/g/n mode in settings. The availability of devices in Home Assistant has been fixed. If the gateway is unavailable, all devices connected to it become unavailable.
  • 2023.08.04. Changed object names in Home Assistant Mqtt Discovery to be compatible with version 2023.8.0.

1. Opportunities

 The project allows you to modify livolo switches with an RF 433MHz receiver to operate in feedback mode and control using an MQTT server. To do this, one capacitance is changed in the switch, the standard RF receiver is removed, and the NRF24LE1 pre-programmed by the switch firmware is connected to the switch using 5 wires. Two of them are power and general, two more are for the LED outputs for reading the state of the switches, and one more is for the input instead of the standard receiver for control via the livolo protocol. It is possible to modify other switches in a similar way, for example, Maifom, Vhome, etc. For this purpose, support for the rcswitch protocol is provided. It is also possible to integrate the NRF24LE1 into other devices with pulse control, that is, a button, using an additional level matching circuit. NRF24LE1 monitors supply voltage and temperature once every 8 seconds if the DS18B20 sensor is connected. To reduce power consumption, the NRF24LE1 transceiver (1mW -94dBm @250kbps) is turned on twice per second for up to 33 ms each to receive commands and transmit state, and the total processor operating time in active mode is approximately 100 ms every second. The rest of the time the processor is in sleep mode, except when it is necessary to transmit a code to the switch. The code is transmitted up to 8 times in every half-second window before the switch is activated, but the processor operates at a minimum frequency of 125kHz. This operating mode gives an average consumption of about 1ma at maximum transmitter power and maximum receiver sensitivity. The protocol is as simple as possible, it operates at one frequency. But this frequency can be set higher than Wifi, BLE and Zigbee. To control the switches, you need a gateway, which is an ESP8266 and NRF24LE1(espnrf), connected to each other via rs232. Connections on the gateway side ESP tx <-> NRF(32pin) p0.4(rx), ESP rx <-> NRF(32pin) p0.3(tx), ESP gpio02 <-> NRF reset. The gateway polls 16 NRF switches, 4 numeric parameters each. The name of each parameter, up to 32 characters, must be defined during configuration in the espnrf web interface. The first 2 parameters reflect the states of the switches (1/0, on/off, true/false), the third parameter is used to display the temperature from the DS18B20 sensor (relevant for integrating NRF24LE1 into an air conditioner), the fourth parameter is the NRF24LE1 supply voltage. The use of an assembler without any sdk made it possible to lower the clock frequency in the switch by 16 times (1MHz), and accordingly reduce energy consumption, and in the gateway it was possible to freely fit into memory not only the program code, but also to reserve space for updating the code and for 64 parameter names. More details in readme_rus.pdf.

2. Build the project

 To build the esp-01(esp8266) binary files, ESP8266_RTOS_SDK (IDF Style) version 3.2 was used (the latest version with OTA does not fit into the 1MB of esp-01 memory) with a description and toolchain 5.2.0. I got the more recent esp-mqtt library here. To assemble binary and HEX files nrf24le1, Telemark Assembler 8051 version 3.2 with description was used.