update documentation
This commit is contained in:
parent
bfe2280d16
commit
4cee82f28d
@ -1,15 +1,132 @@
|
|||||||
# A gateway for 433 MHz devices
|
# A gateway for 433 MHz devices
|
||||||
It uses [rc_switch](https://github.com/sui77/rc-switch) library for controlling wall sockets.
|
It uses [rc_switch](https://github.com/sui77/rc-switch) library for controlling wall sockets.
|
||||||
|
|
||||||
It also supports receiving commands from the same protocol.
|
It supports receiving:
|
||||||
|
- serial commands for controlling wall switches - all protocols
|
||||||
|
- RC commands from wall switches remotes - protocols 1 and 2
|
||||||
|
- sensors states over `Protocol 2`
|
||||||
|
|
||||||
It acts as a serial gateway and it is connected to a Raspberry Pi running Home assistant.
|
It acts as a serial gateway, communicating in JSON format, and it is connected to a Raspberry Pi running Home Assistant.
|
||||||
|
|
||||||
It uses an Arduino Pro Mini 5v 16 Mhz.
|
It uses an Arduino Pro Mini 5v 16 Mhz.
|
||||||
The original bootloader has been replaced with Optiboot using this tutorial: https://andreasrohner.at/posts/Electronics/How-to-make-the-Watchdog-Timer-work-on-an-Arduino-Pro-Mini-by-replacing-the-bootloader/
|
The original bootloader has been replaced with Optiboot using this tutorial: https://andreasrohner.at/posts/Electronics/How-to-make-the-Watchdog-Timer-work-on-an-Arduino-Pro-Mini-by-replacing-the-bootloader/
|
||||||
|
|
||||||
## Read sensors
|
## Receive RC
|
||||||
|
### Sensors
|
||||||
|
Sensors transmit state using `Protocol 2` and the gateway translates them into JSON over serial.
|
||||||
|
##### Protocol structure
|
||||||
|
```
|
||||||
|
STATE
|
||||||
|
|
|
||||||
|
1010|1|101010101|1010101010101|10101
|
||||||
|
----|-----------|-------------|-----
|
||||||
|
TYPE| VALUE | VCC | ID
|
||||||
|
```
|
||||||
|
##### Sensors types
|
||||||
|
```C++
|
||||||
|
enum SensorType : unsigned short {
|
||||||
|
GENERIC = 4,
|
||||||
|
HUMIDITY = 5,
|
||||||
|
TEMPERATURE = 6,
|
||||||
|
CONTACT = 7
|
||||||
|
};
|
||||||
|
```
|
||||||
|
##### Sensors IDs
|
||||||
|
```C++
|
||||||
|
enum SensorId : unsigned short {
|
||||||
|
WINDOW1 = 1,
|
||||||
|
WINDOW2 = 2,
|
||||||
|
WATER_SENSOR = 3,
|
||||||
|
TEMP_SENSOR = 4,
|
||||||
|
LIGHT_SENSOR = 5,
|
||||||
|
MOVEMENT_SENSOR = 6,
|
||||||
|
OIL_SENSOR = 7
|
||||||
|
};
|
||||||
|
```
|
||||||
|
#### Stairs temperature
|
||||||
|
##### Value and volatage
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"sensor": {
|
||||||
|
"id": 4,
|
||||||
|
"diagnostic": {
|
||||||
|
"voltage": 2.239
|
||||||
|
},
|
||||||
|
"temperature": 16.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
##### Value only
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"sensor": {
|
||||||
|
"id": 4,
|
||||||
|
"temperature": 16.2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
#### Oil sensor
|
||||||
|
##### Value and volatage
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"sensor": {
|
||||||
|
"id": 7,
|
||||||
|
"diagnostic": {
|
||||||
|
"voltage": 4.282
|
||||||
|
},
|
||||||
|
"value": 13
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
### Switches
|
||||||
|
Gateway receives remote commands over RC Switch and translates them into JSON over serial
|
||||||
|
#### Protocol 1
|
||||||
|
##### on
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rcSwitch": {
|
||||||
|
"protocol": 1,
|
||||||
|
"state": true,
|
||||||
|
"group": "1",
|
||||||
|
"channel": 1,
|
||||||
|
"raw_value": 5571921
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
##### off
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rcSwitch": {
|
||||||
|
"protocol": 1,
|
||||||
|
"state": false,
|
||||||
|
"group": "1",
|
||||||
|
"channel": 1,
|
||||||
|
"raw_value": 5571921
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Protocol 2
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rcSwitch": {
|
||||||
|
"protocol": 2,
|
||||||
|
"value": 2650807673
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Other protocols
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rcSwitch": {
|
||||||
|
"protocol": 4,
|
||||||
|
"value": 1234567890
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
### DHT
|
### DHT
|
||||||
|
Reads local DHT11 sensor and outputs JSON over serial
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"dht11": {
|
"dht11": {
|
||||||
@ -18,40 +135,49 @@ The original bootloader has been replaced with Optiboot using this tutorial: htt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### RC Switch
|
---
|
||||||
#### on
|
## Receive commands
|
||||||
```
|
It receives commands over serial, in JSON format, and executes them.
|
||||||
[
|
#### Protocol 1
|
||||||
{
|
##### on
|
||||||
"rcSwitch": {
|
```json
|
||||||
"protocol": 1,
|
{
|
||||||
"group": "00001",
|
"rcSwitch": {
|
||||||
"channel": 1,
|
"protocol": 1,
|
||||||
"state": true
|
"group": "00001",
|
||||||
}
|
"channel": 1,
|
||||||
|
"state": true
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
```
|
```
|
||||||
#### off
|
##### off
|
||||||
```
|
```json
|
||||||
[
|
{
|
||||||
{
|
"rcSwitch": {
|
||||||
"rcSwitch": {
|
"protocol": 1,
|
||||||
"protocol": 1,
|
"group": "00001",
|
||||||
"group": "00001",
|
"channel": 1,
|
||||||
"channel": 1,
|
"state": false
|
||||||
"state": false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
```
|
```
|
||||||
```
|
|
||||||
[
|
#### Protocol 2
|
||||||
{
|
```json
|
||||||
"rcSwitch": {
|
{
|
||||||
"protocol": 2,
|
"rcSwitch": {
|
||||||
"value": "10011110000000000001110101111001"
|
"protocol": 2,
|
||||||
}
|
"value": "10010110000000000001110101111001"
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Other protocols
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"rcSwitch": {
|
||||||
|
"protocol": 4,
|
||||||
|
"value": "010001101001100101110100"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
# Temperature sensor
|
# Temperature sensor
|
||||||
|
|
||||||
It uses a [TMP36](https://cloud.hodos.ro/wiki/ha/datasheets/TMP35_36_37.pdf) to read temperature and it is optimised for power consumption.
|
It uses a [TMP36](https://cloud.hodos.ro/wiki/ha/datasheets/TMP35_36_37.pdf) to read temperature and it is optimised for power consumption.
|
||||||
It uses watch dog that wakes every 8s and increments a counter. Once the counter reaches a certain value (e.g. equivalent to 5 mins), it will read and send temperature to the gateway.
|
It uses watch dog that wakes every 8s and increments a counter. Once the counter reaches a certain value (e.g. equivalent to 1 hour), it will read and send temperature to the gateway.
|
||||||
Every hour the voltage is also read and sent.
|
Every 12 hours the voltage is also read and sent.
|
||||||
|
|
||||||
According to the calculator here, https://www.geekstips.com/battery-life-calculator-sleep-mode/, a cell coin battery with a capacity of `240mAh` should last for
|
According to the [battery life calculator](https://www.allaboutcircuits.com/tools/battery-lifetime-calculator/), a cell coin battery with a capacity of `200mAh` should last for
|
||||||
`~ 3 months (108 days)`, given that:
|
`~ 3 years`, given that:
|
||||||
- Current consumption of device during sleep is `4.5uA`
|
- Current consumption of device during sleep is `4.5uA`
|
||||||
- Device wakes up every `5 mins (12 times/hour)`
|
- Device wakes up every `hour`
|
||||||
- Current consumption of device during wake is `10mA`
|
- Current consumption of device during wake is `10mA`
|
||||||
- Duration of wake time is `1000 ms`
|
- Duration of wake time is `1000 ms`
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user