upload with drone pipeline, add json examples
This commit is contained in:
parent
66854190df
commit
8a554a75f0
26
gateway/.drone.yml
Normal file
26
gateway/.drone.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: upload gateway firmare
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
commands:
|
||||
- pio run -e pro-mini
|
||||
|
||||
- name: upload
|
||||
commands:
|
||||
- pio run -e pro-mini -t upload
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- gateway
|
||||
target:
|
||||
- production
|
||||
|
||||
node:
|
||||
host: homebox
|
||||
@ -6,4 +6,52 @@ It also supports receiving commands from the same protocol.
|
||||
It acts as a serial gateway and it is connected to a Raspberry Pi running Home assistant.
|
||||
|
||||
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
|
||||
### DHT
|
||||
```
|
||||
{
|
||||
"dht11": {
|
||||
"temperature": 31.9,
|
||||
"humidity": 45
|
||||
}
|
||||
}
|
||||
```
|
||||
### RC Switch
|
||||
#### on
|
||||
```
|
||||
[
|
||||
{
|
||||
"rcSwitch": {
|
||||
"protocol": 1,
|
||||
"group": "00001",
|
||||
"channel": 1,
|
||||
"state": true
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
#### off
|
||||
```
|
||||
[
|
||||
{
|
||||
"rcSwitch": {
|
||||
"protocol": 1,
|
||||
"group": "00001",
|
||||
"channel": 1,
|
||||
"state": false
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
```
|
||||
[
|
||||
{
|
||||
"rcSwitch": {
|
||||
"protocol": 2,
|
||||
"value": "10011110000000000001110101111001"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
@ -8,10 +8,9 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:uno]
|
||||
[env:pro-mini]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
board_build.mcu = atmega328p
|
||||
board = pro16MHzatmega328
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
sui77/rc-switch@^2.6.3
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
|
||||
#define READ_INTERVAL(c) (c*60*1000UL) // read interval in minutes
|
||||
|
||||
const unsigned long readInterval = READ_INTERVAL(5);
|
||||
unsigned long lastReadTime = -READ_INTERVAL(10);
|
||||
unsigned long currentTime = 0;
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
DHT dht = DHT(DHT11_PIN, DHT11);
|
||||
@ -38,6 +37,7 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
currentTime = millis();
|
||||
StaticJsonDocument<200> jsonDoc;
|
||||
readCommand();
|
||||
readRcSwitch(jsonDoc);
|
||||
@ -126,9 +126,9 @@ void readCommand() {
|
||||
}
|
||||
|
||||
void readDht(JsonDocument& jsonDoc) {
|
||||
unsigned long currentTime = millis();
|
||||
if ((currentTime - lastReadTime) > readInterval) {
|
||||
lastReadTime = currentTime;
|
||||
static unsigned long lastReadTime = 0;
|
||||
if (currentTime > lastReadTime) {
|
||||
lastReadTime = currentTime + READ_INTERVAL(5);
|
||||
JsonObject dht11 = jsonDoc.createNestedObject("dht11");
|
||||
dht11["temperature"] = dht.readTemperature();
|
||||
dht11["humidity"] = dht.readHumidity();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user