Project: GMC-320 Plus - Raspberry Pi

Forums:

Summary: Attempt to connect GQ GMC-320 Nuclear Radiation Detector to Raspberry Pi 3 for reading output.
2018Jan28: Though this is good at reading the serial port and can grab settings, reading data needs fixed.
See gmcDataLogger thread for a working reader solution for the GMC.

Purpose: Displaying radiation readings for smart-home
Technician: abitowhit

Standard RPI installations using raspian noobs. Set pw, hostname and install updates.

sudo apt-get updates
sudo apt-get upgrades

Finding USB
First begin by determining device ID of meter:
type: lsusb
Bus 001 Device 006: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 005: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard
Bus 001 Device 004: ID 046d:c408 Logitech, Inc. Marble Mouse (4-button)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Additional Details:
Type: dmesg | grep -i tty
[ 0.000000] Kernel command line: 8250.nr_uarts=0 bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[ 0.001194] console [tty1] enabled
[ 1.049584] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[ 4.042857] usb 1-1.4: ch341-uart converter now attached to ttyUSB0
[ 18.619344] Bluetooth: RFCOMM TTY layer initialized

Device Driver
Type: lsmod
Module Size Used by
fuse 99603 3
rfcomm 37723 6
bnep 12051 2
hci_uart 20020 1
btbcm 7916 1 hci_uart
bluetooth 365780 29 hci_uart,bnep,btbcm,rfcomm
evdev 12423 6
joydev 9988 0
brcmfmac 292632 0
brcmutil 9863 1 brcmfmac
cfg80211 544545 1 brcmfmac
rfkill 20851 6 bluetooth,cfg80211
snd_bcm2835 24427 2
snd_pcm 98501 2 snd_bcm2835
snd_timer 23968 1 snd_pcm
snd 70032 6 snd_timer,snd_bcm2835,snd_pcm
bcm2835_gpiomem 3940 0
fixed 3285 0
uio_pdrv_genirq 3923 0
uio 10204 1 uio_pdrv_genirq
ch341 6086 0
usbserial 29943 1 ch341
i2c_dev 6913 0
ip_tables 13161 0
x_tables 20578 1 ip_tables
ipv6 408900 49

Type: dmesg
USB registrations:
[ 0.152854] usbcore: registered new interface driver usbfs
[ 0.152955] usbcore: registered new interface driver hub
[ 0.153070] usbcore: registered new device driver usb

Loading into text viewer you can search on the device manufacture..
[ 2.941268] usb 1-1.4: new full-speed USB device number 6 using dwc_otg
[ 2.970957] i2c /dev entries driver
[ 3.074825] usb 1-1.4: New USB device found, idVendor=1a86, idProduct=7523
[ 3.074847] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 3.074857] usb 1-1.4: Product: USB2.0-Serial
[ 4.030663] usbcore: registered new interface driver usbserial
[ 4.030751] usbcore: registered new interface driver usbserial_generic
[ 4.030825] usbserial: USB Serial support registered for generic
[ 4.035115] usbcore: registered new interface driver ch341
[ 4.035212] usbserial: USB Serial support registered for ch341-uart
[ 4.035304] ch341 1-1.4:1.0: ch341-uart converter detected
[ 4.042857] usb 1-1.4: ch341-uart converter now attached to ttyUSB0
[ 11.764240] EXT4-fs (mmcblk0p7): re-mounted. Opts: (null)
[ 11.868259] systemd-journald[129]: Received request to flush runtime journal from PID 1
[ 12.249914] gpiomem-bcm2835 3f200000.gpiomem: Initialised: Registers at 0x3f200000
[ 12.533211] brcmfmac: F1 signature read @0x18000000=0x1541a9a6

type: ls /dev/
In the listings you should see ttyUSB0 in the list.

install python serial
http://pyserial.readthedocs.io/en/latest/shortintro.html
python3 pip install pyserial

