2017-07-17 09:15:23    14    0    0

While trying to port some C code to micropython, I needed to set a lot of defines in a code as Python global vars.

Given those defines :

  1. #define CMD_SIZE 512
  2. /*
  3. frame format
  4. */
  5. #define FRAME_B 0xA5
  6. #define FRAME_E0 0xCC
  7. #define FRAME_E1 0x33
  8. #define FRAME_E2 0xC3
  9. #define FRAME_E3 0x3C
  10. /*
  11. color define
  12. */
  13. #define WHITE 0x03
  14. #define GRAY 0x02
  15. #define DARK_GRAY 0x01
  16. #define BLACK 0x00
  17. /*
  18. command define
  19. */
  20. #define CMD_HANDSHAKE 0x00 //handshake
  21. #define CMD_SET_BAUD 0x01 //set baud
  22. #define CMD_READ_BA
xiaomi mqtt udp zigbee    2016-11-08 07:46:41    20581    0    0

Update

I have uploaded a working version of the connector code on github : https://github.com/jon1012/mihome

What is it ?

The Xiaomi smart home solution is a low-cost zigbee ecosystem of devices that can stay on for a very long time with deep sleep on little batteries.

Best part about it is the price, less than 40 euros for the gateway (hub), and less than 20 for the individual sensors (you can maybe even find better prices online).

 

You can buy the smart home hub online at gearbest for example.


 

Available sensors :

1st tentative

This is my naïve test according to some specs found on the web.

import socket
import binascii

UDP_IP = "192.168.0.107"
UDP_PORT_FROM = 54322
UDP_PORT = 54321
MESSAGE = binascii.unhexlify('21310020ffffffffffffffffffffffffffffffffffffffffffffffffffffffff')

print ("UDP target IP:", UDP_IP)
print (