Automatic Meter Reading
This example shows you how to use Communications System Toolbox™ to read utility meters by processing Standard Consumption Message (SCM) signals and Interval Data Message (IDM) signals which are emitted by the Encoder-Receiver-Transmitter (ERT) compatible meters. You can either use recorded data from a file, or receive signals in real time using the Communication Systems Toolbox Support Package for RTL-SDR Radio.
You can also learn about the Simulink® version of this example here.
Required Hardware and Software
To receive signals in real time, you need the following hardware:
- RTL-SDR radio
and the following software
For a full list of Communications System Toolbox supported SDR platforms, refer to the Supported Hardware section of the Software Defined Radio (SDR) discovery page.
Automatic Meter Reading (AMR) is a technology that autonomously collects the consumption and status data from utility meters (e.g., electric, gas, or water meters) and delivers the data to utility providers for billing or analysis purposes. The AMR system utilizes low power radio frequency (RF) communication to transmit meter readings to a remote receiver. The RF transmission properties include
- Transmission frequency within range: 910-920 MHz
- Data rate: 32768 bps
- On-off keyed Manchester coded signaling
The SCM and IDM are two types of the conventional message types that the meters send out. The SCM packets are used with a fixed length of 96 bits, whereas IDM packets are used with a fixed length of 92 bytes. The packet format of the SCM and IDM messages are shown below [ 1 ]:
Meters capable of sending both SCM and IDM messages transmit them on the same channel with separation of roughly 275 msec. Each meter transmits the SCM and IDM messages over multiple frequencies using a hopping pattern. However, the actual transmission frequencies, the frequency hopping pattern, and the time interval between transmissions are random to avoid interference from other transmissions.
Run the Example
To run the example, type AMRExample in the MATLAB Command Window or click the link. The example shows meter ID along with consumption information and commodity type in a MATLAB graphical display. It updates the display for each data capture and shows unique meter IDs with the latest consumption information.
The receiver initializes the example parameters. Then it calculates the AMR parameters and calls the signal source, physical layer, message parser, and data viewer in a loop. The processing loop keeps track of the radio time using the frame duration.
% Initialize Parameters initParam = helperAMRInit; % Calculate AMR system parameters based on the initialized parameters [amrParam, sigSrc] = helperAMRConfig(initParam); % Create the data viewer object viewer = helperAMRViewer('MeterID', initParam.MeterID, ... 'LogData', initParam.LogData, ... 'LogFilename', initParam.LogFilename, ... 'Fc', amrParam.CenterFrequency, ... 'SignalSourceType', initParam.SignalSourceType); start(viewer); radioTime = 0; % Initialize the radio time % Main Processing Loop while radioTime < initParam.Duration rcvdSignal = sigSrc(); amrBits = helperAMRRxPHY(rcvdSignal, amrParam); amrMessages = helperAMRMessageParser(amrBits, amrParam); update(viewer, amrMessages); radioTime = radioTime + amrParam.FrameDuration; end stop(viewer); % Stop the viewer release(sigSrc); % Release the signal source
Receiver Code Structure
The flow chart summarizes the receiver code structure. The processing has four main parts: Signal Source, Physical Layer, Message Parser and Data Viewer.
This example can use two signal sources:
- ''File'': Over-the-air signals written to a file and read using a Baseband File Reader object at 1.0 Msps
- ''RTL-SDR'': RTL-SDR radio at a sample rate of 1.0 Msps
If you choose ''RTL-SDR'' as the signal source, this example will search your computer for the RTL-SDR radio at radio address '0' and use it as the signal source.
The baseband samples received from the signal source are processed by the physical layer (PHY) to produce packets that contain the SCM or IDM information. The following diagram shows the physical layer receive processing.
The RTL-SDR radio is capable of using a sampling rate in the range of 225-300 kHz or 900-2560 kHz. This example uses a sampling rate of 1.0 Msps to give a sufficient number of samples per Manchester encoded data bit. The radio is tuned to a center frequency of 915 MHz which remains fixed for the whole duration. As the whole packet is transmitted on all hops, it is sufficient to monitor only one frequency. The frequency hopping allows for increased reliability over time.
The received complex samples are amplitude demodulated by extracting their magnitude. The on-off keyed Manchester coding implies the bit selection block includes clock recovery. This block outputs bit sequences (ignoring the idle times in the transmission) which are subsequently checked for the known preamble. If the preamble matches, the bit sequence is further decoded, otherwise, it is discarded and the next sequence is processed.
When the known SCM preamble is found for a bit sequence, the received message bits are decoded using a shortened (255,239) BCH code which can correct up to two bit errors. In the case where the known IDM preamble is found, the receiver performs a cyclic redundancy check (CRC) of the meter serial number and of the whole packet starting at the Packet type (the 5th byte) to determine if the packet is valid. Valid, corrected messages are passed onto the AMR message parser.
For a valid message, the bits are then parsed into the specific fields of the SCM or the IDM format.
The data viewer shows the decoded packets on a separate MATLAB figure. For each successfully decoded packet, the meter ID, commodity type, AMR packet type, consumption information and the capture time is shown. As data is captured and decoded, the application lists the information decoded from these messages in a tabular form. The table lists only the unique meter IDs with their latest consumption information.
You can also change the meter ID and start text file logging using the data viewer.
- Meter ID - Change the meter ID from 0, which is the default value and is reserved for displaying all detected meters, to a specific meter ID which you would like to be displayed.
- Log data to file - Save the decoded messages in a TXT file. You can use the saved data for post processing.
The data file accompanying the example has only one meter reading and has been captured at center frequency of 915 MHz. Using RTL-SDR radio, the example will display readings from multiple meters when it is run for a longer period in a residential neighborhood.
You can further explore AMR signals using the AMRExampleApp user interface. This app allows you to select the signal source and change the center frequency of the RTL-SDR radio. To launch the app, type AMRExampleApp in the MATLAB Command Window or click the link. This user interface is shown in the following figure
You can also explore the following functions for details of the physical layer, AMR message formats:
A version of the example that works with multiple radios is amrMultipleRadios.m. This allows you to examine the frequency hop patterns for a meter by setting different center frequencies per radio device available. The script is set for two radios, but can be extended for any number.
- Automatic meter reading, http://en.wikipedia.org/wiki/Encoder_receiver_transmitter, 2016.
- Itron Electricity meters, http://www.itron.com/na/industries/electricity, 2017.