8/26/2023 0 Comments Attiny88 wire libraryAnd sometimes there are “special chip functions” that perform some kind of post processing on those sensor readings that would be hard to replicate on the Arduino. I☬ chip-based sensors often have a dozen or more operational settings for things like bit-depth, sampling speed, noise reduction, etc., so you usually need to set bits in several different control registers before you can actually take a reading. Think of control registers as banks of On/Off switches, which you turn on by setting a bit to 1 and turn off by setting that bit to 0. Most sensors change how they operate based on the values stored in control registers. The functions named with the i2c_ prefix should be generic enough to work with most I☬ sensors, but I’ll also be referring to a few specific cases to show how you might need to modify those basic functions. There are many kinds of registers but for this introduction I am going to group them into three general types: Control, Data and Status registers, and provide brief examples of code that you can use to work with each of them. ![]() 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.Even if you’ve never worked with registers before, jrowberg’s visual grid layout makes it easy to see how the sensor’s memory is divided into sections, which are doing different things. 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. Note for ACS712 30A version: please do read the article about 30A version. 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. I suppose noise and reading fluctuations don’t impact readings how it happened for DC current. 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.Īlpha 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. The most difficult job was to get everything working in the 6KB memory of the ATTiny. Piece descriptionĬode 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. 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). ![]() I suggest to have a look at the original detailed article, this is a simple porting of that code. It has a very small memory usage and runs on both Arduino UNO and Digispark ATTiny (or compatible boards). This is the AC version of the program I published last year with that nifty alpha filter algorithm. Read AC current and transmit reading via 433MHz
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |