aut viam inveniam aut faciam


I finally have some 'free' time :) so i upgraded a few things on the pi server but not without issues…

From jessie to stretch - network drive

For some reason the old command for mounting a network drive on the pi which worked on jessie did not work under stretch. I kept getting a host is down fault yet it was clearly not. The line i had in fstab before was;

// /media/nas_documents cifs credentials=/home/drakx/.nas_credentials,sec=ntlmv2,uid=1000,gid=1000,iocharset=utf8 0 0

trying combinations of this and even removing the credentials requirement still failed to mount. Eventually after much searching it appears that it is to do with nltm versions, the following worked;

sudo mount --verbose -t cifs -o sec=ntlm,username=****,password=****,vers=1.0 // /mnt/nas_files

but honestly i dont understand it and need to go away and investigate but for now the drive is mapped and i've other things to look at.

dragelec to python3

Dragelec is still alive and going strong, i've now added code to have all data put into an sql database and converted to python3 which had its own peculiarities…

sql code to create the database

    sqlite_file = '/mnt/usbkey/home_mon_db.sqlite'
    myfile = Path(sqlite_file)
    if myfile.is_file():
        # file exists
        print('file exists')
        tn = 'home_mon'
        # Connecting to the database file
        conn = sqlite3.connect(sqlite_file)
        c = conn.cursor()
        # create table
        c.execute('CREATE TABLE {tn} ({nf} {ft} PRIMARY KEY AUTOINCREMENT)'.format(tn='home_mon', nf='IDX', ft='INTEGER') )
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="DATE", ct='DATE'))
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="TIME", ct='TIME'))
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="EXTERNAL", ct='REAL'))
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="FRONTROOM", ct='REAL'))
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="BEDROOM", ct='REAL'))
        c.execute("ALTER TABLE {tn} ADD COLUMN '{cn}' {ct}".format(tn='home_mon', cn="KITCHEN", ct='REAL'))

sql code to write data in

        conn = sqlite3.connect(sqlite_file)
        c = conn.cursor()
        c.execute("INSERT INTO {tn}(DATE,TIME,EXTERNAL,FRONTROOM,BEDROOM,KITCHEN) VALUES(?,?,?,?,?,?)".format(tn='home_mon'), (d_now, t_now, sensordict.get('AC'), sensordict.get('AB'), sensordict.get('AE'), sensordict.get('AD')))

python3 decode 'b'

a change that caught me out was the change in how python handles incoming strings when read from the serial port previously i could simply read the incoming and assign direct to a dictionary or variable as python2 ignored the preceeding letter ie the received string looked like;


reading the python documentation;

A prefix of 'b' or 'B' is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3). A 'u' or 'b' prefix may be followed by an 'r' prefix.

So python2 ignored it but under python3 i need to decode it hence;

llapMsg= ser.read(n)

So dragelec is back up and running with a new sql backend and under python3 next jobs are to improve the decode routine to handle false inputs and of course extract data from the backend for display on the server site.

Recent posts


See more



aut viam inveniam aut faciam