english readme
This commit is contained in:
+142
-127
@@ -1,55 +1,61 @@
|
|||||||
This is an automatic translation, may be incorrect in some places. See sources and examples!
|
This is an automatic translation, may be incorrect in some places. See sources and examples!
|
||||||
|
|
||||||
# Gyver433
|
# Gyver433
|
||||||
Library for 433 MHz radio modules and Arduino
|
Library for Radio Modules 433 MHz and Arduino
|
||||||
- Support for curved Chinese modules
|
- ** Data transfer from the module to the module on your own communication interface **, i.e.Does not work with Chinese remote controls and barriers!
|
||||||
- Built-in CRC integrity check
|
- Support for crooked Chinese modules
|
||||||
|
- Built -in CRC Control of integrity
|
||||||
- Accelerated IO algorithm for AVR Arduino
|
- Accelerated IO algorithm for AVR Arduino
|
||||||
- Asynchronous receive in interrupt
|
- asynchronous reception in interruption
|
||||||
- Super light liba, it will start even on a tini13
|
- Super lightly Liba, will even start on Tini13
|
||||||
|
|
||||||
### Compatibility
|
## compatibility
|
||||||
Compatible with all Arduino platforms (using Arduino functions)
|
Compatible with all arduino platforms (used arduino functions)
|
||||||
- When connecting an interrupt on esp8266, do not forget the `IRAM_ATTR` attribute
|
- When connecting an interruption on the ESP8266, do not forget the Attricbut `IRAM_ATTR`
|
||||||
|
|
||||||
## Content
|
## Content
|
||||||
- [Install](#install)
|
- [installation] (# Install)
|
||||||
- [Interface](#interface)
|
- [interface] (#interface)
|
||||||
- [Connection](#wiring)
|
- [connection] (#wiring)
|
||||||
- [Initialization](#init)
|
- [initialization] (#init)
|
||||||
- [Usage](#usage)
|
- [use] (#usage)
|
||||||
- [Example](#example)
|
- [Example] (# Example)
|
||||||
- [Versions](#versions)
|
- [versions] (#varsions)
|
||||||
- [Bugs and feedback](#feedback)
|
- [bugs and feedback] (#fedback)
|
||||||
|
|
||||||
<a id="install"> </a>
|
<a id="install"> </a>
|
||||||
## Installation
|
## Installation
|
||||||
- The library can be found under the name **Gyver433** and installed via the library manager in:
|
- The library can be found by the name ** Gyver433 ** and installed through the library manager in:
|
||||||
- Arduino IDE
|
- Arduino ide
|
||||||
- Arduino IDE v2
|
- Arduino ide v2
|
||||||
- PlatformIO
|
- Platformio
|
||||||
- [Download library](https://github.com/GyverLibs/Gyver433/archive/refs/heads/main.zip) .zip archive for manual installation:
|
- [download the library] (https://github.com/gyverlibs/gyver433/archive/refs/heads/main.zip) .Zip archive for manual installation:
|
||||||
- Unzip and put in *C:\Program Files (x86)\Arduino\libraries* (Windows x64)
|
- unpack and put in * C: \ Program Files (X86) \ Arduino \ Libraries * (Windows X64)
|
||||||
- Unzip and put in *C:\Program Files\Arduino\libraries* (Windows x32)
|
- unpack and put in * C: \ Program Files \ Arduino \ Libraries * (Windows X32)
|
||||||
- Unpack and put in *Documents/Arduino/libraries/*
|
- unpack and put in *documents/arduino/libraries/ *
|
||||||
- (Arduino IDE) automatic installation from .zip: *Sketch/Include library/Add .ZIP library…* and specify the downloaded archive
|
- (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%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)
|
- 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>
|
|
||||||
|
<a Id="INterFace"> </a>
|
||||||
## Interface
|
## Interface
|
||||||
- Before sending data there is a clock pulse, *TRAIN* ms
|
- Before sending the data, there is a synchronizing pulse, * train * ms
|
||||||
- Next start impulse, *START* ms, LOW
|
- Next, start impulse, * Start * ms, Low
|
||||||
- Data is encoded by pulse length
|
- Data is encoded by pulse length
|
||||||
- Terminates the sending of a stop pulse, *TRAIN* ms
|
- completes the sending of the stop impulse, * train * ms
|
||||||

|
! [Scheme] (/doc/interface.png)
|
||||||

|
! [Scheme] (/doc/timing.png)
|
||||||
|
|
||||||
<a id="wiring"> </a>
|
<a id="wiring"> </a>
|
||||||
## Connection
|
## connection
|
||||||

|
! [Scheme] (/doc/radio433.png)
|
||||||
Transmitters:
|
Transmitters:
|
||||||
- SYN115, small chip: 1.8-3.6V, max.speed 8000
|
- SYN115, small chip: 1.8-3.6V, max.speed 8000
|
||||||
- FS1000A: 3-12V, max. speed 10000
|
- FS1000A: 3-12V, Max.speed of 10,000
|
||||||
-WL102-341: 2.0-3.6V, max.speed 6000
|
-WL102-341: 2.0-3.6V, max.speed 6000
|
||||||
|
|
||||||
Receivers:
|
Receivers:
|
||||||
@@ -57,135 +63,144 @@ Receivers:
|
|||||||
-MX-RM-5V (RF-5V): 5V
|
-MX-RM-5V (RF-5V): 5V
|
||||||
-RX470 (WL101-341): 3-5V
|
-RX470 (WL101-341): 3-5V
|
||||||
|
|
||||||

|
! [Scheme] (/doc/scheme.jpg)
|
||||||

|
! [Scheme] (/doc/radio.png)
|
||||||
|
|
||||||
<a id="init"> </a>
|
<a id="init"> </a>
|
||||||
## Initialization
|
## initialization
|
||||||
```cpp
|
`` `CPP
|
||||||
// === TRANSMITTER ===
|
// === transmitter ===
|
||||||
Gyver433_TX<pin> tx;
|
Gyver433_TX <PIN> TX;
|
||||||
Gyver433_TX<pin, CRC> tx;
|
Gyver433_TX <PIN, CRC> TX;
|
||||||
|
|
||||||
// === RECEIVER ===
|
// === The receiver ====
|
||||||
Gyver433_RX<pin> rx;
|
Gyver433_rx <PIN> RX;
|
||||||
Gyver433_RX<pin, buffer> rx;
|
Gyver433_rx <pin, buffer> rx;
|
||||||
Gyver433_RX<pin, buffer, CRC> rx;
|
Gyver433_rx <pin, buffer, CRC> rx;
|
||||||
|
|
||||||
// pin: digital pin
|
// PIN: Digital PIN
|
||||||
// buffer: buffer size in bytes, default 64
|
// buffer: the size of the buffer in bytes, by the silence.64
|
||||||
// CRC: data integrity check: G433_CRC8 (reliable), G433_XOR (light), G433_NOCRC (disabled). By default G433_CRC8
|
// CRC: Statement of data integrity: G433_CRC8 (reliable), G433_XOR (Light), G433_NOCRC (disconnected).By the silence.G433_CRC8
|
||||||
`` `
|
`` `
|
||||||
|
|
||||||
<a id="usage"> </a>
|
<a id="usage"> </a>
|
||||||
## Usage
|
## Usage`` `CPP
|
||||||
```cpp
|
// ========= gyver433_TX ============
|
||||||
// ========= Gyver433_TX =========
|
VOID SendData (T & Data);// Send data any type (CRC is added automatically)
|
||||||
void sendData(T&data); // send data of any type (CRC added automatically)
|
VOID Write (uint8_t* buf, uint8_t size);// Send an array of byte of the specified size (CRC is not added)
|
||||||
void write(uint8_t* buf, uint8_t size); // send an array of bytes of the specified size (no CRC added)
|
|
||||||
|
|
||||||
// ========= Gyver433_RX =========
|
// ========= gyver433_rx ============
|
||||||
// receive in interrupt
|
// Reception in interruption
|
||||||
void tickISR(); // receive ticker to call in CHANGE interrupt
|
VOID Tickisr ();// Take of reception for calling in interruption by Change
|
||||||
uint8_t tickISRraw(); // manual reception in CHANGE interrupt. Returns 1 (beginning of reception), 2 (byte received), 3 (end of packet)
|
uint8_t TickisrRaw ();// manual reception in the interruption in Change.Return 1 (beginning of reception), 2 (Baite adopted), 3 (end of the package)
|
||||||
|
|
||||||
// receive in loop
|
// Reception in Loop
|
||||||
uint16_t tick(); // non-blocking receive. Returns the number of successfully received bytes
|
uint16_t tick ();// Neboking technique.Will return the number of successfully accepted bytes
|
||||||
uint16_t tickWait(); // blocking receive. Returns the number of successfully received bytes
|
uint16_t tickwait ();// blocking reception.Will return the number of successfully accepted bytes
|
||||||
|
|
||||||
bool readData(T&data); // read the buffer into any data type (into the specified penexchange)
|
Bool Readdata (T & Data);// read the buffer in any type of data (in the specified variable)
|
||||||
uint16_t getSize(); // get the size of the received data
|
uint16_t getsize ();// Get the amount of data accepted
|
||||||
uint16_t gotData(); // will return the number of bytes successfully received in tickISR() (see isr_rx example)
|
uint16_t gotdata ();// will return the number of byte successfully accepted in Tickisr () (see ISR_RX example)
|
||||||
uint8_t getRSSI(); // get reception quality (percentage of successful transmissions 0.. 100)
|
uint8_t getrssi ();// get the quality of the reception (percentage of successful gears 0 .. 100)
|
||||||
|
|
||||||
uint8_tbuffer[]; // access to the receive buffer
|
uint8_t buffer [];// Access to the reception buffer
|
||||||
uint8_t byteBuf; // access to the received byte buffer
|
uint8_t bytebuf;// Access to the Baita Boofer
|
||||||
|
|
||||||
// ============= CRC ==============
|
// ============== CRC ==================
|
||||||
// you can use built-in functions to generate a CRC byte for manually packing packets
|
// 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_crc8 (uint8_t *buffer, uint8_t size);// manual CRC8
|
||||||
uint8_t G433_crc_xor(uint8_t *buffer, uint8_t size); // manual CRC XOR
|
uint8_t g433_crc_xor (uint8_t *buffer, uint8_t size);// manual CRC XOR
|
||||||
|
|
||||||
// ====== DEFINE-SETTINGS ======
|
// ====== Defain-settings ==========
|
||||||
// call before linking the library
|
// Call before connecting the library
|
||||||
#define G433_FAST // [TX] fast sync for green modules
|
#define g433_fast // [tx] short synchronization for green modules
|
||||||
#define G433_MEDIUM // [TX] average timing when sent to SYN480R OVER 400ms (active by default)
|
#define g433_Medium // [tx] average synchronization when sending to SYN480R more than 400MS (actively by default)
|
||||||
#define G433_SLOW // [TX] long sync when sent to SYN480R LESS than 400ms
|
#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-10000 bps, default 2000 bps
|
#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] number of successfully received packets for RSSI calculation (default 8)
|
#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 RSSI calculation from code (save some memory)
|
#define g433_cut_rssi // [rx] Remove the RSSI calculation from the code (save a little memory)
|
||||||
`` `
|
`` `
|
||||||
|
|
||||||
### Receiver operation without interruption
|
### Work of the receiver without interruption
|
||||||
To receive data, it is enough to call the `tick()` method in the main loop, it polls the radio pin itself.
|
To receive data, it is enough to cause a basic cycle of the `tick ()` method, he himself interviews a pin of the radio.
|
||||||
- If there are blocking places in the program and loop() is executed with delays - there will be data loss
|
- If the program has blocking places and Loop () is performed with delays - there will be a loss of data
|
||||||
- For a more reliable reception, it is recommended to call `tickWait()`, it blocks the execution of the code for the duration of the reception.
|
- For more reliable reception, it is recommended to call `tickwait ()`, it blocks the performance of the code during the reception.
|
||||||
|
|
||||||
### Receiver operation with interrupts
|
### Work of the receiver with interruptions
|
||||||
It is recommended to use the CHANGE interrupt technique by calling `tickISR()` in it.
|
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 the loaded program.
|
Then the reception will be asynchronous and will work even in a loaded program.
|
||||||
- If the standard interrupt pins are not enough, you can use PCINT. Manually or withLibraries https://github.com/NicoHood/PinChangeInterrupt
|
- 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>
|
<a id="EXAMPLE"> </a>
|
||||||
## Examples
|
## Examples
|
||||||
See **examples** for other examples!
|
The rest of the examples look at ** Examples **!
|
||||||
### Sending
|
### Sending
|
||||||
```cpp
|
`` `CPP
|
||||||
#include <Gyver433.h>
|
#include <gyver433.h>
|
||||||
Gyver433_TX<2>tx; // specified pin
|
Gyver433_tx <2> tx;// indicated the pin
|
||||||
|
|
||||||
void setup() {
|
VOID setup () {
|
||||||
}
|
}
|
||||||
|
|
||||||
chardata[] = "Hello from #xx"; // string to send
|
Char Data [] = "Hello from #xx";// line for sending
|
||||||
byte count = 0; // counter to send
|
Byte count = 0;// counter for sending
|
||||||
|
|
||||||
void loop() {
|
VOID loop () {
|
||||||
// add counter to string
|
// Add the counter to the line
|
||||||
data[12] = (count / 10) + '0';
|
Data [12] = (Count / 10) + '0';
|
||||||
data[13] = (count % 10) + '0';
|
Data [13] = (Count % 10) + '0';
|
||||||
if (++ count> = 100) count = 0;
|
if (++ count> = 100) count = 0;
|
||||||
tx.sendData(data);
|
TX.SendData (Data);
|
||||||
delay(100);
|
DELAY (100);
|
||||||
}
|
}
|
||||||
`` `
|
`` `
|
||||||
|
|
||||||
### Receive in interrupt
|
### Reception in interruption
|
||||||
```cpp
|
`` `CPP
|
||||||
#include <Gyver433.h>
|
#include <gyver433.h>
|
||||||
Gyver433_RX<2, 20> rx; // specified pin and buffer size
|
Gyver433_rx <2, 20> rx;// indicated the pin and size of the buffer
|
||||||
|
|
||||||
void setup() {
|
VOID setup () {
|
||||||
Serial.begin(9600);
|
Serial.Begin (9600);
|
||||||
attachInterrupt(0, isr, CHANGE); // interrupt radio pin by CHANGE
|
Attachinterrupt (0, Isr, Change);// Interruption of Pina Radio on Change
|
||||||
}
|
}
|
||||||
|
|
||||||
// spec. ticker is called in interrupt
|
// Special.The ticer is called in interruption
|
||||||
void isr() {
|
VOID isr () {
|
||||||
rx.tickISR();
|
rx.tickisr ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
VOID loop () {
|
||||||
if (rx.gotData()) { // if more than 0 successfully received
|
if (rx.gotdata ()) {// If more than 0 successfully accepted
|
||||||
Serial.write(rx.buffer, rx.size); // output
|
Serial.write (rx.buffer, rx.size);// Display
|
||||||
Serial.println ();
|
Serial.println ();
|
||||||
}
|
}
|
||||||
delay(50); // simulate loaded code
|
DELAY (50);// imitation of a loaded code
|
||||||
}
|
}
|
||||||
`` `
|
`` `
|
||||||
|
|
||||||
<a id="versions"> </a>
|
<a id="versions"> </a>
|
||||||
## Versions
|
## versions
|
||||||
- v1.0
|
- V1.0
|
||||||
- v1.1 - optimization, new interface, support for cheap blue modules, work in interrupt
|
- V1.1 - optimization, new interface, support for cheap blue modules, work in interruption
|
||||||
- v1.2 - improving the quality of communication, optimization of work in interruption
|
- V1.2 -improvement in communication quality, optimization of work in interruption
|
||||||
- v1.3 - added RSSI output
|
- v1.3 - added RSSI withdrawal
|
||||||
- v1.4 - redesigned FastIO
|
- V1.4 - Redeled Fastio
|
||||||
- v1.4.1 - FastIO removed, CRC moved separately
|
- v1.4.1 - removed Fastio, CRC is taken separately
|
||||||
- v2.0 - removed buffer for sending, removed Manchester, completely redone and optimized communication interface
|
- V2.0 - removed the buffer for sending, removed Manchester, completely redone and optimized the communication interface
|
||||||
- v2.0.1 - fix compiler warnings
|
- V2.0.1 - FIX Compiler Warnings
|
||||||
|
|
||||||
<a id="feedback"> </a>
|
<a id="feedback"> </a>
|
||||||
## Bugs and feedback
|
## bugs and feedback
|
||||||
When you find bugs, create an **Issue**, or better, immediately write to the mail [alex@alexgyver.ru](mailto:alex@alexgyver.ru)
|
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 revision and your **Pull Request**'s!
|
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
|
||||||
Reference in New Issue
Block a user