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.