Reading particle counting from DYLOS DC1100 data via ESP8266

Code and Cable

For Dylos DC1100 Pro with PC interface (a DB-9 female slot), on Windows, you could you to Dylos software to extract the data. That means you need to hook the Dylos monitor with a PC running Windows.

On Linux machine such as Raspberry Pi, a Python script can used to listen and capture data. Raspberry Pi is a litte Singer-on-Chip (SoC) computer that run on Debian-based Linux, called Raspbian. A other Linux-based flavors can be used as well. Check the full support software here.

Check the DIY COM cable to make sure it is functional. Connect to Raspberry Pi, enter the following commands

ls /dev/ttyUSB*

You should see something like this /tty/USB0

Check to data from the port like this cat /tty/USB0

If Dylos DC1100 is in continuous mode, you will see two numbers seperated by a comma by each minute. This is format is small,large numbers of particles

2.2 Log data directly from cable

Having an MQTT server (an always-on computer running MQTT software accepting messages from MQTT clients) is a better setup to work with multiple clients. It does require more technical know-hows to setup and run such system. Raspberry Pi could be used as MQTT server.

Alternatively, the data from Dylos can be logged directly to a Raspberry Pi and save as .csv format. The .csv file can be imported to a speadsheet software to proceed. Logging data directly from COM cable is appeal to run a few clients in proximity with data is logged in a simple format like csv.

Github code repository
# basic functions to log data directly to a csv file via USB cable
# full code is here https://github.com/binh-bk/rs232-dylos/blob/master/dylos_rpi.py
# optional to push data to MQTT server

push_mqtt = False
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=2)
head_ = 'sensor,time,small,large'
basedir = os.path.abspath(os.path.dirname(__file__))
logFile = os.path.join(basedir, 'dyloslog.csv')
while True:
    if ser.in_waiting > 0:
        line = ser.readline().decode('utf8')
        output = line.split(',')
        output = [x.strip() for x in output]
        small = output[0]
        large = output[-1]
        data = ','.join(['dylos', get_time(), small, large])
        
        with open(logFile, 'a+') as f:
            f.write(f'{data}\n')
        if push_MQTT:
            mesg = prepare_mesg(head_, data)
            push_MQTT(mesg)
            print(f'Pushed {mesg}')
    else:
        time.sleep(1)

The result of log file is similar to the one below.

logfile

Next, we will looking into using ESP8266 as an MQTT client