Wasion Netvendor DDSD 101 Prepaid electricity meter replacement modem.

Avatar

sdg.john
2021-04-30 14:50
Last Edited 2022-08-26 15:56

Wasion Netvendor RS485 modem

The Wasion Netvendor meter is a prepaid meter that uses the RS485 communication protocol to connect to a modem which then enables internet access.


Mission statement:

We aim to develop a modem that functions with the Wasion Netvendor meter that can connect the meter to the pnpscada database for online billing. It should be cost-effective and simple to implement. Primarily, it should fit underneath the meter cover to look neat.


Method:

We would like to communicate with the meter through an orange pi lite based modem. Due to other issues, the orange pi lite loses connectivity to the PNPSCADA database, which prompted the design of a watchdog timer to hard reset the device at least once a day. In order for the modem to fit underneath the meter cover, we implemented a 'hat' design for the orange pi lite, which fits on top of the orange pi and connects to the GPIO pins.  

An Orange Pi Lite single board computer was selected to do the modem setup, and it will run on a Linux operating system, specifically, Armbian Buster.


Watchdog design:

Version 1

The watchdog was designed using basic analogue electronic components, to keep the cost to a minimum, and cancel out any required programming. Surface mount components made it possible for all components to fit on the orange pi hat, making for a compact and efficient design. A 555 timer was used as a clock source which was set to a period of approximately 6 minutes or 360 seconds. With 86400 seconds in a day, it would take 240 clock cycles to count an entire day. Two 4-bit counters were used to count the number of clock cycles that have elapsed. When the 240 clock cycles have been counted, the analogue system will trigger a normally closed relay that disconnects the power from the orange pi lite for a full clock cycle. By connecting the inputs of both 4-bit counters to ground, we initialize the counters to start counting at 0b0000. The figure below shows the analogue circuit that counts the clock cycles and activates the relay.


The figure below shows the circuit diagram for the 555 timer to implement a 6-minute clock source. The combination of resistors and capacitors has been experimentally determined to supply a clock source with a period of approximately 6 minutes.


To communicate with the Wasion Netvendor meter through the Orange Pi Lite, a serial TTL to RS485 converter circuit had to be designed and implemented, as the Wasion Netvendor meter communicates via RS485. The figure below shows the circuit diagram of the serial TTL to RS485 conversion circuit.


This concludes the hardware required to power and reset the Orange Pi Lite and enable communication with the meter. The figure below shows the surface mount populated PCB of the Hat used in version 1.


The figure below shows the fitment of the version 1 Hat on the Orange Pi Lite from above. Note how the debug port is still accessible.


The figure below shows the fully populated PCB used in version 1. A 240V 60Hz AC, to 5V 2A DC converter was chosen to be the power supply for the Hat, which was sourced from RS Components.


The figure below shows how the USB modem is mounted on the board. It is only attached with double-sided tape.



Version 2

For the updated version, a simpler hardware implementation was pursued, however, this solution required some programming knowledge. An ATTiny10 microprocessor was used to replace the watchdog portion of the version 1 board. The figure below shows the circuit diagram for the ATTiny10 implementation. The ATTiny10 essentially replaced all the analogue electronic components in version 1, i.e., the logic gate devices, the 4-bit counters, and the 555 timer clock source. The relay circuit was replaced by a MOSFET which can meet the current and voltage requirements.


Two feedback LEDs were added, one LED to indicate power from the power supply (RED), and one LED to indicate power to the Orange Pi Lite (GREEN). The MOSFET cuts off the ground connection to the Orange Pi Lite when it is activated, thus disconnecting the power supply to it. The two headers allow the user to switch the ATTiny10 from programming mode to operation mode.

ATTiny10 Programming and working

The programming of the ATTiny10 is fairly simple. The ATTiny10 receives an input from the Orange Pi Lite, which resets a counter when received, thus keeping the power connected to the Orange Pi Lite. This means that should the Orange Pi Lite freeze or become unresponsive, the ATTiny10 will initiate a countdown timer which can be dynamically set by the user. When the end of the countdown is reached, the ATTiny10 will disconnect the power supply to the Orange Pi Lite for several seconds, which can also be dynamically set by the user. This will ensure that the Orange Pi Lite will only restart when it's needed, and thus a better approach than presented in version 1 where it hard resets once a day, regardless of the state of the Orange Pi Lite.

