Zigbee

From Eric

(Difference between revisions)
Jump to: navigation, search
m
m
Line 34: Line 34:
Install  
Install  
-
Texas Instruments SmartRF studio (I use smartrftm_studio-2.21.0)
+
* Texas Instruments SmartRF studio (I use smartrftm_studio-2.21.0)
-
Texas instruments flash programmer (I use flash-programmer-1.12.8)
+
* Texas instruments flash programmer (I use flash-programmer-1.12.8)
-
Zboss (I use 2020_11_02_zboss_sniffer_windows_ubuntu_64bit)
+
* Zboss (I use 2020_11_02_zboss_sniffer_windows_ubuntu_64bit)
-
WireShark
+
* WireShark
The Zboss archive contains both the desktop application and the firmware to be programmed to the dongle.  
The Zboss archive contains both the desktop application and the firmware to be programmed to the dongle.  
Line 146: Line 146:
This will generate the firmware, compile it and uploadit to the ESP32CAM.
This will generate the firmware, compile it and uploadit to the ESP32CAM.
The first time, the software will be uploaded via the serial line. Then the following updates can be done OTA.
The first time, the software will be uploaded via the serial line. Then the following updates can be done OTA.
 +
 +
= Using CC2530 devices =
 +
The CC2530 chip provides zigbee connectivity. Unfortunately, to use the firmware, you need a non-free compiler (I don't remember which one).
 +
 +
Fortunately, the [https://ptvo.info/zigbee-switch-configurable-firmware-v2-210/ PTVO] web site provides a free firmware generator: you give your configuration and it geerate the binary that just needs to be flashed using TI's programmer (see above).
 +
 +
Here is the configuration I use:
 +
  Board type: CC2530 + CC2591
 +
  Device type: Router
 +
  Transmit enable (TXEN): P12Receive enable (RXEN): P14
 +
  Status LED: P23, Periodic (every 5 seconds)
 +
 
 +
  Output pins:
 +
  P10: Output 1, GPIO, External pull-up, Remember state
 +
  P12: Output 2, GPIO, External pull-up, Remember state
 +
  P13: Output 3, GPIO, External pull-up, Remember state
 +
  P15: Output 4, GPIO, External pull-up, Remember state
 +
  P16: Output 5, GPIO, External pull-up, Remember state
 +
  P17: Output 6, GPIO, External pull-up, Remember state
 +
  P20: Output 7, GPIO, External pull-up, Remember state
 +
  P21: Output 8, GPIO, External pull-up, Remember state
 +
 
 +
  Input pins:
 +
  P00: Input 1, GPIO, External pull-up, Switch, Link to out 1
 +
  P01: Input 2, GPIO, External pull-up, Switch, Link to out 2
 +
  P04: Input 3, GPIO, External pull-up, Switch, Link to out 3
 +
  P05: Input 4, GPIO, External pull-up, Switch, Link to out 4
 +
  P06: Input 5, GPIO, External pull-up, Long, Double, Tripple
 +
  P22: Input 6, GPIO, External pull-up, Long, Double, Tripple

Revision as of 18:00, 9 August 2021

Contents

Install zigbee2mqtt

Configure the zigbee adapter

See https://www.zigbee2mqtt.io/information/flashing_the_cc2531.html

Install zigbee2mqtt

See https://www.zigbee2mqtt.io/


To mofidy the state of a device, refer to the zigbee2mqtt documentation for your device. For instance, for a 4-relay Tuya adapter:

 mosquitto_pub -t "zigbee2mqtt/relays/set" -m  '{"state_l1": "OFF"}'

start zigbee2mqtt automatically

See https://www.zigbee2mqtt.io/getting_started/running_zigbee2mqtt.html

 # Stopping Zigbee2MQTT
 sudo systemctl stop zigbee2mqtt
 # Starting Zigbee2MQTT
 sudo systemctl start zigbee2mqtt
 # View the log of Zigbee2MQTT
 sudo journalctl -u zigbee2mqtt.service -f


Zigbee sniffing

Install

  • Texas Instruments SmartRF studio (I use smartrftm_studio-2.21.0)
  • Texas instruments flash programmer (I use flash-programmer-1.12.8)
  • Zboss (I use 2020_11_02_zboss_sniffer_windows_ubuntu_64bit)
  • WireShark

The Zboss archive contains both the desktop application and the firmware to be programmed to the dongle.

Note that I have not managed to make ZBoss work on Linux.


On Linux, you’ll have to use cc-tools:

 git clone https://github.com/dashesy/cc-tool.git
 cd cc-tool
 ./bootstrap
 ./configure
 make

And to flash:

 sudo ./cc-tool -e -w <firmware>.hex

Instructions are given at https://www.zigbee2mqtt.io/how_tos/how_to_sniff_zigbee_traffic.html

(see also: https://www.hal9k.dk/sniffing-philips-hue-zigbee-traffic-with-wireshark/, https://www.youtube.com/watch?v=4vG4CVNAm_A,


Zigbee frames are encrypted.

To decrypt the frames, follow the following procedure:


Voir aussi : https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/218226/getting-started-with-the-cc2530

https://electronics.stackexchange.com/questions/158637/zigbee-firmware-for-cc2530-chips

Install an ESP32 CAM camera

To install an ePS32 CAM, the easiest way is to use the ESPhome firmware generator.

Installing ESPhome (e.g, on the Raspberry Pi server) is achieved as follows (see complete instructions here):

 pip3 install esphome

(The executable "esphome" is located at $HOME/.local/bin/)

Then, you have to connect physically your ESP32_CAM to the host using a serial adapter, according to the following diagram:

Esp32cam connection.jpg

Then you have to create a configuration file. This can be done using the esphome wizard, or you can get your inspiration from the following one:

 esphome:
   name: esp32_cam_2
   platform: ESP32
   board: nodemcu-32s
 
 # Enable logging
 logger:
 
 # Enable Home Assistant API
 api:
   password: "xxxxxx"
 
 ota:
   password: "xxxxxx"
 
 wifi:
   ssid: "yyyyyy"
   password: "zzzzzz"
 
 # Enable fallback hotspot (captive portal) in case wifi connection fails
 ap:
   ssid: "Esp32 Cam 2 Fallback Hotspot"
   password: "aaaaaaaa"
 
 esp32_camera:
   external_clock:
     pin: GPIO0
     frequency: 20MHz
   i2c_pins:
     sda: GPIO26
     scl: GPIO27
   data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
   vsync_pin: GPIO25
   href_pin: GPIO23
   pixel_clock_pin: GPIO22
   power_down_pin: GPIO32
 
   # Image settings
   name: "CAM 2"
 
 text_sensor:
   - platform: version
     name: "ESPHome Version"
 
 switch:
   - platform: restart
     name: "ESP32 CAM 2 restart"
   - platform: gpio
     pin: 4
     name: "CAM 2 Flash"
   - platform: gpio
     pin: 2
     name: "CAM 2 LED"
 
 binary_sensor:
   - platform: status
     name: "CAM 2 Status"
 

Then, to upload the firmware to the ESP32CAM, type

~/.local/bin/esphome run <config file>.yaml

This will generate the firmware, compile it and uploadit to the ESP32CAM. The first time, the software will be uploaded via the serial line. Then the following updates can be done OTA.

Using CC2530 devices

The CC2530 chip provides zigbee connectivity. Unfortunately, to use the firmware, you need a non-free compiler (I don't remember which one).

Fortunately, the PTVO web site provides a free firmware generator: you give your configuration and it geerate the binary that just needs to be flashed using TI's programmer (see above).

Here is the configuration I use:

 Board type: CC2530 + CC2591
 Device type: Router
  Transmit enable (TXEN): P12Receive enable (RXEN): P14
 Status LED: P23, Periodic (every 5 seconds)
 
 Output pins:
 P10: Output 1, GPIO, External pull-up, Remember state
 P12: Output 2, GPIO, External pull-up, Remember state
 P13: Output 3, GPIO, External pull-up, Remember state
 P15: Output 4, GPIO, External pull-up, Remember state
 P16: Output 5, GPIO, External pull-up, Remember state
 P17: Output 6, GPIO, External pull-up, Remember state
 P20: Output 7, GPIO, External pull-up, Remember state
 P21: Output 8, GPIO, External pull-up, Remember state
 
 Input pins:
 P00: Input 1, GPIO, External pull-up, Switch, Link to out 1
 P01: Input 2, GPIO, External pull-up, Switch, Link to out 2
 P04: Input 3, GPIO, External pull-up, Switch, Link to out 3
 P05: Input 4, GPIO, External pull-up, Switch, Link to out 4
 P06: Input 5, GPIO, External pull-up, Long, Double, Tripple
 P22: Input 6, GPIO, External pull-up, Long, Double, Tripple
Personal tools