Using Mega with Modern Devices Temp Sensor

I finally got my mega mostly working. It's part of the LiquidWare MegaPalm package. Had a problem with one of the keys on the button pad that was hanging me up. Anyway, programmed around that and have been testing some of the examples.

I also have the Modern Devices Temp Sensor. It's connected to analog pins 2-5. Pins 2 and 3 are supposed to be GND and 5V. They are configured through the LibTemperature. I checked the lib and they are set using digitalWrite on pins 16 and 17. I assume that somehow digitalWrites on pins 16 and 17 map to analog 2 and 3 but I don't know that for sure. I do know that power isn't actually showing up on those pins.

My GetLocalTemp application isn't working. It's hanging when it tries to get the I2C data. I checked the GND and 5V and they are not present. For some reason, the application isn't configuring these analog pins as GND and 5V output.

  1. Anyone have any idea why it's not being configured properly?

  2. Are digital 16 and 17 mapped to analog 2 and 3?

  3. The interface is 4 pins. But the board has 2 sets of 4 pins. It's not clear which set I should be using. Which set should be used? What's the difference?

Set 1: GND, Vin, SDI, SCL (I'm using this set)
Set 2: DXN, DXP, A1, A0

But without +5V, neither would work.

  1. Is there some difference with the Mega that is preventing the LibTemperature from being correct for the Mega board?

  2. If the LibTemperature was written for another board, is there any way to get analog2 to be GND and analog3 to be 5V? I have tried analogWrite(2,0) and analogWrite(3,255) but that didn't work. I'm stuck.

Not having GND and 5V on analog pins 2 and 3 would mean the Temp Sesor isn't powered and explains why my application isn't working. But I'm at a loss how to verify the LibTemperature, for the Mega?

This - very short - library uses WIRE

This library (i.e. wire) allows you to communicate with I2C / TWI devices. On most Arduino boards, SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5. On the Arduino Mega, SDA is digital pin 20 and SCL is 21.

The use of analog pins as + and - is a waste, explained by the simple mechanical layout.

Just change the pins in the templib.cpp as indicated above for the Mega ...

Well that sucks. :cry: I have the Mega Palm and the ButtonPad is hooked to those pins. I doubt if they use WIRE though, but they do use those pins. I could wire to different pins for power, but it looks like ButtonPad confilicts with use of the WIRE interface.

I was hoping to add a few sensors to the megapalm but it looks like that's not gonna happen. I might have to remove the button pad or use wires instead of pins.

I did remove buttonpad and connect to those 4 adjacent pins and it does work.

Thanks