Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c91bf4e80 | |||
| 102beca9f5 | |||
| c4a9822af4 | |||
| b7b2f840da | |||
| f0a5bdad5b | |||
| a73d2f6bbc | |||
| 9e7e75ffe5 | |||
| 1700798c90 | |||
| 463158e667 | |||
| a2265e1aae | |||
| 17fa4047f9 | |||
| 17d9e91111 | |||
| f97e26411f | |||
| fe49edcfa6 | |||
| 3587e96247 | |||
| fc967f7554 | |||
| 2d1566ace2 | |||
| a0dd1f6aee | |||
| 035596d252 | |||
| 5a467a1c93 | |||
| e987107e6e | |||
| f3a861ecd1 | |||
| 8f40368bdf | |||
| 83e3903f88 | |||
| 33477745b2 | |||
| 52277d98e8 | |||
| 9c10e644db | |||
| 03525ebe93 | |||
| 9d18b80bb6 | |||
| 415de7a97a | |||
| 970e454920 | |||
| b416ae981a | |||
| e66a74de62 |
@@ -0,0 +1,20 @@
|
||||
|
||||
name: Telegram Message
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
jobs:
|
||||
build:
|
||||
name: Send Message
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: send telegram message on push
|
||||
uses: appleboy/telegram-action@master
|
||||
with:
|
||||
to: ${{ secrets.TELEGRAM_TO }}
|
||||
token: ${{ secrets.TELEGRAM_TOKEN }}
|
||||
disable_web_page_preview: true
|
||||
message: |
|
||||
${{ github.event.repository.name }} v${{ github.event.release.tag_name }}
|
||||
${{ github.event.release.body }}
|
||||
https://github.com/${{ github.repository }}
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Alex
|
||||
Copyright (c) 2021 AlexGyver
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||

|
||||

