Skip to content

Commit

Permalink
Nvk/crowcon xgard bright arrakis 2.5.0 gw (#306)
Browse files Browse the repository at this point in the history
* making last fixes for Crowcon H2 sensor.
  • Loading branch information
nkrasko authored May 2, 2024
1 parent 0a6ed95 commit e83ce52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .marketplace/devices/devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
- blueprint: gas_sensors/crowcon_xgard_bright_arrakis_mk4
display_name: Arrakis MK4 IPC Version
description: Use Enapter Gateway on Arrakis MK4 IPC to integrate Crowcon Xgard Bright.
verification_level: ready_for_testing
verification_level: verified

- id: crowcon-xgardiq
display_name: Crowcon XgardIQ
Expand Down
16 changes: 10 additions & 6 deletions gas_sensors/crowcon_xgard_bright_arrakis_mk4/firmware.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ADDRESS_CONFIG = 'address'
BAUD_RATE_CONFIG = 'baud_rate'

local CONNECTION = {}
local SERIAL_OPTIONS = {}
local TTY

function main()
Expand Down Expand Up @@ -41,16 +42,19 @@ function tty_init()
return nil, 'not_configured'
else
CONNECTION = {
baudrate = tonumber(baud_rate),
read_timeout = 1000,
address = tonumber(address),
}

SERIAL_OPTIONS = {
baud_rate = tonumber(baud_rate),
parity = 'N',
stop_bits = '2',
stop_bits = 2,
data_bits = 8,
read_timeout = 1000,
address = tonumber(address),
port = port,
}

TTY = modbusrtu.new(port, CONNECTION)
TTY = modbusrtu.new(port, SERIAL_OPTIONS)

if TTY then
return TTY, nil
Expand All @@ -69,7 +73,7 @@ function send_telemetry()
local connection, err = tty_init()

if connection then
local data, result = connection:read_inputs(CONNECTION.address, 1000, 2, CONNECTION.read_timeout)
local data, result = connection:read_holdings(CONNECTION.address, 1000, 2, CONNECTION.read_timeout)

if data then
telemetry['h2_concentration'] = tofloat(data)
Expand Down

0 comments on commit e83ce52

Please sign in to comment.