Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 LILYGO TTGO LoraV2.1-1.6 to communicate #5

Open
paradisgaston opened this issue Feb 6, 2025 · 9 comments
Open

2 LILYGO TTGO LoraV2.1-1.6 to communicate #5

paradisgaston opened this issue Feb 6, 2025 · 9 comments

Comments

@paradisgaston
Copy link

Hi, I am new to this type of communication.
I purchased two LILYGO TTGO LoraV2.1-1.6 that I which to exchange text at a distance of 1km.
I configure the 2 devices using your external _components github://swoboda1337/sx127x-esphome.
I change the frequency to 915000000 # 915 MHz in Hz because I wish to use LoRa. And -sx127x.send_packet: "Hello Cabane" instead of raw.

Does your external_compnent support this frequency and sending data. I have define button in each device to send message. But I do not see anything happening.
If you wish, I can send you my code to investigate.
Thanks

@swoboda1337
Copy link
Owner

swoboda1337 commented Feb 6, 2025

The two devices are close together now or 1 km apart?

Can look at the packet mode docs here: https://deploy-preview-4278--esphome.netlify.app/components/sx127x#packet-mode

That config is using FSK and probably has a range of 500 meters.

I haven't added support for LoRa yet but it is on my todo list. I was going to start this week actually.

@swoboda1337
Copy link
Owner

As for frequency support yes it will support that frequency as long as you bought a device that supports that frequency.

@paradisgaston
Copy link
Author

paradisgaston commented Feb 6, 2025 via email

@paradisgaston
Copy link
Author

paradisgaston commented Feb 6, 2025 via email

@swoboda1337
Copy link
Owner

swoboda1337 commented Feb 6, 2025

ChatGTP is useless for anything esphome :)

Just use the config in that link exactly as is but with a different frequency:

# Example configuration entry
sx127x:
  dio0_pin: GPIO26
  nss_pin: GPIO18
  rst_pin: GPIO23
  pa_pin: BOOST
  pa_power: 17
  bitsync: true
  bitrate: 4800
  frequency: 915000000  
  modulation: FSK
  rx_start: true
  payload_length: 8
  sync_value: [0x33, 0x33]
  preamble_size: 2
  preamble_errors: 8
  preamble_polarity: 0x55
  on_packet:
    then:
      - lambda: |-
          ESP_LOGD("lambda", "packet %s", format_hex(x).c_str());

  button:
    - platform: template
      name: "Transmit Packet"
      on_press:
        then:
          - sx127x.send_packet:
             data: [0xC5, 0x51, 0x78, 0x82, 0xB7, 0xF9, 0x9C, 0x5C

@paradisgaston
Copy link
Author

paradisgaston commented Feb 6, 2025 via email

@swoboda1337
Copy link
Owner

Looks like its working. To do text you can do:

        - sx127x.send_packet:
            data: !lambda |-
              std::string message = "Hello!";
              std::vector<uint8_t> data(message.begin(), message.end());
              data.resize(8);
              return data;

and

  on_packet:
    then:
      - lambda: |-
          std::string message(x.begin(), x.end());
          ESP_LOGD("lambda", "packet %s", message.c_str());

Note the packet size is fixed so I put a resize 8 there (change that if you increase the packet size)

@paradisgaston
Copy link
Author

paradisgaston commented Feb 7, 2025 via email

@swoboda1337
Copy link
Owner

swoboda1337 commented Feb 7, 2025

Max size is 64. It would be more efficient to send things as bytes not text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants