22 March 2022 By Julian Spina 2

ATTiny/Arduino UNO AC current measurements with ACS712

Read AC current and transmit reading via 433MHz

This is the AC version of the program I published last year with that nifty alpha filter algorithm. It has a very small memory usage and runs on both Arduino UNO and Digispark ATTiny (or compatible boards). I suggest to have a look at the original detailed article, this is a simple porting of that code.

These are the components needed, choose between a Digispark or an Arduino UNO R3 board (I always buy Arduino boards with the old big USB port, like the one on printers; it’s much more solid that micro/mini USB ports).

Piece descriptionLink to purchase
Digispark ATTiny85 board
https://s.click.aliexpress.com/e/_AsYcuj
Arduino UNO R3 board
https://s.click.aliexpress.com/e/_ATY4VN
FS1000A 433MHz
transmitter/receiver
https://s.click.aliexpress.com/e/_A1zzuP
ACS712 Module
https://s.click.aliexpress.com/e/_Aa6dWx

Code is very simple, it uses Virtual Wire library to manage the 433MHz transmission; this was the only library I managed to get working on both Arduino UNO R3 and Digispark ATTiny85. The most difficult job was to get everything working in the 6KB memory of the ATTiny.

If you want to do some console printing on ATTiny you can uncomment all the lines with DigiKeyboard; but you will have to also comment out the Virtual Wire code (all of it), otherwise 6KB wont be enough anymore.

Alpha filtering algorithm is here implemented as a single line of code, opposed to DC version where I applied it on a 1000 consecutive current readings. I suppose noise and reading fluctuations don’t impact readings how it happened for DC current. Plus, I compared readings from ACS712 to the one of the energy meter and I added some range-based adjustments, you’ll find an IF-chain in the code.

Code is attached at the end of the post.

Note for ACS712 30A version: please do read the article about 30A version. If you think you’ll be measuring currents over 10A you must remove the plastic connector on the ACS712 module and directly solder the wires to the board.

Here’s some photos of the first two boxes I made, both using ATTiny85… yes, I love the fact it’s small and requires nearly no current to run.

Preparing the pieces

Measurement for Mining Rig (1A)

Measuring at the house main panel

Source Code

Here’s the source code: http://electronic.acca3.it/wp-content/uploads/2022/03/ACS712-AC-version.zip

Enjoy!