Going With the Flow
Sometimes victory is hard-won. Other times it just requires patience and laziness.
Way back in 2016 I bought Adafruit's breakout board for the INA219 high-side current sensor so that I could play around with measuring current. Sure, I can do that with my multimeter, but with the actual sensor I can do it with an Arduino, and maybe build this in to a project.
You may have noticed that the way I've been talking about it indicates that I never finished any such project. Very astute. I'll continue.
I can't tell you exactly what I did wrong, but this wasn't my top priority so when it didn't work out, the project went on the shelf. I revisited it a couple of times over the years and I didn't get anywhere. Maybe I should dig up that code, because when I sat down this time, I saw there was an issue with the wiring. I had connected the INA219 SCL and SDA pins to pins B9 and B12 on the Espruino (Original) when I thought I had connected them to B8 and B9. B12 is not a I²C-capable pin, and besides, I was using B8 for the Nokia LCD.
I can't swear that that was the issue in the past since I may have pulled the board or some jumpers off of the solderless breadboard and put them back. But that was an issue when I picked the project back up and dusted it off yesterday evening.
However, I only discovered the miswiring because I got a very clear error message about B12 not being I²C-capable, and I only got that error message because in the time that this project was gathering dust on my unfinished projects pile, someone else wrote an Espruino module for the INA219.
This became quite an easy project, basically because someone else did the hard work. That's a little embarrassing but sometimes that's how a project shakes out. I was able to get it working in less than an hour using less than 50 lines of example code (found at Pico LCD Hello World and espruino.com's INA219 page.)
I apologize to anyone finding this article when looking for information about how to use the INA219. I don't have any information that isn't already easily available. It's just a proof that I can do something with this sensor. That's all I need right now. There are a number of projects that I can use this for, including making a better test platform for power supplies. Those will require actual effort.
It always feels good to succeed where I'd run into problems in the past. It's nice to take a job off of my to-be-done-someday list. I admit that it feels a bit like cheating to simply wait several years until someone else did the real work, but it's not like I'm saying that's a good plan. It's just nice that it actually worked out. Now I can get on with the business of actually designing something that uses this sensor.