dbuezas / esphome-cc1101

89 stars 16 forks source link

not able to send #4

Closed ageurtse closed 1 month ago

ageurtse commented 1 year ago

hello i have aa cc1101 hooked up to a wemos D1 mini.

when hooking up i could recieve some data.

but when i resend this data there is nothing happening, the lights wont turn on. what could be wrong, how to find out what is wrong.

below is my yaml file

# --- start default settings ---
esphome:
  name: 118-rf-tranceiver
  includes:
    - cc1101.h
  libraries:
    - SPI
    - "SmartRC-CC1101-Driver-Lib"

esp8266:
  board: d1_mini_lite

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pwd

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "rf fallback"
    password: !secret esphome_pwd

  manual_ip:
    static_ip: 192.168.1.118
    gateway: 192.168.1.1
    subnet: 255.255.255.0

captive_portal:

# Enable logging
logger:

api:
  password: !secret esphome_api

ota:
  password: !secret esphome_ota

web_server:
  port: 80

# --- End default settings ---

# --- Start of custom sensors ---

sensor:
  - platform: custom
    lambda: |-
      auto my_sensor = new CC1101(
        D5, // SCK
        D6, // MISO
        D7, // MOSI
        D8, // CSN
        D1, // GDO0
        D2, // GDO2
        200, // bandwidth_in_khz
        433.92 // freq_in_mhz
      );
      App.register_component(my_sensor);
      return {my_sensor};
    sensors:
      id: transciver
      internal: true
remote_transmitter:
  - pin: D1 # This is GDO0
    carrier_duty_percent: 100%

remote_receiver:
  - pin: D1 # This is GDO0
      # on the esp8266 use any of D1,D2,D5,D6,D7,Rx
      # Don't use D3,D4,D8,TX, boot often fails.
      # Can't be D0 or GPIO17 b/c no interrupts
    dump: rc_switch

binary_sensor:
  - platform: remote_receiver
    name: Garage
    rc_switch_raw:
      code: "0011000100001110101001111000"
      protocol: 1
button:
  - platform: template
    name: Garage
    on_press:
      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_rc_switch_raw:
          code: "0011000100001110101001111000"
          protocol: 1
      - lambda: get_cc1101(transciver).endTransmission();
      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_rc_switch_raw:
          code: "0011000100001110101001111000"
          protocol: 1
      - lambda: get_cc1101(transciver).endTransmission();

      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_rc_switch_raw:
          code: "0011000100001110101001111000"
          protocol: 1
      - lambda: get_cc1101(transciver).endTransmission();
      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_rc_switch_raw:
          code: "001100010000111010100111100"
          protocol: 1
      - lambda: get_cc1101(transciver).endTransmission();
dbuezas commented 8 months ago

The data you are receiving looks almost perfect. The only issue is that it is receiving an extra pulse (probably because of the 0 wait you put there (as @kgstorm mentioned).

image

(last row is the sent code)

These numbers represent the time between each flank of each pulse. They only need to be maybe ±10%

deanfourie1 commented 8 months ago

The data you are receiving looks almost perfect. The only issue is that it is receiving an extra pulse (probably because of the 0 wait you put there (as @kgstorm mentioned).

image

(last row is the sent code)

These numbers represent the time between each flank of each pulse. They only need to be maybe ±10%

Oh wow, that explains it well.

I was expecting it to receive the exact same data as being sent, but its obviously encoded somehow right.

dbuezas commented 8 months ago

Is it possible to make it "latching" until a restore is sent. Like a door.

binary_sensor:
  - platform: template
    name: "Door Keller"
    id: door_keller
    device_class: door
  - platform: remote_receiver
    receiver_id: receiver_doors
    id: keller_door_off
    internal: true
    name: ""
    on_press:
      - binary_sensor.template.publish:
          id: door_keller
          state: ON
    raw:
      code:
        [.....]
  - platform: remote_receiver
    receiver_id: receiver_doors
    id: keller_door_on
    internal: true
    name: ""
    on_press:
      - binary_sensor.template.publish:
          id: door_keller
          state: OFF
    raw:
      code:
        [.....]
dbuezas commented 8 months ago

BTW, here's the online web plotting tool: https://github.com/dbuezas/esphome-remote_receiver-oscilloscope

deanfourie1 commented 8 months ago

BTW, here's the online web plotting tool: https://github.com/dbuezas/esphome-remote_receiver-oscilloscope

Ive actually come accross that before, but the data I put in looked nothing like that haha. I think it was just a lot of noise.

deanfourie1 commented 8 months ago

Thanks for your help guys! I'm super wrapped to finally get this working!

I just need to swing it over to my Wemos Battery Shield and setup and test with deep sleep now.

deanfourie1 commented 8 months ago

Is it possible to make it "latching" until a restore is sent. Like a door.

binary_sensor:
  - platform: template
    name: "Door Keller"
    id: door_keller
    device_class: door
  - platform: remote_receiver
    receiver_id: receiver_doors
    id: keller_door_off
    internal: true
    name: ""
    on_press:
      - binary_sensor.template.publish:
          id: door_keller
          state: ON
    raw:
      code:
        [.....]
  - platform: remote_receiver
    receiver_id: receiver_doors
    id: keller_door_on
    internal: true
    name: ""
    on_press:
      - binary_sensor.template.publish:
          id: door_keller
          state: OFF
    raw:
      code:
        [.....]

Thanks, I need to trigger this from a GPIO.

Another question, how can I generate the [code] to be sent. Do I just make it up?

dbuezas commented 8 months ago

Thanks, I need to trigger this from a GPIO.

Look into esphome docs you can do anything with it.

Another question, how can I generate the [code] to be sent. Do I just make it up?

That's exactly the raw output you get in the receiver

deanfourie1 commented 8 months ago

But what I dont understand is, the commands sent by transmitter were different to what was received by the receiver.

dbuezas commented 8 months ago

Mmm were they? Can you run this again and post the result after adding the delay between repeats? Pleas also post what you transmit

deanfourie1 commented 8 months ago

Hey could you help me out with one more issue. Im using the Wemos Battery Shield which is a WROOM 02 ESP.

https://epartners.co.nz/products/tm2004?_pos=3&_sid=e0721fd63&_ss=r

When compiling the full code, the device fails to boot or connect to HA.

I'm thinking this could be due to me using a strapping pin defined in the

sensor:
  - platform: custom
    lambda: |-
      auto my_sensor = new CC1101(
        5, // SCK
        6, // MISO
        7, // MOSI
        3, // CSN
        1, // GDO0
        200, // bandwidth_in_khz
        433.92 // freq_in_mhz
      );
      App.register_component(my_sensor);
      return {my_sensor};
    sensors:
      id: transciver
      internal: true
remote_transmitter:
  - pin: 1 # This is GDO0
    carrier_duty_percent: 100%

Do you have any idea how I can get around this. Full YAML.

esphome:
  name:
  friendly_name:
  includes:
    - cc1101.h
  libraries:
    - SPI
    - "SmartRC-CC1101-Driver-Lib"

esp8266:
  board: esp_wroom_02

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: 

ota:
  password: 

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: 
    password: 

captive_portal:

sensor:
  - platform: custom
    lambda: |-
      auto my_sensor = new CC1101(
        5, // SCK
        6, // MISO
        7, // MOSI
        3, // CSN
        1, // GDO0
        200, // bandwidth_in_khz
        433.92 // freq_in_mhz
      );
      App.register_component(my_sensor);
      return {my_sensor};
    sensors:
      id: transciver
      internal: true
remote_transmitter:
  - pin: 1 # This is GDO0
    carrier_duty_percent: 100%

button:
  - platform: template
    name: Garage
    on_press:
      - lambda: get_cc1101(transciver).beginTransmission();
      - remote_transmitter.transmit_raw:
          code: [415,-300,370,-300,375,-300,378,-300,378,-300,379,-300,405]
          repeat: 
            times: 10
            wait_time: 10ms
      - lambda: get_cc1101(transciver).endTransmission();

Thank you!

deanfourie1 commented 7 months ago

Hey guys, is there any way we can get the CC1101 to send the commands from this post?

Much appreciated!

https://github.com/esphome/feature-requests/issues/2235#issuecomment-1858834643

kgstorm commented 7 months ago

Hey guys, is there any way we can get the CC1101 to send the commands from this post?

Much appreciated!

esphome/feature-requests#2235 (comment)

Have you tried converting it to int first? https://community.home-assistant.io/t/send-hexadecimal-content-from-input-text/409091/5?u=implicit_none