kalheessi
Posts: 2
Joined: Thu Mar 26, 2015 2:36 pm

MCP3424 pi4j

Thu Mar 26, 2015 3:12 pm

hi

i'm using a MCP3424 ADC, in java with pi4j.
i don't know how tu use the library to get a value through the i2c bus.

can you please show me a java example code, that i can use to start coding my application.

thank you.

User avatar
clicky
Posts: 279
Joined: Thu Oct 25, 2012 7:34 am

Re: MCP3424 pi4j

Fri Mar 27, 2015 9:48 pm

Here's an example:
https://github.com/Pi4J/pi4j/blob/mast ... ample.java

Let me know if you get stuck anywhere...

kalheessi
Posts: 2
Joined: Thu Mar 26, 2015 2:36 pm

Re: MCP3424 pi4j

Tue Mar 31, 2015 8:09 am

hi
thank you for your example
but i don't understand how i can read a analogic value

Code: Select all

//import com.pi4j.io.gpio.GpioPinAnalogInput;
import com.pi4j.io.i2c.I2CBus;
//import com.pi4j.io.i2c.I2CDevice;
//import com.pi4j.io.i2c.I2CFactory;
import java.io.IOException;

public class MCP3424 {
    
    private I2CBus initDevice;
    private I2CBus device;
    
    public MCP3424 (I2CBus bus) throws IOException {
        initDevice = (I2CBus) bus.getDevice(0x69);
        device = (I2CBus) bus.getDevice(0x68);   
    }

    public float readValue(){
       // i would like to get the value here
}
}

Butch
Posts: 9
Joined: Thu Nov 29, 2012 6:18 pm

Re: MCP3424 pi4j

Tue Mar 31, 2015 11:57 am

You have to read the documentation of the chip. Usually you have to write a command to the device and than you can read the answer and write this to properties you can define in your MCP3424-Class.

ahmedawad
Posts: 42
Joined: Mon Apr 18, 2016 11:44 am
Location: Bremen, DE

Re: MCP3424 pi4j

Fri Jun 03, 2016 9:55 am

Hi,

have a look here, there exist what you are looking for
https://github.com/ahmedawad1/RaspberryPI_projects
specifically the MCP_test project.

regards

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: MCP3424 pi4j

Fri Jun 03, 2016 4:18 pm

There are a couple of MCP ADC chips implemented in the Pi4J-gpio-extension project including MCP 3004, 3008, 3204, 3208. I think these are SPI chips, but it may still provide a useful pattern especially if you ultimately want to contribute the MCP3424 back into the Pi4J project.

https://github.com/Pi4J/pi4j/tree/devel ... ension/mcp

Thanks, Robert
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

ahmedawad
Posts: 42
Joined: Mon Apr 18, 2016 11:44 am
Location: Bremen, DE

Re: MCP3424 pi4j

Sat Jun 04, 2016 9:51 am

Thanks Robert,

your projects are very useful actually, I learned a lot from them before. I got the MCP3424 from ABelectronics and all I found was just C-Libraries and Python. no support for java. I am using Pi4j also, that's why I tried to implement this project. It is the same routine as what is provided from ABelectronics https://github.com/abelectronicsuk/ABEl ... _Libraries

I understood how the MCP3424 works from the datasheet and at the end the difference was between the way of access to the I2c bus in C and in Pi4j.

regards
Ahmed

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: MCP3424 pi4j

Mon Jun 13, 2016 9:20 pm

FYI, contributor "Alexander Falkenstern" recently added a MCP3424 impl to the Pi4 project.

SEE: https://github.com/Pi4J/pi4j/commit/2c0 ... bcd976b069

Examples: This commit is included in the latest 1.1-SNAPSHOT build.

Cheers!
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Return to “Java”