1

I am trying to get values from this sensor Airspeed v3 from eagle tree but it seems my I2C is not working properly.

I bought a module in third party mode and followed these instructions from the manufacturer website.

I went to rcgroups forum and discovered the right values for the bits mentioned in the documentation about WRITE and READ.

I started the development of a code but I cannot get the values from the sensor. It is supposed to send me a 2 byte-formatted value indicating the airspeed measured. But surprisingly when I call this method Wire.requestFrom(AIRSPEED_ADDRESS, 2) it returns 0, so someway the communication is not working. I have used I2C before for ADXL345 sensor and it works perfectly.

The results from these lines

Serial.println(data[0]); 
Serial.println(data[1]);

are just -1 indicating that no data is available to display.

Does anybody know how to get this working? Am I missing something?

This is my code right now.

#include <Wire.h>
#define AIRSPEED_ADDRESS 0xEA
#define WRITE_BIT 0x00
#define READ_BIT 0x01
void setup() {
 // join I2C bus (I2Cdev library doesn't do this automatically)
 Wire.begin();
 Serial.begin(9600);
 Serial.println("Program started");
}
void loop() {
 byte data[2] = {0};
 int i = 0;
 int16_t velocidade = 0;
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 if (!Wire.write(WRITE_BIT)) {
 Serial.println("error sending write_bit");
 }
 Wire.endTransmission();
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 if (!Wire.write(0x07)) {
 Serial.println("error sending 0x07");
 }
 Wire.endTransmission(false);
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 if (!Wire.write(READ_BIT)) {
 Serial.println("error sending read_bit");
 }
 else {
 //Serial.println("ok sending read_bit");
 } 
 Wire.endTransmission();
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 Serial.print("bytes read from slave: ");
 Serial.println( Wire.requestFrom(AIRSPEED_ADDRESS, 2) );
 data[0] = Wire.read();
 data[1] = Wire.read();
 Wire.endTransmission(); 
 velocidade = data[1] | (data[0] << 8);
 Serial.println(data[0]); 
 Serial.println(data[1]); 
 Serial.println(" "); 
}
asked May 13, 2015 at 3:43
1
  • This is really helpful. Thank you very much! Commented Sep 27, 2018 at 0:20

2 Answers 2

2

I found the I2C address on my Eagletree Airspeed V3 sensor to be 0x75 NOT 0xEA.

the following code adapted from first sample above works on my Nano:

/*
 * note that timming is critical - see delay (5)
 * and bps set to 115200
 * works ok, but clean up 5-19-2019 jaf
 */
#include <Wire.h>
#define AIRSPEED_ADDRESS 0x75
#define WRITE_BIT 0x00
#define READ_BIT 0x01
void setup() {
 Wire.begin();
 Serial.begin(115200);
 Serial.println("Program started");
}
void loop() {
 byte data[2] = {0};
 int i = 0;
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 Wire.write(WRITE_BIT); 
 Wire.endTransmission();
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 Wire.write(0x07); 
 Wire.endTransmission();
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 Wire.write(READ_BIT); 
 Wire.endTransmission();
 Wire.beginTransmission(AIRSPEED_ADDRESS); 
 Wire.requestFrom(AIRSPEED_ADDRESS, 2);
 data[0] = Wire.read();
 Wire.endTransmission();
 Serial.println(data[0]); 
 delay(5);
}
answered May 20, 2019 at 12:24
1

That's interesting but after using a different library the code worked out.

It has to follow exactly what the datasheet says in order to get things done.

The following source code makes it and get the airspeed from the sensor:

#define SENSOR_ADDRESS 0xEA 
#include <Wire.h> 
#include <I2cMaster.h> 
TwiMaster AIRSPEED_SENSOR(true); 
void setup() { 
 Serial.begin(9600); 
}
long airspeed_update(void) { 
 static struct { 
 union { int16_t val; uint8_t raw[2]; 
 } airspeed16; 
 } airspeedv3; 
 long airsp; 
 if(AIRSPEED_SENSOR.start(SENSOR_ADDRESS | I2C_WRITE)) { 
 delay(10); 
 AIRSPEED_SENSOR.write(0x07); 
 delay(10); 
 AIRSPEED_SENSOR.stop(); 
 } 
 if(AIRSPEED_SENSOR.restart(SENSOR_ADDRESS | I2C_READ)) { 
 delay(10); 
 airspeedv3.airspeed16.raw[0]=AIRSPEED_SENSOR.read(false); 
 delay(10); 
 airspeedv3.airspeed16.raw[1]=AIRSPEED_SENSOR.read(true); 
 delay(10); 
 AIRSPEED_SENSOR.stop();
 } 
 airsp=airspeedv3.airspeed16.val; 
 return airsp; 
}
void loop() { 
 int airspeed = airspeed_update(); Serial.println(airspeed); 
 delay(50);
}

Get this library from here.

answered May 14, 2015 at 0:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.