Hi everyone,
(I asked for help in the previous topic, but no reaction, probably because of the solved state of that topic? So I place it in a new one!)
I tried to take a shot at this too. I've got a Netduino Plus 2 too( ), running NETMF4.2.
Borrowing your code I tried it like this:
public static void NetduinoForumsMethod2() { IC_BMP085 press; press = new IC_BMP085(0x77); while (true) { var logString = "pressure: " + press.pressure + " " + "altitude: " + press.altitude.ToString("F1") + " " + "free mem: " + Debug.GC(false); Debug.Print(DateTime.Now + ": " + logString); Thread.Sleep(3000); } }
In the code class provided, it now crashes on 2 places.
First in the CalculateTemperature method on following line:
x2 = mc * 2048 / (x1 + md); b5 = x1 + x2; temperature = (Single)((b5 + 8) >> 4) / 10;
This was caused by x1 + md being 0.
Trying to bypass I tried
if (x1 + md == 0) { temperature = 0; } else { x2 = mc * 2048 / (x1 + md); b5 = x1 + x2; temperature = (Single)((b5 + 8) >> 4) / 10; }
This made sure the calculateTemperature method was no longer crashing. But there was a new problem waiting.
Second time on the following line in the CalculatePressure method
p = (b7 < 0x80000000 ? (b7 * 2) / b4 : (b7 / b4) * 2);
This is caused again by a divided by zero exception, where b4 is 0.
Trying to bypass I tried following code:
if (b4 == 0) p = 0; //It kept crashing here, /0 doesn't work. else p = (b7 < 0x80000000 ? (b7 * 2) / b4 : (b7 / b4) * 2);
And now it is always returning 236
Only mind the white wires, the other ones are for my OneWire Temperature sensor. (More here)
- Sensor Pin VIn --> Netduino Pin 5V
- Sensor Pin GND --> Netduino Pin GND
- Sensor Pin SDA --> Netduino Pin SDA
- Sensor Pin SCL --> Netduino Pin SCL
But my sensor shows slightly different labels.
- Sensor VCC => NP2 5V
- Sensor GND => NP2 GND
- Sensor DA/SDA => NP2 SD
- Sensor CL/SCL => NP2 SC
Edited by Tobias Vandenbempt, 25 April 2014 - 07:19 AM.