Shop OBEX P1 Docs P2 Docs Learn Events
INA219 module and ... — Parallax Forums

INA219 module and ...

I was looking for something that could read current and voltage, and came across this module. Wondering if anybody has used this with, maybe a Propeller, using C code.

It seems like there is example code and a wiring diagram for a Raspberry Pi, but I wonder if this could be workable with the new P2, and of course the P1.

Thanks

Ray

Comments

  • kwinnkwinn Posts: 8,697
    It should work with P1 and P2. I have used 3 of them with P1 to monitor a 3 output power supply, and am planning to use it with P2 when my P2D2 board arrives.
  • I used that device in a commercial product (laser-tag controller). My code is, of course, Spin. That said, it's very simple and you should have no trouble converting it to C.
  • I passed on this module and instead went with INA260 which seems to be better at measuring current and voltage.

    I used the one from Adafruit.

    Wrote C code to drive it nicely.

    Mike
  • iseries mentioned the INA260 module, which I think will be more useful for my purposes. Still have not decided how I will code the program. And, at a minimal I will probably need, to start with, at least four of theses modules, which brings up the question of, how do I make the modules available on the I2C buss.

    I also looked at Jon's jm_ina219.spin program, I wonder how that would work with the flexGUI IDE. The last time I used the spintoc part of flexGUI, to convert some Spin code to PropGCC, I was not able to make the PropGCC code work correctly.

    I will probably be collecting the INA260 data, continuously, and feeding it to an SQLite database, for further analysis. These are just a few things that I have in mind.
  • JonnyMacJonnyMac Posts: 8,912
    edited 2019-11-11 20:32
    how do I make the modules available on the I2C buss.
    Both device types have A0 and A1 (address) inputs which allow up to for devices on the bus.
    I also looked at Jon's jm_ina219.spin program, I wonder how that would work with the flexGUI IDE. The last time I used the spintoc part of flexGUI, to convert some Spin code to PropGCC, I was not able to make the PropGCC code work correctly.
    My object will work if you write your code in Spin or in FlexC.

    I've attached a demo program that uses four of my Spin objects without modification/conversion -- one that launches a PASM cog (serial io). Interesting, the C binary image was a little bigger than the identical program written in Spin; this may have to do with overhead dealing with Spin objects in C. Still it works, so I can write C code without walking away from all of my existing objects. Spin is my favorite Propeller language, but it's nice to have C as an option.
  • yes, the multi-language feature of fastspin is a wonderful thing.

    Mike
  • yetiyeti Posts: 818
    edited 2019-11-12 05:05
    msrobots wrote: »
    yes, the multi-language feature of fastspin is a wonderful thing.
    https://forums.parallax.com/discussion/169141 has several examples of mixing FastSpin's languages and even one using FastSpin compiled cog PASM output in OpenWrt which turned out to be purely straight forward.
    What I don't see how to do so far: Including/using bytecode Spin in FastSpin LMM code and the other way round. But I dont expect much demand for this. :-)
  • I put my INA260 driver in the OBEX if you are interested in a C version of the driver.

    Mike
  • Thanks Jon, for the excellent examples. I will look into the code to see how your Spin objects work within a C or flexBASIC confine.

    Thanks iseries, for a pointer to your libina260 driver. I will also take a closer look at your SimpleIDE implementation for using the INA260.

    Now, I have to get a better understanding of the code that has been presented so far before I make a decision as to what I will be using. Will it be SimpleIDE, flexC, flexBASIC, micropython, or, …

    Another choice P2 Eval or FLiP module or ...
  • @iseries, I am starting to look into using some INA260 units from Adafruit. I looked at your zip, that is in the OBEX, and noticed a couple things.

    In the INA260 folder you have the file, libina260.c, this is really not a lib file, since it contains the main() function. The file, ina260.c, is the lib file, since it does not contain a main(), correct.

    The actual lib file, would that be placed in the Simple Library folder, and then added while in SimpleIDE?

    If, you were so kind, could you add a brief description as to what pins would be used, for instance, a FLiP module -> INA260 unit.

    I am going to replacing some of my voltage divider breakouts, using ADC, with the INA260 to get some more detailed information that the ADC method lacks.

    Thanks
    Ray
  • The way you build a library is you start a project in simpleide with lib as the first part of the name. The project file contains test code that is used to test the library. It does not become a part of the library but is just for building the library.

    Since all my code is put in a folder called "Custom" that would be where you put the zipped file into. So in the Learn/Simple Libraries you would add a folder call "Custom" and unzip the folder there.

    You can then use the SimpleIDE to open the project folder that has test code in it and will show a sample of how to use it. In addition there is an HTML folder with a file index.html that documents all the functions of this library.

    To use the library simple add it to your projects under project add simple library.

    Mike
  • Thanks Mike.

    I just downloaded your latest zip. In the html folder you have a file doc.png, I assume it is a photograph? For some reason my Win 10 Pro does not show the picture. I assume that is where you show what pins are connected to what pins.

    Once I get this to work with SimpleIDE I will probably try to get it to work with FlexGUI. I have not used FlexGUI in quite awhile, hopefully it will be able to handle the INA260 program.

    Ray
Sign In or Register to comment.