I tried the example code for the mcp9808 and it works fine.
I would like to have two mcp9808.
My question is how do i properly syntax in code to address each mcp9808 and read the temperature from both?
**below is just an lcd example, i'm not asking about LCDs**
Just for an example when I use two LCDs with the backpack with I2C, I use the following:
LiquidCrystal lcd1(0);
LiquidCrystal lcd2(1);
then i can print to each lcd such as:
lcd1.print("some text");
lcd2.print("some other text");
mcp9808 I2C proper syntax addressing
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- sxrg
- Posts: 249
- Joined: Mon Dec 10, 2012 10:02 pm
Re: mcp9808 I2C proper syntax addressing
Let me add that I know that the default addressing is 0x18 and how to apply the addressing by connecting A0 and or A1 and A@ high with would change the addressing to 0x19 and so on.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: mcp9808 I2C proper syntax addressing
This is the code for the begin function: so you would add an address to the begin call in your code.
Code: Select all
boolean Adafruit_MCP9808::begin(uint8_t addr)
Code: Select all
mcp2.begin(0x19);
- sxrg
- Posts: 249
- Joined: Mon Dec 10, 2012 10:02 pm
Re: mcp9808 I2C proper syntax addressing
Thanks for the reply.
Using the example code for the mcp9808 I added your code:
This seems to work, i can see the two different temperatures.
But i kept getting errors when I tried to add:
Where is this placed?
Using the example code for the mcp9808 I added your code:
Code: Select all
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
Adafruit_MCP9808 mcp2 = Adafruit_MCP9808(); //your added code for the second mcp9808
void setup() {
tempsensor.begin();
mcp2.begin(0x19);
But i kept getting errors when I tried to add:
Code: Select all
boolean Adafruit_MCP9808::begin(uint8_t add)
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: mcp9808 I2C proper syntax addressing
That is the prototype in the .h file. You don't add that it was just to show you where the address went.Where is this placed?
- sxrg
- Posts: 249
- Joined: Mon Dec 10, 2012 10:02 pm
Re: mcp9808 I2C proper syntax addressing
Sorry for my ignorance..lol
But, Thank you very much. I appreciate it.
But, Thank you very much. I appreciate it.
Please be positive and constructive with your questions and comments.