项目作者: dsvensson

项目描述 :
CC1101 based IKEA Sparsnäs decoder
高级语言: Rust
项目地址: git://github.com/dsvensson/sparsnas-rs.git
创建时间: 2018-04-18T19:54:30Z
项目社区:https://github.com/dsvensson/sparsnas-rs

开源协议:Other

下载


IKEA Sparsnäs receiver

Work in progress, should be configurable, and perhaps turned into a library and another
application would do the actual work of storing the data in for example Influx DB. Currently
CRC check doesn’t pass in the cc1101 crate, should be fixed too. I’m fairly new with Rust,
so all help, nags, recommendations appreciated.

Screenshot

  1. $ cargo run
  2. Compiling sparsnas v0.1.0 (file:///home/pi/sparsnas)
  3. Finished dev [unoptimized + debuginfo] target(s) in 6.83 secs
  4. Running `target/debug/sparsnas`
  5. 11 3e 39 40de 0009693e ed39 3207 000205e3 64 # Current power: 287
  6. 11 3e 3a 40de 0009693e ed3a 30d2 000205e5 64 # Current power: 294
  7. 11 3e 3b 40de 0009693e ed3b 3009 000205e6 64 # Current power: 299
  8. 11 3e 3c 40de 0009693e ed3c 2fd6 000205e7 64 # Current power: 301

Hardware

A Ti CC1101 (available for about 3-4 USD) connected to a Raspberry Pi:

  1. Vdd - 3.3V (P1-17)
  2. SI - MOSI (P1-19)
  3. SO - MISO (P1-21)
  4. CS - SS (P1-24)
  5. SCLK - SCK (P1-23)
  6. GDO2 - GPIO (P1-22)
  7. GND - GND (P1-25)

Raspberry Pi Setup

Update to the latest kernel via sudo rpi-update, and add the following SPI
settings to /boot/config.txt:

  1. dtparam=spi=on
  2. dtoverlay=spi0-hw-cs

The overlay is needed to get SPI_NO_CS working. Without this it’s not possible to
perform multiple SPI transfers within the same chip-select.

Cross compilation

Compiling this on the Raspberry Pi is fairly painful. To get cross compilation going add
the following to ~/.cargo/config:

  1. [target.armv7-unknown-linux-musleabihf]
  2. linker = "arm-linux-gnueabihf-gcc"

And install the ARM toolchain:

  1. sudo apt-get install gcc-arm-linux-gnueabihf

The development roundtrip can now be shortened by:

  1. cargo build --target=armv7-unknown-linux-musleabihf && \
  2. rsync -vPz target/armv7-unknown-linux-musleabihf/debug/sparsnas pi@raspberrypi.local:/tmp && \
  3. ssh pi@raspberrypi.local "killall -9 sparsnas; /tmp/sparsnas"

License

Licensed under your option of: