Table of Contents

Android application: Power monitor for Atorch

Power monitor for Atorch Welcome to my power monitor application for Atorch power meters! This app allows users to track and monitor their power usage in real-time, helping them to save energy and reduce their carbon footprint. With this app, users can view detailed statistics on their energy consumption. Whether you're looking to save money on your energy bills or simply want to be more energy-efficient, this app is the perfect tool for you.

Supported for Atorch UD18 UD24 DT24 and similar USB or S1-B mains power meters, that share the same BLE Serial protocol

VersionDevelopmentLanguagePlatformScreenshots
1.15In-ProgressJavaScript Android: Droidscript, Framework7

Source is available on GitHub repository

BLE Serial Protocol

Commands for UD18 UD24

CommandBytes
WH resetFF 55 11 03 01 00 00 00 00 51
AH resetFF 55 11 03 02 00 00 00 00 52
TIME resetFF 55 11 03 03 00 00 00 00 53
ALL resetFF 55 11 03 05 00 00 00 00 5d
SETUP ButtonFF 55 11 03 31 00 00 00 00 01
ENTER ButtonFF 55 11 03 32 00 00 00 00 02
[+] ButtonFF 55 11 03 33 00 00 00 00 03
[-] ButtonFF 55 11 03 34 00 00 00 00 0C

Commands for S1-B

CommandBytes
WH resetFF 55 11 03 01 00 00 00 00 51
Internal relayFF 55 11 03 02 00 00 00 00 52
TIME resetFF 55 11 03 03 00 00 00 00 53

Data from devices UD18 UD24 and S1B

Bit decUD18/24S1B
1FF
255
3msg type: 0x01- data, 0x11- command, 0x02- ACK
4device type: 0x03- usb0x01- mains
5VV
6VV
7V, INT24 / 100V, INT24 / 10
8II
9II
10I, INT24I, INT24 / 10
11mAhW
12mAhW
13mAh, INT24W, INT24/10
14WhkWh
15WhkWh
16WhkWh
17Wh INT32, /100kWh INT32, /100
18D-Price
19D-, INT16, /100Price
20D+Price INT24, /100
21D+, INT16, /100Frequency
22 Frequency INT16, /10
23Temperature ºC BYTEPower Factor
24 Power Factor INT16, /1000
25Hour BYTE
26Minute BYTETemperature ºC BYTE
27Second BYTEHours
28 Hours INT16
29 Minutes BYTE
30 Seconds BYTE
31
32
33
34
35
36CRC

Checksum calculation

Using AI capabilities as was able to identify CRC for USB meter (device type 0x03) It works for device that i own.

FUNCTION verifyUSB(message: STRING) -> BOOLEAN
    # Convert hex string to byte array
    bytes = HEX_TO_BYTES(message)
    
    # Payload = bytes from index 2 to second-to-last
    payload = bytes[2 : LENGTH(bytes) - 1]
    
    # Accumulator: sum all payload bytes, keep only lowest 8 bits
    acc = 0
    FOR EACH byte IN payload:
        acc = (acc + byte) AND 0xFF
    
    # XOR accumulator with 0x44 to get expected checksum
    expected = acc XOR 0x44
    
    # Compare with last byte of message
    RETURN expected EQUALS bytes[LENGTH(bytes) - 1]
END FUNCTION

or as one liner

checksum = (SUM(bytes[2:-1]) AND 0xFF) XOR 0x44

I'm working on Javascript based environment and this code works for me for USB based device

function verifyChecksumUsb(message) {
  const bytes = new Uint8Array(message.length / 2);
  for (let i = 0; i < message.length; i += 2) {
    bytes[i / 2] = parseInt(message.substr(i, 2), 16);
  }
  const payload = bytes.slice(2, -1);
  const sum = payload.reduce((acc, v) => (acc + v) & 0xFF, 0);
  const checksum = (sum ^ 0x44) & 0xFF;
  return checksum === bytes[bytes.length - 1];
}
 
const msg = 'FF550103000383000080004EBA000027D7004B0147001F003312111E0000000000000072'
console.log('Checksum for '+ msg +' is ' + verifyChecksumUsb(msg))
// Checksum for FF550103000383000080004EBA000027D7004B0147001F003312111E0000000000000072 is true

Downloads

PowerMon version 1.10

Permissions note

Storage- to save configuration file on your device, save persistence of measurements.

Location- On older versions of Android (specifically Android 6.0 Marshmallow through Android 11), location services must be enabled to access Bluetooth Low Energy (BLE) devices because BLE scanning can be used to determine the physical location of the device. My app does not collect location, does not store it or process in any way. Its used just for connecting to BLE

.

Changes

Version 1.10

CORS fixes
More error checking in case something goes wrong
Logging functionality

Full changelog