RI-D35 Energy Meter

../../../../../../_images/ri-d35.jpg

These are inexpensive and readily available MODBUS single-phase energy meters.

namespace RID35

Modbus/RID35/Request.h

Created on: 24 March 2022

Copyright 2022 mikee47 mike@sillyhouse.net

This file is part of the IOControl Library

This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 or later.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this library. If not, see https://www.gnu.org/licenses/.

Enums

enum class Unit

Values:

enumerator NONE
enumerator KW
enumerator KVAR
enumerator KVA
enumerator KWH
enumerator KVARH
enumerator KVAH
enumerator VOLT
enumerator AMP
enumerator HERTZ
enum class Register

Values:

enumerator XX
enumerator RID35_STDREG_MAP

Variables

constexpr uint16_t stdRegBase = 0x01
constexpr uint16_t ovfRegBase = 0x96
constexpr size_t stdRegCount = (1 + unsigned(Register::MaxDemandApparentPower)) * 2
constexpr size_t ovfRegCount = 1 + unsigned(Register::Kvah) - unsigned(Register::TotalKwh)
constexpr size_t registerCount = stdRegCount + ovfRegCount
class Device : public IO::Modbus::Device
#include <Device.h>

Public Functions

virtual IO::Request *createRequest() override

Create a request object for this device.

Return values:

Request* – Caller must destroy or submit the request

class Factory : public IO::RS485::Device::FactoryTemplate<Device>
#include <Device.h>

Public Functions

inline virtual const FlashString &deviceClass() const override

Return the Device class name, e.g. ‘r421a’.

class Request : public IO::Modbus::Request
#include <Request.h>

Public Functions

virtual void getJson(JsonObject json) const override

Get result of a completed request in JSON format.

virtual ErrorCode callback(PDU &pdu) override

Process a received PDU.

Parameters:

pdu

Return values:

ErrorCode – If request is re-submitted, return Error::pending, otherwise request will be completed with given error.