Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.34 KB

MobileAlertsSensorQRCode.markdown

File metadata and controls

48 lines (34 loc) · 1.34 KB

QR Code on the sensors

Every sensor has a QR Code printed on it, or in the box (for the small window sensors), it looks like this one:

QR Code

The encoding is different from the above example (which I quickly generated):

  • ECC Level L (Low Error Correction)
  • Mask Pattern 3
  • Encoding Format: 8-bit Byte (Because of the CR character)
  • Version 3: 29x29 Pixel

This allows 53 characters to be stored in the QR code, which works for the sensors.

The text contains three lines of ASCII text, with the lines separated by CR (ASCII 13):

  1. serial number of the sensor
  2. production date (day.month.year)
  3. product name or version number.

Here is a small sample code that generates the QR Code:

    #!/usr/bin/python

    import qrcode

    qr = qrcode.QRCode(
        version=3,
        error_correction=qrcode.constants.ERROR_CORRECT_L,
        box_size=10,
        border=4,
    )

    sensorID = '091234567890'           # [0-9A-F]{12}
    productionDate = '01.02.2015'       # "dd.MM.yyyy"
    productCode = 'MA10320/103300'

    qr.add_data('\r'.join([sensorID,productionDate,productCode]))
    #qr.add_data('0A1234567890\r01.01.2015\rMA10860')
    #qr.add_data('031234567890\r01.01.2015\rMA10200/10210')
    #qr.add_data('101234567890\r01.01.2015\rV05i')
    qr.make(fit=True)

    img = qr.make_image()
    img.save("qrcode.png","PNG")