The RS485 communication portion of the design shown in version 1, remained exactly the same.

The figure below shows the unpopulated board used in version 2. Note how much simpler the design is with fewer components. This should improve power consumption as well.


The figure below shows how the version 2 board fits onto the Orange Pi Lite. The debug port is still accessible like in version 1, but the fitment around the USB ports was improved.


The figure below shows the fully populated and operational board used in version 2. The aforementioned LEDs can be seen to be lit up. The Blue LED on the USB modem shows that the device is indeed connected to a network.



Meter cover fitment

The figure below shows how the complete modem assembly fits inside the meter cover. Both version 1 and version 2 fit the same, as the physical dimensions have not changed.



Firmware implementation:

Ser2net

Firstly, ser2net must be installed on the Orange Pi Lite. This can be done by entering the following in the command line:

apt-get install ser2net

The appropriate UART pins must be enabled to interface with the hardware design layout, in this case UART3. To enable the UART pins, enter the following in the command line:

armbian-config

When the interface is loaded, navigate to system as shown in the figure below.


Navigate to Hardware as shown in the figure below to access the hardware configurations.


Navigate to uart3, and press the space bar to toggle. Press enter to save the selected value, and exit through the prompts.


In the ser2net.conf file, we need to enable the serial to network interface on ttyS3. This can be done by entering the following in the command line:

nano /etc/ser2net.conf

and then adding the following to the bottom of the file:

10000:telnet:600:/dev/ttyS3:9600 8DATABITS NONE 1STOPBIT banner

The 10000 refers to the port 10000. Ser2net uses a default IP address to connect to, along with the port specified. IP: 127.0.0.1 port


TCPBridge program:

After this initial setup was done, a TCP Bridge program was written to establish a connection between the ser2net port used, and the pnpscada server, to enable remote meter reading. Ensure that the ports for ser2net match in the TCP Bridge program and in the ser2net.conf file.

To let this program execute on startup in the background, enter the following in the command line:

nano /etc/rc.local

Insert the following at the bottom of the file, before exit 0:

sudo java -cp ./root/ TCPToggleTest &

 

 Huawei E3131 USB modem:

USB Modeswitch

To setup the Huawei E3131 usb stick modem, insert and run lsusb in the command line to see as what device it is detected. (Modem/Networkcard is correct).


Run the following in the command line:

apt-get install usb-modeswitch

After successful installation, run the following in the command line (all one line):

sudo usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 1506 -M '55534243123456780000000000000011062000000100000000000000000000'

Run lsusb in the command line again to verify if it is correct.

 

Intall ppp

In the command line, run:

apt-get install ppp 

 

Install sakis3g

In the command line, run:

wget 'http://raspberry-at-home.com/files/sakis3g.tar.gz'

After successful download, run:

sudo cp sakis3g.tar.gz /usr/bin/

cd /usr/bin/

sudo tar -zxvf sakis3g.tar.gz

sudo chmod +x sakis3g

Create a sakis3g.conf file by running the following in the command line:

nano /etc/sakis3g.conf

 Insert the following in the file:

APN='CUSTOM_APN'

CUSTOM_APN='internet'

APN_USER=' '

APN_PASS=' '

OTHER='USBMODEM'

USBMODEM='12d1:1506'

USBINTERFACE='0'

 Run the following in the command line, inside the directory /usr/bin/:

./sakis3g --interactive

Choose -connect

            -custom tty

            - enter /dev/ttyUSB0

 

Install WiringPi

Enter the following in the command line to download WiringPi:

git clone https://github.com/zhaolei/WiringOP.git -b h3

Enter the following in the command line to install WiringPi:

cd WiringOP

chmod +x ./build

sudo ./build

WiringPi should now be installed and ready to implement the pin toggle script, to signal the ATTiny10 to stay alive.


The Wasion Netvendor meter should now be connected to the PNPSCADA database and be fully operational.


Tags: 555 timerattiny10orange pi liteorange pi modempnpscadars485 communication wasionwasion netvendor modemwatchdog
Please log in to post a comment