|
||||
[](https://github.com/GyverLibs/Gyver433/releases/latest/download/Gyver433.zip)
|
||||
[](https://registry.platformio.org/libraries/gyverlibs/Gyver433)
|
||||
[](https://www.ardu-badge.com/Gyver433)
|
||||
[](https://alexgyver.ru/)
|
||||
[](https://alexgyver.ru/support_alex/)
|
||||
[](https://github-com.translate.goog/GyverLibs/Gyver433?_x_tr_sl=ru&_x_tr_tl=en)
|
||||
|
||||
[](https://t.me/GyverLibs)
|
||||
|
||||
# Gyver433
|
||||
Библиотека для радиомодулей 433 МГц и Arduino
|
||||
- **Передача данных с модуля на модуль по собственному интерфейсу связи**, т.е. не работает с китайскими пультами и шлагбаумами!
|
||||
- Поддержка кривых китайских модулей
|
||||
- Встроенный CRC контроль целостности
|
||||
- Ускоренный алгоритм IO для AVR Arduino
|
||||
@@ -14,6 +22,8 @@
|
||||
|
||||
## Содержание
|
||||
- [Установка](#install)
|
||||
- [Интерфейс](#interface)
|
||||
- [Подключение](#wiring)
|
||||
- [Инициализация](#init)
|
||||
- [Использование](#usage)
|
||||
- [Пример](#example)
|
||||
@@ -32,6 +42,36 @@
|
||||
- Распаковать и положить в *Документы/Arduino/libraries/*
|
||||
- (Arduino IDE) автоматическая установка из .zip: *Скетч/Подключить библиотеку/Добавить .ZIP библиотеку…* и указать скачанный архив
|
||||
- Читай более подробную инструкцию по установке библиотек [здесь](https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
|
||||
### Обновление
|
||||
- Рекомендую всегда обновлять библиотеку: в новых версиях исправляются ошибки и баги, а также проводится оптимизация и добавляются новые фичи
|
||||
- Через менеджер библиотек IDE: найти библиотеку как при установке и нажать "Обновить"
|
||||
- Вручную: **удалить папку со старой версией**, а затем положить на её место новую. "Замену" делать нельзя: иногда в новых версиях удаляются файлы, которые останутся при замене и могут привести к ошибкам!
|
||||
|
||||
|
||||
<a id="interface"></a>
|
||||
## Интерфейс
|
||||
- Перед отправкой данных идёт синхронизирующий импульс, *TRAIN* мс
|
||||
- Далее старт импульс, *START* мс, LOW
|
||||
- Данные кодируются длиной импульса
|
||||
- Завершает отправку стоп импульс, *TRAIN* мс
|
||||

|
||||

|
||||
|
||||
<a id="wiring"></a>
|
||||
## Подключение
|
||||

|
||||
Передатчики:
|
||||
- SYN115, маленький чип: 1.8-3.6V, макс. скорость 8000
|
||||
- FS1000A: 3-12V, макс. скорость 10000
|
||||
- WL102-341: 2.0-3.6V, макс. скорость 6000
|
||||
|
||||
Приёмники:
|
||||
- SYN480R, крупный чип: 3.3-5.5V
|
||||
- MX-RM-5V (RF-5V): 5V
|
||||
- RX470 (WL101-341): 3-5V
|
||||
|
||||

|
||||

|
||||
|
||||
<a id="init"></a>
|
||||
## Инициализация
|
||||
@@ -56,14 +96,16 @@ Gyver433_RX<пин, буфер, CRC> rx;
|
||||
// ========= Gyver433_TX =========
|
||||
void sendData(T &data); // отправить данные любого типа (CRC добавляется автоматически)
|
||||
void write(uint8_t* buf, uint8_t size); // отправить массив байт указанного размера (CRC не добавляется)
|
||||
uint8_t buffer[]; // доступ к буферу приёма
|
||||
uint8_t byteBuf; // доступ к буферу принятого байта
|
||||
|
||||
// ========= Gyver433_RX =========
|
||||
// приём в прерывании
|
||||
void tickISR(); // тикер приёма для вызова в прерывании по CHANGE
|
||||
uint8_t tickISRraw(); // ручной приём в прерывании по CHANGE. Вернёт 1 (начало приёма), 2 (принят байт), 3 (конец пакета)
|
||||
|
||||
// приём в loop
|
||||
uint16_t tick(); // неблокирующий приём. Вернёт количество успешно принятых байт
|
||||
uint16_t tickWait(); // блокирующий приём. Вернёт количество успешно принятых байт
|
||||
|
||||
bool readData(T &data); // прочитает буфер в любой тип данных (в указанную переменную)
|
||||
uint16_t getSize(); // получить размер принятых данных
|
||||
uint16_t gotData(); // вернёт количество успешно принятых в tickISR() байт (см. пример isr_rx)
|
||||
@@ -87,10 +129,19 @@ uint8_t G433_crc_xor(uint8_t *buffer, uint8_t size); // ручной CRC XOR
|
||||
#define G433_CUT_RSSI // [RX] убрать расчёт RSSI из кода (сэкономит чуть памяти)
|
||||
```
|
||||
|
||||
### Работа приёмника без прерываний
|
||||
Для приёма данных достаточно вызывать в основном цикле метод `tick()`, он сам опрашивает пин радио.
|
||||
- Если в программе есть блокирующие места и loop() выполняется с задержками - будет потеря данных
|
||||
- Для более надёжного приёма рекомендуется вызывать `tickWait()`, она блокирует выполнение кода на время приёма.
|
||||
|
||||
### Работа приёмника с прерываниями
|
||||
Рекомендуется использовать приём в прерывании по CHANGE, для этого нужно вызывать в нём `tickISR()`.
|
||||
Тогда приём будет асинхронный и будет работать даже в загруженной программе.
|
||||
- Если стандартных пинов прерываний не хватает, можно задействовать PCINT. Вручную или с помощью библиотеки https://github.com/NicoHood/PinChangeInterrupt
|
||||
|
||||
<a id="example"></a>
|
||||
## Примеры
|
||||
Остальные примеры смотри в **examples**!
|
||||

|
||||
### Отправка
|
||||
```cpp
|
||||
#include <Gyver433.h>
|
||||
@@ -136,17 +187,6 @@ void loop() {
|
||||
}
|
||||
```
|
||||
|
||||
## Заметка по модулям:
|
||||
Передатчики:
|
||||
- SYN115, маленький чип: 1.8-3.6V, макс. скорость 8000
|
||||
- FS1000A: 3-12V, макс. скорость 10000
|
||||
- WL102-341: 2.0-3.6V, макс. скорость 6000
|
||||
|
||||
Приёмники:
|
||||
- SYN480R, крупный чип: 3.3-5.5V
|
||||
- MX-RM-5V (RF-5V): 5V
|
||||
- RX470 (WL101-341): 3-5V
|
||||
|
||||
<a id="versions"></a>
|
||||
## Версии
|
||||
- v1.0
|
||||
@@ -156,8 +196,19 @@ void loop() {
|
||||
- v1.4 - переделан FastIO
|
||||
- v1.4.1 - убран FastIO, CRC вынесен отдельно
|
||||
- v2.0 - убран буфер на отправку, убран манчестер, полностью переделан и оптимизирован интерфейс связи
|
||||
- v2.0.1 - fix compiler warnings
|
||||
|
||||
<a id="feedback"></a>
|
||||
## Баги и обратная связь
|
||||
При нахождении багов создавайте **Issue**, а лучше сразу пишите на почту [alex@alexgyver.ru](mailto:alex@alexgyver.ru)
|
||||
Библиотека открыта для доработки и ваших **Pull Request**'ов!
|
||||
Библиотека открыта для доработки и ваших **Pull Request**'ов!
|
||||
|
||||
|
||||
При сообщении о багах или некорректной работе библиотеки нужно обязательно указывать:
|
||||
- Версия библиотеки
|
||||
- Какой используется МК
|
||||
- Версия SDK (для ESP)
|
||||
- Версия Arduino IDE
|
||||
- Корректно ли работают ли встроенные примеры, в которых используются функции и конструкции, приводящие к багу в вашем коде
|
||||
- Какой код загружался, какая работа от него ожидалась и как он работает в реальности
|
||||
- В идеале приложить минимальный код, в котором наблюдается баг. Не полотно из тысячи строк, а минимальный код
|
||||
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
This is an automatic translation, may be incorrect in some places. See sources and examples!
|
||||
|
||||
# Gyver433
|
||||
Library for Radio Modules 433 MHz and Arduino
|
||||
- ** Data transfer from the module to the module on your own communication interface **, i.e.Does not work with Chinese remote controls and barriers!
|
||||
- Support for crooked Chinese modules
|
||||
- Built -in CRC Control of integrity
|
||||
- Accelerated IO algorithm for AVR Arduino
|
||||
- asynchronous reception in interruption
|
||||
- Super lightly Liba, will even start on Tini13
|
||||
|
||||
## compatibility
|
||||
Compatible with all arduino platforms (used arduino functions)
|
||||
- When connecting an interruption on the ESP8266, do not forget the Attricbut `IRAM_ATTR`
|
||||
|
||||
## Content
|
||||
- [installation] (# Install)
|
||||
- [interface] (#interface)
|
||||
- [connection] (#wiring)
|
||||
- [initialization] (#init)
|
||||
- [use] (#usage)
|
||||
- [Example] (# Example)
|
||||
- [versions] (#varsions)
|
||||
- [bugs and feedback] (#fedback)
|
||||
|
||||
<a id="install"> </a>
|
||||
## Installation
|
||||
- The library can be found by the name ** Gyver433 ** and installed through the library manager in:
|
||||
- Arduino ide
|
||||
- Arduino ide v2
|
||||
- Platformio
|
||||
- [download the library] (https://github.com/gyverlibs/gyver433/archive/refs/heads/main.zip) .Zip archive for manual installation:
|
||||
- unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64)
|
||||
- unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32)
|
||||
- unpack and put in *documents/arduino/libraries/ *
|
||||
- (Arduino id) Automatic installation from. Zip: * sketch/connect the library/add .Zip library ... * and specify downloaded archive
|
||||
- Read more detailed instructions for installing libraries [here] (https://alexgyver.ru/arduino-first/#%D0%A3%D1%81%D1%82%D0%B0%BD%D0%BE%BE%BE%BED0%B2%D0%BA%D0%B0_%D0%B1%D0%B8%D0%B1%D0%BB%D0%B8%D0%BE%D1%82%D0%B5%D0%BA)
|
||||
### Update
|
||||
- I recommend always updating the library: errors and bugs are corrected in the new versions, as well as optimization and new features are added
|
||||
- through the IDE library manager: find the library how to install and click "update"
|
||||
- Manually: ** remove the folder with the old version **, and then put a new one in its place.“Replacement” cannot be done: sometimes in new versions, files that remain when replacing are deleted and can lead to errors!
|
||||
|
||||
|
||||
<a Id="INterFace"> </a>
|
||||
## Interface
|
||||
- Before sending the data, there is a synchronizing pulse, * train * ms
|
||||
- Next, start impulse, * Start * ms, Low
|
||||
- Data is encoded by pulse length
|
||||
- completes the sending of the stop impulse, * train * ms
|
||||
! [Scheme] (/doc/interface.png)
|
||||
! [Scheme] (/doc/timing.png)
|
||||
|
||||
<a id="wiring"> </a>
|
||||
## connection
|
||||
! [Scheme] (/doc/radio433.png)
|
||||
Transmitters:
|
||||
- SYN115, small chip: 1.8-3.6V, max.speed 8000
|
||||
- FS1000A: 3-12V, Max.speed of 10,000
|
||||
-WL102-341: 2.0-3.6V, max.speed 6000
|
||||
|
||||
Receivers:
|
||||
- SYN480R, large chip: 3.3-5.5V
|
||||
-MX-RM-5V (RF-5V): 5V
|
||||
-RX470 (WL101-341): 3-5V
|
||||
|
||||
! [Scheme] (/doc/scheme.jpg)
|
||||
! [Scheme] (/doc/radio.png)
|
||||
|
||||
<a id="init"> </a>
|
||||
## initialization
|
||||
`` `CPP
|
||||
// === transmitter ===
|
||||
Gyver433_TX <PIN> TX;
|
||||
Gyver433_TX <PIN, CRC> TX;
|
||||
|
||||
// === The receiver ====
|
||||
Gyver433_rx <PIN> RX;
|
||||
Gyver433_rx <pin, buffer> rx;
|
||||
Gyver433_rx <pin, buffer, CRC> rx;
|
||||
|
||||
// PIN: Digital PIN
|
||||
// buffer: the size of the buffer in bytes, by the silence.64
|
||||
// CRC: Statement of data integrity: G433_CRC8 (reliable), G433_XOR (Light), G433_NOCRC (disconnected).By the silence.G433_CRC8
|
||||
`` `
|
||||
|
||||
<a id="usage"> </a>
|
||||
## Usage`` `CPP
|
||||
// ========= gyver433_TX ============
|
||||
VOID SendData (T & Data);// Send data any type (CRC is added automatically)
|
||||
VOID Write (uint8_t* buf, uint8_t size);// Send an array of byte of the specified size (CRC is not added)
|
||||
|
||||
// ========= gyver433_rx ============
|
||||
// Reception in interruption
|
||||
VOID Tickisr ();// Take of reception for calling in interruption by Change
|
||||
uint8_t TickisrRaw ();// manual reception in the interruption in Change.Return 1 (beginning of reception), 2 (Baite adopted), 3 (end of the package)
|
||||
|
||||
// Reception in Loop
|
||||
uint16_t tick ();// Neboking technique.Will return the number of successfully accepted bytes
|
||||
uint16_t tickwait ();// blocking reception.Will return the number of successfully accepted bytes
|
||||
|
||||
Bool Readdata (T & Data);// read the buffer in any type of data (in the specified variable)
|
||||
uint16_t getsize ();// Get the amount of data accepted
|
||||
uint16_t gotdata ();// will return the number of byte successfully accepted in Tickisr () (see ISR_RX example)
|
||||
uint8_t getrssi ();// get the quality of the reception (percentage of successful gears 0 .. 100)
|
||||
|
||||
uint8_t buffer [];// Access to the reception buffer
|
||||
uint8_t bytebuf;// Access to the Baita Boofer
|
||||
|
||||
// ============== CRC ==================
|
||||
// you can use the built -in functions for generating the CRC byt for manual packages
|
||||
uint8_t g433_crc8 (uint8_t *buffer, uint8_t size);// manual CRC8
|
||||
uint8_t g433_crc_xor (uint8_t *buffer, uint8_t size);// manual CRC XOR
|
||||
|
||||
// ====== Defain-settings ==========
|
||||
// Call before connecting the library
|
||||
#define g433_fast // [tx] short synchronization for green modules
|
||||
#define g433_Medium // [tx] average synchronization when sending to SYN480R more than 400MS (actively by default)
|
||||
#define g433_slow // [tx] Long synchronization when sending to SYN480R less often 400ms
|
||||
#define G433_Speed 1000 // [RX/TX] Speed, should be the same on RX and TX, 100-10,000 bits/s, silent.2000 bits/s
|
||||
#define g433_rssi_count 8 // [RX] The number of successfully accepted packets for RSSI calculation (according to default. 8)
|
||||
#define g433_cut_rssi // [rx] Remove the RSSI calculation from the code (save a little memory)
|
||||
`` `
|
||||
|
||||
### Work of the receiver without interruption
|
||||
To receive data, it is enough to cause a basic cycle of the `tick ()` method, he himself interviews a pin of the radio.
|
||||
- If the program has blocking places and Loop () is performed with delays - there will be a loss of data
|
||||
- For more reliable reception, it is recommended to call `tickwait ()`, it blocks the performance of the code during the reception.
|
||||
|
||||
### Work of the receiver with interruptions
|
||||
It is recommended to use the technique in the interrupt on Change, for this you need to call `Tickisr ()` in it.
|
||||
Then the reception will be asynchronous and will work even in a loaded program.
|
||||
- If the standard pins of interruptions are not enough, you can use PCINT.Manually or with the help of the library https://github.com/nicohood/pinchangeinterrapt
|
||||
|
||||
<a id="EXAMPLE"> </a>
|
||||
## Examples
|
||||
The rest of the examples look at ** Examples **!
|
||||
### Sending
|
||||
`` `CPP
|
||||
#include <gyver433.h>
|
||||
Gyver433_tx <2> tx;// indicated the pin
|
||||
|
||||
VOID setup () {
|
||||
}
|
||||
|
||||
Char Data [] = "Hello from #xx";// line for sending
|
||||
Byte count = 0;// counter for sending
|
||||
|
||||
VOID loop () {
|
||||
// Add the counter to the line
|
||||
Data [12] = (Count / 10) + '0';
|
||||
Data [13] = (Count % 10) + '0';
|
||||
if (++ count> = 100) count = 0;
|
||||
TX.SendData (Data);
|
||||
DELAY (100);
|
||||
}
|
||||
`` `
|
||||
|
||||
### Reception in interruption
|
||||
`` `CPP
|
||||
#include <gyver433.h>
|
||||
Gyver433_rx <2, 20> rx;// indicated the pin and size of the buffer
|
||||
|
||||
VOID setup () {
|
||||
Serial.Begin (9600);
|
||||
Attachinterrupt (0, Isr, Change);// Interruption of Pina Radio on Change
|
||||
}
|
||||
|
||||
// Special.The ticer is called in interruption
|
||||
VOID isr () {
|
||||
rx.tickisr ();
|
||||
}
|
||||
|
||||
VOID loop () {
|
||||
if (rx.gotdata ()) {// If more than 0 successfully accepted
|
||||
Serial.write (rx.buffer, rx.size);// Display
|
||||
Serial.println ();
|
||||
}
|
||||
DELAY (50);// imitation of a loaded code
|
||||
}
|
||||
`` `
|
||||
|
||||
<a id="versions"> </a>
|
||||
## versions
|
||||
- V1.0
|
||||
- V1.1 - optimization, new interface, support for cheap blue modules, work in interruption
|
||||
- V1.2 -improvement in communication quality, optimization of work in interruption
|
||||
- v1.3 - added RSSI withdrawal
|
||||
- V1.4 - Redeled Fastio
|
||||
- v1.4.1 - removed Fastio, CRC is taken separately
|
||||
- V2.0 - removed the buffer for sending, removed Manchester, completely redone and optimized the communication interface
|
||||
- V2.0.1 - FIX Compiler Warnings
|
||||
|
||||
<a id="feedback"> </a>
|
||||
## bugs and feedback
|
||||
Create ** Issue ** when you find the bugs, and better immediately write to the mail [alex@alexgyver.ru] (mailto: alex@alexgyver.ru)
|
||||
The library is open for refinement and your ** pull Request ** 'ow!
|
||||
|
||||
|
||||
When reporting about bugs or incorrect work of the library, it is necessary to indicate:
|
||||
- The version of the library
|
||||
- What is MK used
|
||||
- SDK version (for ESP)
|
||||
- version of Arduino ide
|
||||
- whether the built -in examples work correctly, in which the functions and designs are used, leading to a bug in your code
|
||||
- what code has been loaded, what work was expected from it and how it works in reality
|
||||
- Ideally, attach the minimum code in which the bug is observed.Not a canvas of a thousand lines, but a minimum code
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 222 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 172 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
+2
-2
@@ -1,9 +1,9 @@
|
||||
name=Gyver433
|
||||
version=2.0
|
||||
version=2.1.1
|
||||
author=AlexGyver <alex@alexgyver.ru>
|
||||
maintainer=AlexGyver <alex@alexgyver.ru>
|
||||
sentence=Simple library for 433 MHz radio
|
||||
paragraph=Simple library for 433 MHz radio
|
||||
category=Device Control
|
||||
url=https://github.com/GyverLibs/Gyver433
|
||||
architectures=*
|
||||
architectures=*
|
||||
|
||||
+3
-2
@@ -21,6 +21,7 @@
|
||||
v1.4 - переделан FastIO
|
||||
v1.4.1 - убран FastIO, CRC вынесен отдельно
|
||||
v2.0 - убран буфер на отправку, убран манчестер, полностью переделан и оптимизирован интерфейс связи
|
||||
v2.0.1 - fix compiler warnings
|
||||
*/
|
||||
|
||||
#ifndef _Gyver433_h
|
||||
@@ -53,7 +54,7 @@
|
||||
#define G433_EDGE_S (G433_START + G433_WINDOW)
|
||||
|
||||
// жоский delay для avr
|
||||
#ifdef AVR
|
||||
#ifdef _delay_us
|
||||
#define G433_DELAY(x) _delay_us(x)
|
||||
#else
|
||||
#define G433_DELAY(x) delayMicroseconds(x)
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
|
||||
// отправка, блокирующая. Кушает любой тип данных
|
||||
template <typename T>
|
||||
bool sendData(T &data) {
|
||||
void sendData(T &data) {
|
||||
uint8_t *ptr = (uint8_t*) &data;
|
||||
write(ptr, sizeof(T));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user