Skip to main content

Nextion display serial client

Project description

Nextion serial client

Lightweight Python 3.5+ async library to control Nextion displays.

Simple usage:

import asyncio
import logging
import random

from nextion import Nextion, EventType

def event_handler(type_, data):
    if type_ == EventType.STARTUP:
        print('We have booted up!')

    logging.info('Event %s data: %s' % type, str(data))

async def run():
    client = Nextion('/dev/ttyS1', 9600, event_handler)
    await client.connect()

    # await client.sleep(True)

    # await client.command('sendxy=0')

    print(await client.get('sleep'))
    print(await client.get('field1.txt'))

    await client.set('field1.txt', "%.1f" % (random.randint(0, 1000) / 10))
    await client.set('field2.txt', "%.1f" % (random.randint(0, 1000) / 10))
    
    await client.set('field3.txt', random.randint(0, 100))

    print('finished')

if __name__ == '__main__':
    logging.basicConfig(
        format='%(asctime)s - %(levelname)s - %(message)s',
        level=logging.DEBUG,
        handlers=[
            logging.StreamHandler()
        ])
    loop = asyncio.get_event_loop()
    asyncio.ensure_future(run())
    loop.run_forever()

Additional resources:

https://www.itead.cc/wiki/Nextion_Instruction_Set

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextion-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file nextion-1.0.0.tar.gz.

File metadata

  • Download URL: nextion-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.7

File hashes

Hashes for nextion-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0357df52777b1fa88aad797045c793fb9a7b27952e7ab48157915c3afb6150cb
MD5 4a2419b86a78b3bf34c92e8eeb06308c
BLAKE2b-256 a8ca4d360447fd71d5f6b51d902a27810eb6940bb80200f890c2f3ce51966051

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page