Other Parts Discussed in Thread: ENERGIA, CC3200, MSP430WARE
Hi,
I am trying to interface VL6180x time of flight sensor with msp430g2553.
Its an I2C sensor, I have connected SCL and SDA of sensor to P1.6 and P1.7 of msp430 respectively.
I am using energia IDE, Wire library and Vl6180x pololu library for communication.
Above are the setup, but I am not getting data from sensor to msp.
I have used this same library in energia to interface and test with CC3200, it works good. So the sensor and library are ok.
Pullup resistors for I2C are placed in sensor board itself.
Below is my energia code, the code compiles and dumps into msp without any error.
#include <Wire.h> #include <VL6180X.h> VL6180X sensor; #define GLED P1_0///P2_2 #define RLED P2_1 void setup() { Serial.begin(115200); Wire.begin(); pinMode(GLED,OUTPUT); pinMode(RLED,OUTPUT); digitalWrite(GLED,LOW); digitalWrite(RLED,LOW); digitalWrite(GLED,HIGH); delay(1000); digitalWrite(GLED,LOW); sensor.init(); sensor.configureDefault(); // Reduce range max convergence time and ALS integration // time to 30 ms and 50 ms, respectively, to allow 10 Hz // operation (as suggested by Table 6 ("Interleaved mode // limits (10 Hz operation)") in the datasheet). sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30); sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50); sensor.setTimeout(500); // stop continuous mode if already active sensor.stopContinuous(); // in case stopContinuous() triggered a single-shot // measurement, wait for it to complete delay(300); // start interleaved continuous mode with period of 100 ms sensor.startInterleavedContinuous(100); } void loop() { Serial.print("Ambient: "); Serial.print(sensor.readAmbientContinuous()); if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.print("\tRange: "); Serial.print(sensor.readRangeContinuousMillimeters()); if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } if(sensor.readRangeContinuousMillimeters()>50){ digitalWrite(RLED,HIGH); digitalWrite(GLED,LOW); }else{ digitalWrite(RLED,LOW); digitalWrite(GLED,HIGH); } Serial.println(); }