Attiny Over Serial Configuration A2
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 Emonhub Emoncms)
- Nodeid (device ID)
- Polling (polling interval of data)
- Ical (current calibration value)
- Vcal (Voltage calibration value)
- Phasecal (Phase calibration)
- Vest (estimated voltage for power estimate)
Note this applies for boards RPICT3T1 RPICT4T4 RPICT3V1
It does not apply for boards RPICT3, RPICT7V1, RPICT8, RPICT4V3.
Older versions
Find the same page for older sketch version below.
Configuration over serial for sketch version 1.1.
Configuration over serial for sketch version 1.2 & 1.3.
RPICT Configuration tool
The configuration tool can be downloaded directly from the raspberrypi:
$ sudo apt-get install python3-serial
$ wget lechacal.com/RPICT/tools/lcl-rpict-config.py.zip $ unzip lcl-rpict-config.py.zip
$ sudo mv lcl-rpict-config.py /usr/local/bin/
Reading current configuration
Using the configurator without option only read the configuration stored in the board.
$ lcl-rpict-config.py -a
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: 0xa2 # Format: 3 # NodeId: 11 # Polling: 2000 # KCAL: 83.3300018311 1.0 1.0 83.3300018311 1.0 1.0 1.0 83.3300018311 # PHASECAL: 0 # VEST: 240.000000 # xpFREQ: 50 # Ncycle: 20 # debug: 0 #
The configuration is stored in the /tmp/rpict.config file when this is executed. We usually recommend to make a backup of this file.
Note. This above is for a RPICT3T1. If you have a different board the output might look different (in particular the order of numbers in the Kcal variable).
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 = 3 nodeid = 11 polling = 2000 kcal = 83.33 1. 1. 83.33 1. 1. 1. 83.33 phasecal = 0 vest = 240.00 xpFREQ = 50 Ncycle = 20 debug = 0
We save this file in my_rpict3t1.conf. Then we can now start the configurator with the -w option.
$ lcl-rpict-config.py -a -w my_rpict3t1.conf
Upon reset the configurator will display the old config then write the new config and display it.
# RPICT Configuration Utility # Configuration will be overwritten (Ctrl C to cancel) # Now reset RPICT hardware # # Configuration in memory: # # Structure: 0xa2 # Format: 3 # NodeId: 11 # Polling: 5000 # KCAL: 83.3300018311 1.0 1.0 83.3300018311 1.0 1.0 1.0 83.3300018311 # PHASECAL: 0 # VEST: 240.000000 # xpFREQ: 50 # Ncycle: 20 # debug: 0 # # Writing configuration with file A2/rpict3t1.conf # # Configuration in memory: # # Structure: 0xa2 # Format: 3 # NodeId: 11 # Polling: 2000 # KCAL: 83.3300018311 1.0 1.0 83.3300018311 1.0 1.0 1.0 83.3300018311 # PHASECAL: 0 # VEST: 240.000000 # xpFREQ: 50 # Ncycle: 20 # debug: 0 #
The configuration file
The configuration file fed into the utility must have the format below:
[main] format = 3 nodeid = 11 polling = 2000 kcal = 83.33 1. 1. 83.33 1. 1. 1. 83.33 phasecal = 0 vest = 240.00 xpFREQ = 50 Ncycle = 20 debug = 0
format indicate which format output will be used. Must be an integer number.
0 - CSV
1 - deprecated
2 - deprecated
3 - Emonhub (recommended)
nodeid Will set the node id. An identifier that will be prepended to the beginning of the data.
polling Number of milliseconds between each data to be sent to the raspberrypi.
kcal Calibration coefficient. ical or vcal values.
- rpctt3t1 ical1 ical2 ical3 are on position 1 4 8.
- rpict3v1 ical1 ical2 ical3 V1 are on position 1 2 3 8.
vest Voltage to compute estimated power. (appiles to rpict3t1/rpict4t4). Usually 240V or 110V. Set vest=1 to obtain output as ampere instead of watts. Set vest=1000 to get milliampere.
xpFREQ Expected frequency of the waveform to measure. Typically 50Hz or 60Hz depending where you are. This must be a whole integer.
Ncycle Number of cycle used to compute the RMS signal. A good value is normally 20.
debug Turn debug on/off. Set it to 0 or 1. If on debug will make the output displaying more information about the reading. In particular which smallest polling can be achieved.
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/A2/rpict3v1.conf $ lcl-rpict-config.py -w rpict3v1.conf
RPICT3T1 & RPICT4T4
$ wget lechacal.com/RPICT/config/A2/rpict3t1.conf $ lcl-rpict-config.py -w rpict3t1.conf
RPICT4V3 version 1
$ wget lechacal.com/RPICT/config/A2/rpict4v3.conf $ lcl-rpict-config.py -w rpict4v3.conf
How to reset the board
Auto reset
Newest board now have the auto reset feature. To enable it just use the -a option with the lcl-rpict-config.py command.
lcl-rpict-config.py -a
or
lcl-rpict-config.py -a -w myfile.conf
Physical reset
Press the white button.
Older versions without white button
Early versions of the RPICT did not have any white button for reset.
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 brief contact with the two pins then remove the jumper. This will reset the board.
KCAL format
Each entry represent the calibration coefficient for the given port. The '1.' are just place holder and have no effect if modified.
RPICT3T1
kcal = ct1 1. 1. ct2 1. 1. 1. ct3
example:
kcal = 83.33 1. 1. 83.33 1. 1. 1. 83.33
RPICT3V1
kcal = ct1 ct2 ct3 1. 1. 1. 1. v1
example:
kcal = 83.33 83.33 83.33 1. 1. 1. 1. 545.0