The com port of my Teensy disappears after working fine for about a minute

359 Views Asked by At

I have a simple BMP180 sensor breakout board communicating with my Teensy device through I2C. My sketch simply print out the values that it reads. When I open serial monitor (which only works half the time), it works fine for about a minute, but then suddenly cuts out. When I check the serial ports, the original COM port my teensy was on is no longer there. I've opened devmgmt and the port isn't there. I've tried rebooting my laptop, and also holding the reset button on the Teensy while re-plugging it in. No luck. Below is my code. Also, nothing shows up in the Arduino serial monitor, even when I thrown in an infinite loop printing stuff, but sublime's serial monitor does show it. Just thought that was weird too.

#include <MCP3221.h>
#include <Wire.h>
#include "SoftwareSerial.h"
#define ADDRESS 0x4D // 7 bits address is 0x4D, 8 bits is 0x9B
void setup() {
  Serial.begin(9600);
  Serial.println("First");

  Wire.begin(); //connects I2C
}
//fdsyjyutsydshgfjyfj
void loop() {
  byte ad_high;
  byte ad_low;
  int Result = 0;

  Wire.requestFrom(ADDRESS, 2);        //requests 2 bytes
  while(Wire.available() < 2)
  {
    Serial.println("not yet available");
  }
  Serial.println("Working");
  ad_high = Wire.receive();           
  ad_low = Wire.receive();
  Result = (ad_high * 256) + ad_low;

  Serial.println(Result);

  delay(10);

}

Seems like it's stuck on the while**

1

There are 1 best solutions below

0
On

You might have more luck using one of the BMP085 / BMP180 libraries, assuming you don't need to get at the really low level stuff. If you do you can always hack that code.

e.g. https://github.com/adafruit/Adafruit_BMP085_Unified -I've used this with that sensor with no problems.