Things used in this project

Hardware components:
Udooneo trasparent
UDOO NEO
×1
16GB MicroSD Card
×1
100A Single Phase Power Meter with Modbus RTU
×1
USB-RS485 Converter
×1
MicroUSB Supply
×1
Software apps and online services:
InfluxDB
Grafana

Code

Logging ScriptPython
import minimalmodbus as mb
import influxdb
import time
import struct
import threading
import datetime

time.sleep(30)
meter=mb.Instrument('/dev/ttyUSB0',1,mode='rtu')
meter.serial.baudrate=9600
meter.serial.timeout=0.1
db_client=influxdb.InfluxDBClient('localhost', database='dwelling')

def log_to_influx(meter, db_client):
    threading.Timer(1.0, log_to_influx, args=[meter, db_client]).start()
    try:
        reg_list=meter.read_registers(0,32, functioncode=4)
        v,i,w,va,var,pf = [struct.unpack('>f', struct.pack('>HH', *reg_list[a:a+2]))[0] for a in range(0,31,6)]
        reg_list=meter.read_registers(70,10,functioncode=4)
        hz,kwh_imp,kwh_exp,kvarh_imp,kvarh_exp = [struct.unpack('>f', struct.pack('>HH', *reg_list[a:a+2]))[0] for a in range(0,9,2)] 
        json_body = [
            {
                "measurement": "grid",
                "time": datetime.datetime.utcnow().isoformat()[:-7]+'Z',
                "fields": {
                    "V": v,
                    "I": i,
                    "W": w,
                    "VA": va,
                    "VAR": var,
                    "PF": pf,
                    "Hz": hz,
                }
            },
        ]
        db_client.write_points(json_body)
    except ValueError as e:
        print e
        meter.flushInput()
        meter.flushOutput()            
    finally:
        pass

log_to_influx(meter, db_client)

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

CarPC Android 
Intermediate
  • 23,574
  • 92

Android board computer for vehicles using UDOO

A powerful Maritime Instrument & Display Controller
Intermediate
  • 10,277
  • 55

Work in progress

A powerful Maritime Instrument & Display Controller, based on UDOO Neo, acting as a navigator, chart plotter, wireless NMEA multiplexer & ?

UDOO Ubuntu LTS Guide
Intermediate
  • 1,241
  • 23

Full instructions

Building a Ubuntu LTS configuration for the UDOO Quad

myva-Home (Voice controlled home automation)
Intermediate
  • 3,910
  • 40

Full instructions

My Voice Activated/Controlled Home, Using the Linkit Smart and an Android with easy to use examples and libraries

UDOO Neo Automated Hematoogy Laboratory Tubes Unscramble
Intermediate
  • 1,405
  • 11

Full instructions

A device that reads a bar code placed on the tube and, based on it, moving two step motors to place the tube in the correct position.

SATA on UDOO
Intermediate
  • 1,802
  • 15

Full instructions

Experiences and benchmarks with SATA drives on the UDOO.

Add projectSign up / Login