Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamHow to send with IRsend?
Debug:IR:IR decode returned true, protocol 1
Debug:IR: Raw-Data=0x85
Debug:IR: 9 bits
Debug:IR: LSB first
Debug:IR:IR decode returned true, protocol PulseDistance (1)
Info:MQTT:Publishing val IR_PulseDistance 0x721 0x70E 0 (9 bits) to IR-Blaster/ir/get retain=0
Info:IR:IR MQTT publish IR_PulseDistance 0x721 0x70E 0 (9 bits) took 3ms
Debug:IR:IR fire event took 0ms
Debug:IR:IR decode returned true, protocol 1
Debug:IR: Raw-Data=0x85
Debug:IR: 9 bits
Debug:IR: LSB first
Debug:IR:IR decode returned true, protocol PulseDistance (1)
Info:MQTT:Publishing val IR_PulseDistance 0x622 0x60F 0 (9 bits) to IR-Blaster/ir/get retain=0
Info:IR:IR MQTT publish IR_PulseDistance 0x622 0x60F 0 (9 bits) took 1ms
Debug:IR:IR fire event took 0ms
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic IR-Blaster/ir/get
Debug:MQTT:channelSet topic 4209020 with arg IR_PulseDistance 0x721 0x70E 0 (9 bits)
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic IR-Blaster/ir/get
Debug:MQTT:channelSet topic 4209020 with arg IR_PulseDistance 0x622 0x60F 0 (9 bits)
• Publish the command (from the same device that decoded the frame) in exactly the same format the firmware produced:
IRsend {"Protocol":"PULSE_DISTANCE","Data":"0x721","Bits":9}
IRsend {"Protocol":"PULSE_DISTANCE","Data":"0x622","Bits":9}
• If you control the blaster via MQTT the usual topic is
cmnd/IR-Blaster/IRsend <-- Topic
{"Protocol":"PULSE_DISTANCE","Data":"0x721","Bits":9} <-- Payload
• If you are writing firmware yourself (Arduino-IRremote / IRremoteESP8266 ≥v4.x) call
IrSender.sendPulseDistanceWidthData(0x721, 9, kPulseDistanceDefaultConstants);
Replace 0x721
by 0x622
for the second button.
Key points
– Use the PulseDistance encoder because the decoder identified the same template (protocol 1
).
– Keep the payload length at 9 bits, LSB first; the library handles the bit order for you.
– No extra header or stop bits have to be specified; they are included in the template the firmware compiled-in.
Log interpretation
• The receiver twice produced protocol PulseDistance (1)
→ device already contains a PulseDistance template.
• First frame: primary data 0x721, header mark 0x721 µs, header space 0x70E µs.
• Second frame: primary data 0x622, header mark 0x622 µs, header space 0x60F µs.
• Data field printed as 0x85
(binary 1 0000 101) = same payload decoded both times; the apparent difference between 0x721/0x622 pairs is only in timing, not in data.
Why 9 bits, LSB-first matters
The least significant bit leaves first on the IR carrier. IRremote’s PulseDistance sender automatically reverses the bit order if you pass the flag PROTOCOL_IS_LSB_FIRST
(already part of the default template), so you only supply the integer value (0x85
).
Which API to use
a. Tasmota / ESPHome / OpenMQTTGateway (pre-compiled firmware) → IRsend
JSON payload on the console, HTTP /cm
, or MQTT cmnd/…/IRsend
.
b. DIY code (IRremoteESP8266 / Arduino-IRremote)
#include <IRremote.hpp>
#define IR_SEND_PIN 4
void setup() { IrSender.begin(IR_SEND_PIN); }
void loop() {
// variant 1 – use value & bit length only
IrSender.sendPulseDistanceWidthData(0x85, 9, kPulseDistanceDefaultConstants);
delay(2000);
}
c. Raw fallback (guaranteed to work on any target): capture with IRRaw 1
, then send with IRsend <comma-separated-raw-array>
.
Carrier and timing
• PulseDistance template compiled into Tasmota uses 38 kHz by default; that matches >90 % of consumer IR gear.
• If you re-implement, specify the same carrier:
IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_DELAY, 0 /*invert*/, 38 /*kHz*/);
Verifying transmission
• Observe LED with a phone camera or connect an IR receiver module and run IRrecvDump
.
• You should see the same 0x85 (9 bits)
printout when you press “send”.
– IRremote 4.x unified both AVR and ESP targets; sendPulseDistanceWidthData()
is stable from 2023-10.
– Tasmota 13.x automatically exposes every decoded frame as a ready-to-paste IRSend
line; nothing else is required.
– Home-automation stacks (Home-Assistant, openHAB) increasingly use MQTT JSON blobs exactly like the one above, so your payload is future-proof.
Pulse-distance coding = “1” and “0” differ by space length, not mark length; header mark/space precede every frame. The default template inside IRremote defines:
Header: (mark,space) = (kHeaderMark, kHeaderSpace)
Bit “1”: (mark,space) = (kBitMark, kOneSpace)
Bit “0”: (mark,space) = (kBitMark, kZeroSpace)
Stop: final mark
Since your decoder already succeeded, reuse that template instead of guessing timings.
– Household IR blasters transmit in the unlicensed 780–1100 nm optical band; generally no regulatory constraints.
– Be careful not to retransmit copyrighted or encrypted streams (e.g. pay-TV IR handshake) outside your own home.
– High-current IR LEDs can exceed eye-safety limits; keep series resistor ≥100 Ω at 3.3 V if you omit a driver transistor.
#define SEND_PULSE_DISTANCE
in IRremoteConfig.h
if you have trimmed the library. Serial.println(IrSender.printIRResultMinimal());
right after sending to see the encoder output. – If the firmware that received the frame was built without send support for PulseDistance, the IRsend
command will return “Protocol disabled”; in that case rebuild with IR_PULSEDISTANCE_SUPPORT 1
.
– Some remotes repeat a frame every 110 ms while the key is held. If your target needs repeats, add {"Protocol":"PULSE_DISTANCE","Data":"0x721","Bits":9,"Repeat":2}
in Tasmota or call IrSender.sendPulseDistanceWidthData(..., 3 /*repeats*/);
.
– Study ir_DistanceWidthProtocol.hpp
in Arduino-IRremote for more granular timing control.
– Look at the kExampleConstant_Sony
etc. templates to create custom PulseDistance variants.
– If you have an oscilloscope, capture the IR LED current waveform to verify exact burst timing.
Send the code exactly as the decoder printed it:
cmnd/IR-Blaster/IRsend → {"Protocol":"PULSE_DISTANCE","Data":"0x721","Bits":9}
or, in your own firmware:
IrSender.sendPulseDistanceWidthData(0x85, 9, kPulseDistanceDefaultConstants);
Keep the bit length at 9, keep LSB-first, use the built-in PulseDistance template, and ensure your IR LED hardware is wired and powered correctly. That reproduces the signal the receiver logged and should control the original device reliably.