Skip to content

Commit

Permalink
Nvk/imt solar si r s485tc 2t arrakis mk4 (#309)
Browse files Browse the repository at this point in the history
* Adding IMT Solar Irradiance Sensor Si-RS485TC-2T for Arrakis MK4
  • Loading branch information
nkrasko authored May 3, 2024
1 parent 5838717 commit b84b63e
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .marketplace/devices/devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,19 @@

- id: imt-solar-si-rS485tc-2t
display_name: IMT Solar Irradiance Sensor Si-RS485TC-2T
description: Irradiance sensor.
description: Professional Irradiance Sensor
icon: enapter-solar-panel
vendor: imt
category: irradiance_sensors
blueprint_options:
- blueprint: irradiance_sensors/imt_solar_si-rS485tc-2t
display_name: ENP-RS485 UCM Version
description: Use Enapter ENP-RS485 to integrate IMT Solar Irradiance Sensor Si-RS485TC-2T
verification_level: verified
- blueprint: irradiance_sensors/imt_solar_si-rS485tc-2t_arrakis_mk4
display_name: Arrakis MK4 IPC Version
description: Use Enapter Gateway on Arrakis MK4 IPC to integrate IMT Solar Irradiance Sensor Si-RS485TC-2T
verification_level: ready_for_testing

- id: eastron-sdm120ct
display_name: Eastron SDM120CT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This [Enapter Device Blueprint](https://go.enapter.com/marketplace-readme) integ

## Configuring RS485 Ports of Arrakis MK4

Crowcon Xgard Bright works over RS-485 port. Arrakis MK4 have universal ports which needs to be configured in BIOS of the IPC to required mode.
Alicat Scientific Mass Flow Meters CODA-Series works over RS-485 port. Arrakis MK4 have universal ports which needs to be configured in BIOS of the IPC to required mode.

1. Reboot IPC and press `Del` button on the keyboard to enter BIOS setup utility.
2. Navigate to `Advanced` -> `SIO F81804`.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions irradiance_sensors/imt_solar_si-rS485tc-2t_arrakis_mk4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# IMT Solar Si-RS485TC-2T

This [Enapter Device Blueprint](https://go.enapter.com/marketplace-readme) integrates **IMT Solar Si-RS485TC-2T** - irradiance sensor with [ModBus RTU](https://go.enapter.com/developers-enapter-modbus) over [RS-485 communication interface](https://go.enapter.com/developers-enapter-rs485) optimized for [Arrakis MK4 IPC](https://www.welotec.com/product/fanless-industrial-computer-arrakis-mk4-series/).

## Configuring RS485 Ports of Arrakis MK4

Crowcon Xgard Bright works over RS-485 port. Arrakis MK4 have universal ports which needs to be configured in BIOS of the IPC to required mode.

1. Reboot IPC and press `Del` button on the keyboard to enter BIOS setup utility.
2. Navigate to `Advanced` -> `SIO F81804`.

<img src="./.assets/1-arrakis-mk4-advanced.jpeg" alt="SIO F81804" width="25%" />

3. Select the port you would like to use for connection of gas sensor. `UART Port 1 (ttyS0)` or `UART Port 2 (ttyS1)`.

<img src="./.assets/2-arrakis-mk4-f81804-conf.jpeg" alt="Arrakis MK4 UART" width="25%" />

3. Set `Peripheral Type` to `RS485` and press `F10` on keyboard to save and exit configuration

<img src="./.assets/3-arrakis-mk4-uart-1-conf.jpeg" alt="Arrakis MK4 UART" width="25%" />

## Connect to Enapter

- Sign up to the Enapter Cloud using the [Web](https://cloud.enapter.com/) or mobile app ([iOS](https://apps.apple.com/app/id1388329910), [Android](https://play.google.com/store/apps/details?id=com.enapter&hl=en)).
- Use the [Enapter ENP-RS485](https://go.enapter.com/handbook-enp-rs485) module for physical connection. See [connection instructions](https://go.enapter.com/handbook-enp-rs485-conn) in the module manual.
- [Add ENP-RS485 to your site](https://go.enapter.com/handbook-mobile-app) using the mobile app.
- [Upload](https://go.enapter.com/developers-upload-blueprint) this blueprint to ENP-RS485.

## References

- [IMT Solar Si Series data sheet](https://go.enapter.com/imt-solar-si-datasheet)
- [Description MODBUS protocol for IMT Solar Si-RS485 sensors](https://go.enapter.com/imt-solar-si-modbus)
- [Arrakis MK4 IPC](https://www.welotec.com/product/fanless-industrial-computer-arrakis-mk4-series/)
131 changes: 131 additions & 0 deletions irradiance_sensors/imt_solar_si-rS485tc-2t_arrakis_mk4/firmware.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
local config = require('enapter.ucm.config')

-- Configuration variables must be also defined
-- in `write_configuration` command arguments in manifest.yml
PORT_CONFIG = 'port'
ADDRESS_CONFIG = 'address'
BAUD_RATE_CONFIG = 'baud_rate'
STOP_BITS_CONFIG = 'stop_bits'
PARITY_CONFIG = 'parity'

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

function main()
config.init({
[PORT_CONFIG] = { type = 'string', required = true },
[ADDRESS_CONFIG] = { type = 'string', required = true, default = 1 },
[BAUD_RATE_CONFIG] = { type = 'number', required = true, default = 19200 },
[STOP_BITS_CONFIG] = { type = 'number', required = true, default = 1 },
[PARITY_CONFIG] = { type = 'string', required = true, default = 'N' },
})
scheduler.add(30000, send_properties)
scheduler.add(1000, send_telemetry)
end

function send_properties()
enapter.send_properties({
vendor = 'IMT Solar',
model = 'Si-RS485TC-2T',
})
end

function tty_init()
if TTY then
return TTY, nil
end

local values, err = config.read_all()
if err then
enapter.log('cannot read config: ' .. tostring(err), 'error')
return nil, 'cannot_read_config'
else
local port, address, baud_rate, stop_bits, parity =
values[PORT_CONFIG],
values[ADDRESS_CONFIG],
values[BAUD_RATE_CONFIG],
values[STOP_BITS_CONFIG],
values[PARITY_CONFIG]
if not port or not address or not baud_rate or not stop_bits or not parity then
return nil, 'not_configured'
else
CONNECTION = {
address = tonumber(address),
read_timeout = 1000,
}

SERIAL_OPTIONS = {
baud_rate = tonumber(baud_rate),
parity = tostring(parity),
stop_bits = tostring(stop_bits),
data_bits = 8,
read_timeout = 1000,
}

TTY = modbusrtu.new(port, SERIAL_OPTIONS)

if TTY then
return TTY, nil
else
return nil, 'rs485_init_issue'
end
end
end
end

function send_telemetry()
local telemetry = {}
local alerts = {}
local status = 'ok'

local connection, err = tty_init()
if err ~= nil then
status = 'read_error'
alerts = { err }
else
local data, result = connection:read_inputs(CONNECTION.address, 0, 1, CONNECTION.read_timeout)
if data then
telemetry['solar_irrad'] = uint16(data) / 10
else
enapter.log('Register 0 reading failed: ' .. result, 'error', true)
status = 'read_error'
alerts = { 'communication_failed' }
end

local data, result = connection:read_inputs(CONNECTION.address, 7, 1, CONNECTION.read_timeout)
if data then
telemetry['module_temp'] = int16(data) / 10
else
enapter.log('Register 7 reading failed: ' .. result, 'error', true)
status = 'read_error'
alerts = { 'communication_failed' }
end

local data, result = connection:read_inputs(CONNECTION.address, 8, 1, CONNECTION.read_timeout)
if data then
telemetry['ambient_temp'] = int16(data) / 10
else
enapter.log('Register 8 reading failed: ' .. result, 'error', true)
status = 'read_error'
alerts = { 'communication_failed' }
end
end

telemetry['alerts'] = alerts
telemetry['status'] = status

enapter.send_telemetry(telemetry)
end

function uint16(register)
local raw_str = string.pack('BB', register[1] & 0xFF, register[1] >> 8)
return string.unpack('I2', raw_str)
end

function int16(register)
local raw_str = string.pack('BB', register[1] & 0xFF, register[1] >> 8)
return string.unpack('i2', raw_str)
end

main()
138 changes: 138 additions & 0 deletions irradiance_sensors/imt_solar_si-rS485tc-2t_arrakis_mk4/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
blueprint_spec: device/1.0

display_name: IMT Solar Irradiance Sensor Si-RS485TC-2T
description: Irradiance sensor with ModBus RTU
icon: enapter-solar-panel
vendor: imt
author: enapter
contributors:
- anataty
- Rina-an
- nkrasko
support:
url: https://go.enapter.com/enapter-blueprint-support
email: [email protected]
license: MIT

communication_module:
product: ENP-VIRTUAL
lua:
file: firmware.lua
dependencies:
- enapter-ucm
allow_dev_dependencies: true

properties:
vendor:
type: string
display_name: Vendor
model:
type: string
display_name: Model

telemetry:
status:
display_name: Status
type: string
enum:
- ok
- warning
- read_error
solar_irrad:
display_name: Solar Irradiance
type: float
unit: W/m2
module_temp:
display_name: Module Temperature
type: float
unit: celsius
ambient_temp:
display_name: Ambient Temperature
type: float
unit: celsius

alerts:
no_model:
display_name: Device model is not set
description: Please set device's model via 'Configure' command
severity: info
cannot_read_config:
severity: error
display_name: Cannot Read Configuration
description: Cannot read configuration from flash storage. Check the logs.
not_configured:
severity: info
display_name: Modbus Connection Not Configured
description: Modbus connection not configured. Please set the correct settings using "Configure" command.
communication_failed:
display_name: Communication Failed
severity: error
rs485_init_issue:
severity: error
display_name: Cannot Initialize RS485 Port
description: Cannot initialize RS485 port. Check logs for details.

command_groups:
config:
display_name: Configuration

commands:
write_configuration:
display_name: Configure
group: config
populate_values_command: read_configuration
ui:
icon: file-document-edit-outline
arguments:
port:
display_name: Arrakis MK4 Serial Port
description: for example, ttyS0
type: string
enum:
- /dev/ttyS0
- /dev/ttyS1
required: true
address:
display_name: Modbus address
type: integer
required: true
baud_rate:
display_name: Modbus baudrate
type: integer
required: true
enum:
- 9600
- 19200
- 38400
- 57600
- 115200
parity:
display_name: Parity
type: string
required: true
enum:
- N
- O
- E
stop_bits:
display_name: Modbus stop bits
type: integer
required: true
enum:
- 1
- 2
read_configuration:
display_name: Read config Parameters
group: config
ui:
icon: file-check-outline

.cloud:
category: renewable_energy_sources
mobile_main_chart: solar_irrad
mobile_telemetry:
- solar_irrad
- module_temp
mobile_charts:
- solar_irrad
- module_temp

0 comments on commit b84b63e

Please sign in to comment.