如何解码
要以二进制格式获取代码以使用您 download the library RC_switch 2.6.3 并通过 Sketch -> Library manager -> Add zip library 将其安装到您的库目录。
然后将File > Examples > RC_Switch > ReceiveDemo_Advanced 加载到板上。
上传草图后,将 433MHz 射频接收器连接到 Arduino UNO 板的Digital Pin 2。打开 Arduino IDE 串行监视器并开始按下遥控器的按钮。
按下每个按钮一次后,您可以看到每个按钮的二进制代码(以红色突出显示):
保存每次按下按钮的二进制代码(您也可以使用十进制或三态代码):
Button 3 ON = (24Bit) Binary: 000101010101000101010101
Button 3 OFF = (24Bit) Binary: 000101010101000101010100
Button 4 ON = (24Bit) Binary: 000101010101010001010101
Button 4 OFF = (24Bit) Binary: 000101010101010001010100
保存您的脉冲长度:416 微秒和协议:1。
如何发送
您需要使用二进制代码、脉冲长度和协议自定义下一个草图:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Optional set pulse length.
mySwitch.setPulseLength(REPLACE_WITH_YOUR_PULSE_LENGTH);
// Optional set protocol (default is 1, will work for most appliancies)
mySwitch.setProtocol(REPLACE_WITH_YOUR_PROTOCOL);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
}
void loop() {
// Binary code - button 3 ON
mySwitch.send("000101010101000101010101"); // YOUR_CODE_HERE
delay(1000);
// Binary code - button 3 OFF
mySwitch.send("000101010101000101010100"); // YOUR_CODE_HERE
delay(1000);
// Binary code - button 4 ON
mySwitch.send("000101010101010001010101"); // YOUR_CODE_HERE
delay(1000);
// Binary code - button 4 OFF
mySwitch.send("000101010101010001010100"); // YOUR_CODE_HERE
delay(1000);
}
因此没有切割波信号或类似信号,只是系统按下按钮记录和回放。
编辑
对于您的特殊需要解码 AC123 协议,有一个解决方案。
通过调整下面给定的发射器程序和fork of the RC-switch library 来完成解码。由于 AC123 使用 2 个同步位和 64 个数据字节。协议设置(仅添加到 pevar 库)是:
{15, 132, 50, {99, 13}, {5, 13}, {11, 6}, {11, 101}, false }
如何添加new remote read this wiki 但使用分叉库。作为帮助,如果您使用 simple_scanner (在示例中),您会得到类似从下一个数字到下一个 844 (你的第一个是)是作为 int 数组的代码:
212,572,
from =>844,5144,596,576,212,180,612,564,212,192,600,180,608,
180,608,564,216,576,216,180,608,180,612,564,212,576,212,576,
216,564,224,180,600,188,604,180,608,576,212,564,216,576,212,
180,612,572,216,180,596,192,604,180,608,572,216,180,600,576,
212,180,612,572,216,180,608,564,216,180,612,180,608,180,608,
180,600,180,608,180,612,180,608,564,216,184,608,180,608,184,
608,180,596,192,600,180,608,180,608,180,604,188,600,576,212,
184,608,180,596,192,600,180,608,564,224,564,220,188,600,576,
212,180,608,180,600,576,216,176,612,180,608,564,212,
576<= till here
,844,5140,600,572,216,176,612,568,220,180,600,
180,612,180,608,564,224,564,220,180,608,180,608,564,228,560,
216,572,216,572 .... goes on for x lines
可以通过在数组末尾添加,0 以this fork of the library of RC-switch 发送数组
要发送自生成信号,您必须在根据 wiki 分析数据负载后使用 this fork of the library
AC123 的协议是这样构建的(您仍然必须使用 RC_Scanner 来获取数据为您的硬件!):
Remote ID Byte 1 (possibly Manufacturer ID) 10100011
Remote ID Byte 2 01101110
Remote ID Byte 3 00010100
Remote ID Byte 4 00110101
Channel Byte 1 00000001
Channel Byte 2 00000000
Control Code 00001011
Checksum 11000011
The command byte works as follows for my system:
UP STOP DOWN
00001011 00100011 01000011
校验和计算为远程 ID 字节 2 + 远程 ID 字节 3 + 远程 ID 字节 4 + 通道字节 1 + 通道字节 2 + 控制代码。这可能加起来超过 1 个字节,在这种情况下 MSB 被忽略。
注意:这不包括可能指向制造商 ID 的远程 ID 字节 1。
这是一个快速使用和试验的草图:
// Transmitter for AC123 - Manufacturer ID 1
#include <RCSwitch.h> // Use this lib variant: https://github.com/perivar/rc-switch/
const unsigned long Remote = 0xA362281F;
const uint8_t CHANNEL_PADDING = B0000;
const uint8_t UP = B00001011;
const uint8_t STOP = B00100011;
const uint8_t DOWN = B01000011;
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Pin 5 change to your setuo
mySwitch.enableTransmit(5);
// AC123 Protocol define as 15
mySwitch.setProtocol(15);
mySwitch.setPulseLength(50);
}
void loop() {
Serial.println("Send Command");
sendCommand(Remote, B00001111, DOWN);
delay(2000);
sendCommand(Remote, B00001111, STOP);
delay(2000);
sendCommand(Remote, B00001111, UP);
delay(2000);
}
void comUp(unsigned long Remote, uint8_t channels) {
sendCommand(Remote, channels, UP);
}
void comDown(unsigned long Remote, uint8_t channels) {
sendCommand(Remote, channels, DOWN);
}
void comStop(unsigned long Remote, uint8_t channels) {
sendCommand(Remote, channels, STOP);
}
// This is the part you'll have to adept to your hardware
void sendCommand(unsigned long Remote, uint8_t channels, uint8_t commandR) {
uint8_t RemoteByte1 __attribute__((unused)) = Remote >> 24; // possibly Manufacturer ID not used at the moment
uint8_t RemoteByte2 = Remote >> 16;
uint8_t RemoteByte3 = Remote >> 8;
uint8_t RemoteByte4 = Remote;
uint8_t Checksum = RemoteByte2 + RemoteByte3 + RemoteByte4 + channels + CHANNEL_PADDING + commandR;
char SendCodeChar[64];
uint8_t bitPos = 31;
for (uint8_t i = 0; i <= 31; i++) {
if bitRead(Remote, bitPos) SendCodeChar[i] = '1';
else SendCodeChar[i] = '0';
bitPos--;
}
bitPos = 7;
for (uint8_t i = 32; i <= 39 ; i++) {
if bitRead(channels, bitPos) SendCodeChar[i] = '1';
else SendCodeChar[i] = '0';
bitPos--;
}
bitPos = 7;
for (uint8_t i = 40; i <= 47 ; i++) {
if bitRead(CHANNEL_PADDING, bitPos) SendCodeChar[i] = '1';
else SendCodeChar[i] = '0';
bitPos--;
}
bitPos = 7;
for (uint8_t i = 48; i <= 55 ; i++) {
if bitRead(commandR, bitPos) SendCodeChar[i] = '1';
else SendCodeChar[i] = '0';
bitPos--;
}
bitPos = 7;
for (uint8_t i = 56; i <= 63 ; i++) {
if bitRead(Checksum, bitPos) SendCodeChar[i] = '1';
else SendCodeChar[i] = '0';
bitPos--;
}
mySwitch.send(SendCodeChar);
}
编辑 2
当 OP 更改了他的问题并在此处添加了捕获的数据(其工作 OMG)时,我在讨论中给出的答案作为对其他人如何解码的帮助。
我在电子表格中进行分析,您应该搜索 8xx(脉冲)和 5XXX(编码 AC123-0x)的组合,在您的情况下,一帧包含逗号,长度始终为 1750 个字符
Start here first frame =>888,5208,648,556,252,152,648,548,248,156,648,
156,644,160,648,548,240,
564,248,156,648,160,644,552,244,556,248,156,656,540,268,144,648,548,256,148,
660,148,656,144,648,552,252,148,660,536,260,152,640,556,252,156,644,160,644,
552,240,172,632,564,244,548,256,548,244,168,640,160,648,156,652,152,644,160,
648,144,652,152,656,148,644,552,256,148,652,152,652,152,636,172,636,156,
648,156,644,160,628,176,632,164,640,568,240,160,632,172,628,164,644,160,648
,548,260,540,256,552,256,148,656,540,264,540,256,548,256,548,252,148,656
,152,636,556<=end frame
start next frame=>884,5220,640,560,252,148,656,540,260,152,660,136,664,140,664,
532,264,540,264,140,660,144,664,532,256,548,256,148,652,552,248,156,636,
560,248,156,648,160,644,160,644,548,248,156,648,556,252,152,656,536,264,
140,664,140,664,532,276,136,656,540,264,540,268,528,268,144,652,156,640,
152,652,152,648,160,636,168,632,160,644,160,644,552,244,172,632,160,644,
160,648,156,640,164,640,152,656,148,656,148,652,152,644,552,252,148,656,
152,640,164,640,152,648,548,252,552,244,564,240,164,640,552,256,548,244,
564,240,564,240,160,648,156,636,556<=end frame
start next frame=>892,5212,648,548,252,152,656,540,260,
156,636,164,640,156,648,548,256,548,248,168,636,160,648,544,260,544,252,
160,652,544,264,136,660,536,260,156,648,148,660,144,660,536,252,160,644,
548,252,156,648,544,252,164,636,160,648,560,236,164,632,564,244,560,
244,560,244,156,644,164,640,152,660,144,656,148,644,160,648,144,656,
152,648,544,264,152,644,148,648,160,644,160,640,164,632,160,640,164,
640,164,644,160,632,564,236,168,640,160,644,160,636,168,640,556,248,
544,264,544,248,164,640,552,252,544,260,544,252,552,248,156,648,156
,640,552,3300,84,484,672,160<=end frame
实际上,您发布的代码中有三个命令。在作为数组传输之前不要忘记在末尾添加 ,0