Attiny Over Serial Configuration

From lechacal
Jump to navigation Jump to search

Overview

RPICT board using Attiny microcontroller can be configured over serial using a utility written in python.

Current version allows changes of

  • Output format (csv or Emoncms)
  • Nodeid (emoncms only)
  • Polling (polling interval of data)
  • Ical (current calibration value)
  • Vcal (Voltage calibration value)
  • Vest (estimated voltage for power estimate)

Note this applies for boards RPICT3T1 RPICT4T4 RPICT3V1

It does not apply for boards RPICT3, RPICT7V1, RPICT8, RPICT4V3.

RPICT Configuration tool

The configuration tool can be downloaded directly from the raspberrypi:

$ wget lechacal.com/RPICT/tools/lcl-rpict-config.py.zip
$ unzip lcl-rpict-config.py.zip

Reading current configuration

Using the configurator without option only read the configuration stored in the board.

$ ./lcl-rpict-config.py

This yields

# RPICT Configuration Utility
# Read only
# Now reset RPICT hardware

Once the board has received the reset the configuration will be shown. How to reset the board

# 
# Configuration in memory:
# 
# Structure: 0xa0
# Format: 0
# NodeId: 11
# Polling: 5000
# ICAL: 83.330002
# VCAL: 560.000000
# VEST: 240.000000
#

Note. Every time the configuration is read from the board it stores a config file in /tmp/rpict.config.

Modify the configuration

To change the values the configurator must be fed with a file containing the new values. We will use the example of a RPICT3T1. Such file looks as below.

[main]
format = 0
nodeid = 11
polling = 5000
ical = 83.33
vcal = 560.0
vest = 240.0

We save this file in rpict3t1.conf. Then we can now start the configurator with the -w option.

$ ./lcl-rpict-config.py -w rpict3t1.conf

Once reset the configurator will read the old config then write the new config and display the newly stored one again.

# RPICT Configuration Utility
# Configuration will be overwritten (Ctrl C to cancel)
# Now reset RPICT hardware
# 
# Configuration in memory:
# 
# Structure: 0xa0
# Format: 0
# NodeId: 10
# Polling: 5000
# ICAL: 83.330002
# VCAL: 545.000000
# VEST: 240.000000
# 
# Writing configuration with file rpict3t1.conf
# 
# Configuration in memory:
# 
# Structure: 0xa0
# Format: 1
# NodeId: 11
# Polling: 5000
# ICAL: 83.330002
# VCAL: 560.000000
# VEST: 240.000000
#


The configuration file

The configuration file fed into the utlity must have the format below:

[main]
format = 0
nodeid = 11
polling = 5000
ical = 83.33
vcal = 560.0
vest = 240.0

format indicate which format output will be used. Must be an integer number.
0 - CSV
1 - Emoncms
2 - Emoncms as float (must have datatype f setup in emonhub config)

nodeid Only used in emoncms format. Will set the node id.

polling Number of milliseconds between each data to be sent to the raspberrypi.

ical Current calibration coefficient.

vcal Voltage calibration coeficient. Must be present even if not used (e.g RPICT3T1)

vest Voltage to compute estimated power. Usually 240V or 110V. Must be present even is not used. Set vest=1 to obtain output as ampere instead of watts. Set vest=1000 to get milliampere.

Restore Default Config

If things go wrong it is possible to reinstate default configuration as shown below.

Restoring the configuration will be necessary if you have just uploaded a new sketch.

RPICT3V1

$ wget lechacal.com/RPICT/config/A0/rpict3v1.conf
$ ./lcl-rpict-config.py -w rpict3v1.conf

RPICT3T1 & RPICT4T4

$ wget lechacal.com/RPICT/config/A0/rpict3t1.conf
$ ./lcl-rpict-config.py -w rpict3t1.conf

How to reset the board

Use a small jumper to link the reset pin with the ground. This can be found on the 3x2 6 pin ISP connector.

Make a very brief contact with the two pins then remove the jumper. This will reset the board.