Using miniterm.py to connect.
Go to the pyserial-3.4 location and open terminal window. Navigate to serial/tools.
type: python3 miniterm.py
This will open miniterm. Ctrl/T Ctrl/H for help on commands.
Set baud to 115200 to match GMC-320.
Type:Ctrl-T and type b.
At response type 115200.
You can type Ctrl-T then Ctrl-I to get current settings. Serial should be
Data bit: 8
Parity: None
Stop bit: 1
Control: None

Type: >
If you receive GMC-320Re 5.07 or similar, you have connected to the GMC.
GMC Commands (see gpmc commands comment to this thread for more or https://www.gqelectronicsllc.com/download/GQ-RFC1201.txt)
Paste commands into text editor for cut and paste.
NOTICE: If you use > you will need to cut and paste > to turn off heartbeat, you will not be able to type it in.
For some reason, though it says it is ASCII, some of the responses are coming back as control chars and not text.
Still working on this. I am assuming that the ASCII control in miniterm is uncorrect. Setting filter to debug displays code, but unmanageable.
CPM and the like are returned as unreadable chars. Even switching the encoding has no affect to get valid char outputs.
Minimally, I am talking with the device, but at this stage, though communicating, the returned values are not useable.
I will need to script.

abitowhit's picture

https://www.gqelectronicsllc.com/download/GQ-RFC1201.txt

***************************************************
GQ-RFC1201

GQ Geiger Counter Communication Protocol
***************************************************
Ver 1.40 Jan-2015

Status of this Memo

This document specifies a GQ GMC Geiger Counter Communication Protocol for the
communication between GQ GMC Geiger Counter and a computer host via serial port, and requests discussion and suggestions for
improvements. Distribution of this memo is unlimited.

Copyright Notice

Copyright (C) GQ Electronics LLC (2012). All Rights Reserved.

Abstract

This document defines a GQ GMC Geiger Counter Communication Protocol
to support communication between GMC Geiger Counter and a computer host via serial port. The protocol allows to send data request command from a computer host to a GQ GMC geiger counter.

**************************
Serial Port configuration
**************************

For the GMC-300 V3.xx and earlier version, the serial port communication is based on a fixed baud rate.

Baud: 57600
Data bit: 8
Parity: None
Stop bit: 1
Control: None

For the GMC-300 Plus V4.xx and later version firmware, 115200 BPS is used.

For GMC-320, the serial port communication baud rate is variable. It should be one of the followings:

1200,2400,4800,9600,14400,19200,28800,38400,57600,115200 BPS. The factory default is 115200 BPS.

**************************
Command format
**************************

A valid command start with ASCII '<' and ended with ASCII '>>'. Both command and parameters are in between '<' and '>>'.

Command is a ASCII string. All parameters of command are true value in hexadecimal.

Direction: All commands are initiated from computer(HOST).

**************************
Commands
**************************

1. Get hardware model and version

Command: >

Return: total 14 bytes ASCII chars from GQ GMC unit. It includes 7 bytes hardware model and 7 bytes firmware version.

e.g.: GMC-300Re 2.10

Firmware supported: GMC-280, GMC-300 Re.2.0x, Re.2.10 or later

2. Get current CPM value

Command: >

Return: A 16 bit unsigned integer is returned. In total 2 bytes data return from GQ GMC unit. The first byte is MSB byte data and second byte is LSB byte data.

e.g.: 00 1C the returned CPM is 28.

Firmware supported: GMC-280, GMC-300 Re.2.0x, Re.2.10 or later

3. Turn on the GQ GMC heartbeat

Note: This command enable the GQ GMC unit to send count per second data to host every second automatically.

Command: >

Return: A 16 bit unsigned integer is returned every second automatically. Each data package consist of 2 bytes data from GQ GMC unit. The first byte is MSB byte data and second byte is LSB byte data.

e.g.: 10 1C the returned 1 second count is 28. Only lowest 14 bits are used for the valid data bit. The highest bit 15 and bit 14 are reserved data bits.

Firmware supported: GMC-280, GMC-300 Re.2.10 or later

4. Turn off the GQ GMC heartbeat

Command: >

Return: None

Firmware supported: Re.2.10 or later

5. Get battery voltage status

Command: >

Return: one byte voltage value of battery (X 10V)

e.g.: return 62(hex) is 9.8V

Firmware supported: GMC-280, GMC-300 Re.2.0x, Re.2.10 or later

6. Request history data from internal flash memory

Command: >

A2,A1,A0 are three bytes address data, from MSB to LSB. The L1,L0 are the data length requested. L1 is high byte of 16 bit integer and L0 is low byte.

The length normally not exceed 4096 bytes in each request.

Return: The history data in raw byte array.

Comment: The minimum address is 0, and maximum address value is the size of the flash memory of the GQ GMC Geiger count. Check the user manual for particular model flash size.

Firmware supported: GMC-300 Re.2.0x, Re.2.10 or later

7. Get configuration data

Command: >

Return: The configuration data. Total 256 bytes will be returned.

Firmware supported: GMC-280, GMC-300 Re.2.10 or later

8. Erase all configuration data

Command: >

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.10 or later

9. Write configuration data

Command: >

A0 is the address and the D0 is the data byte(hex).

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.10 or later

10. send a key

Command: >

D0 is the key value from 0 to 3. It represents software key S1~S4.
Return: none

Firmware supported: GMC-280, GMC-300 Re.2.0x, Re.2.10 or later

Note: for Re.2.11 or later, each key can be a ASCII string: >,>,>,>

11. get serial number

Command: >

Return: serial number in 7 bytes.

Firmware supported: GMC-280, GMC-300 Re.2.11 or later

12. Power OFF

Command: >

Return: none

Firmware supported: GMC-280, GMC-300 Re.2.11 or later

13. Reload/Update/Refresh Configuration

Command: >

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.20 or later

14. Set realtime clock year

command: >

D0 is the year value in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

15. Set realtime clock month

command: >

D0 is the month value in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

16. Set realtime clock day

command: >

D0 is the day of the month value in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

17. Set realtime clock hour

command: >

D0 is the hourvalue in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

18. Set realtime clock minute

command: >

D0 is the minute value in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

19. Set realtime clock second

command: >

D0 is the second value in hexdecimal

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.2.23 or later

20. Reset unit to factory default

command: >

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.3.00 or later

21. Reboot unit

command: >

Return: None

Firmware supported: GMC-280, GMC-300 Re.3.00 or later

22. Set year date and time

command: >

Return: 0xAA

Firmware supported: GMC-280, GMC-300 Re.3.00 or later

23. Get year date and time

command: >

Return: Seven bytes data: YY MM DD HH MM SS 0xAA

Firmware supported: GMC-280, GMC-300 Re.3.00 or later

24. Get temperature

command: >

Return: Four bytes celsius degree data in hexdecimal: BYTE1,BYTE2,BYTE3,BYTE4
Here: BYTE1 is the integer part of the temperature.
BYTE2 is the decimal part of the temperature.
BYTE3 is the negative signe if it is not 0. If this byte is 0, the then current temperture is greater than 0, otherwise the temperature is below 0.
` BYTE4 always 0xAA

Firmware supported: GMC-320 Re.3.01 or later

25. Get gyroscope data

command: >

Return: Seven bytes gyroscope data in hexdecimal: BYTE1,BYTE2,BYTE3,BYTE4,BYTE5,BYTE6,BYTE7
Here: BYTE1,BYTE2 are the X position data in 16 bits value. The first byte is MSB byte data and second byte is LSB byte data.
BYTE3,BYTE4 are the Y position data in 16 bits value. The first byte is MSB byte data and second byte is LSB byte data.
BYTE5,BYTE6 are the Z position data in 16 bits value. The first byte is MSB byte data and second byte is LSB byte data.
BYTE7 always 0xAA

Firmware supported: GMC-320 Re.3.01 or later

26. Power ON

Command: >

Return: none

Firmware supported: GMC-280, GMC-300, GMC-320 Re.3.10 or later

-6.1193329,39.1580149,06-17-2019 10:53:35 AM,!Eating lunch