My apologies for posting code incorrectly.
- Using Ameba RTL8195A board
- I2C communication with do sensor.
- Circuit: I2C_SCL connected to RX pin of sensor, I2C_SDA connected to TX. both through 4.7k resistor.
- Supplying 5v to Vcc from ameba board . common ground of sensor and board.
- I have run the code I2C_scanner code by ground fungus. and the result is as under:
Find the avaiable window
Baud:3; auto_length:0; Delay start:0; Delay end:63
[SPIF Err]SpicNVMCalStore: The flash memory(@0x9080 = 0x0) is not able to be write, Erase it first!!
===== Enter Image 1 ====
SPI calibration
Find the avaiable window
Baud:2; auto_length:21; Delay start:0; Delay end:63
[SPIF Err]SpicNVMCalStore: The flash memory(@0x90b0 = 0x0) is not able to be write, Erase it first!!
SDR Controller Init
Test 0: No match addr 0xc9d38 => 0xf != 0xc
Test 0: No match addr 0x1f7c10 => 0x5 != 0x2d6a0aaa
OTA addr 0x0 INVALID
load NEW fw 0
Flash Image2:Addr 0xb000, Len 27860, Load to SRAM 0x10006000
Image3 length: 0x2130, Image3 Addr: 0x30000000
Img2 Sign: RTKWin, InfaStart @ 0x10006049
===== Enter Image 2 ====
addr:1001D348 size:00052CB8
addr:30002130 size:001FDED0
I2C scanner. Scanning ...
Found address: 1 (0x1)
Found address: 2 (0x2)
Found address: 3 (0x3)
Found address: 4 (0x4)
Found address: 5 (0x5)
Found address: 6 (0x6)
Found address: 7 (0x7)
Found address: 8 (0x8)
Found address: 9 (0x9)
Found address: 10 (0xA)
Found address: 11 (0xB)
Found address: 12 (0xC)
Found address: 13 (0xD)
Found address: 14 (0xE)
Found address: 15 (0xF)
Found address: 16 (0x10)
Found address: 17 (0x11)
Found address: 18 (0x12)
Found address: 19 (0x13)
Found address: 20 (0x14)
Found address: 21 (0x15)
Found address: 22 (0x16)
Found address: 23 (0x17)
Found address: 24 (0x18)
Found address: 25 (0x19)
Found address: 26 (0x1A)
Found address: 27 (0x1B)
Found address: 28 (0x1C)
Found address: 29 (0x1D)
Found address: 30 (0x1E)
Found address: 31 (0x1F)
Found address: 32 (0x20)
Found address: 33 (0x21)
Found address: 34 (0x22)
Found address: 35 (0x23)
Found address: 36 (0x24)
Found address: 37 (0x25)
Found address: 38 (0x26)
Found address: 39 (0x27)
Found address: 40 (0x28)
Found address: 41 (0x29)
Found address: 42 (0x2A)
Found address: 43 (0x2B)
Found address: 44 (0x2C)
Found address: 45 (0x2D)
Found address: 46 (0x2E)
Found address: 47 (0x2F)
Found address: 48 (0x30)
Found address: 49 (0x31)
Found address: 50 (0x32)
Found address: 51 (0x33)
Found address: 52 (0x34)
Found address: 53 (0x35)
Found address: 54 (0x36)
Found address: 55 (0x37)
Found address: 56 (0x38)
Found address: 57 (0x39)
Found address: 58 (0x3A)
Found address: 59 (0x3B)
Found address: 60 (0x3C)
Found address: 61 (0x3D)
Found address: 62 (0x3E)
Found address: 63 (0x3F)
Found address: 64 (0x40)
Found address: 65 (0x41)
Found address: 66 (0x42)
Found address: 67 (0x43)
Found address: 68 (0x44)
Found address: 69 (0x45)
Found address: 70 (0x46)
Found address: 71 (0x47)
Found address: 72 (0x48)
Found address: 73 (0x49)
Found address: 74 (0x4A)
Found address: 75 (0x4B)
Found address: 76 (0x4C)
Found address: 77 (0x4D)
Found address: 78 (0x4E)
Found address: 79 (0x4F)
Found address: 80 (0x50)
Found address: 81 (0x51)
Found address: 82 (0x52)
Found address: 83 (0x53)
Found address: 84 (0x54)
Found address: 85 (0x55)
Found address: 86 (0x56)
Found address: 87 (0x57)
Found address: 88 (0x58)
Found address: 89 (0x59)
Found address: 90 (0x5A)
Found address: 91 (0x5B)
Found address: 92 (0x5C)
Found address: 93 (0x5D)
Found address: 94 (0x5E)
Found address: 95 (0x5F)
Found address: 96 (0x60)
Found address: 97 (0x61)
Found address: 98 (0x62)
Found address: 99 (0x63)
Found address: 100 (0x64)
Found address: 101 (0x65)
Found address: 102 (0x66)
Found address: 103 (0x67)
Found address: 104 (0x68)
Found address: 105 (0x69)
Found address: 106 (0x6A)
Found address: 107 (0x6B)
Found address: 108 (0x6C)
Found address: 109 (0x6D)
Found address: 110 (0x6E)
Found address: 111 (0x6F)
Found address: 112 (0x70)
Found address: 113 (0x71)
Found address: 114 (0x72)
Found address: 115 (0x73)
Found address: 116 (0x74)
Found address: 117 (0x75)
Found address: 118 (0x76)
Found address: 119 (0x77)
Done.
Found 119 device(s).
My code for reading dissolved oxygen is as under:
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}
char myChar = 'R';
int reading=0;
void loop() {
// step 1: instruct sensor to read echoes
Wire.beginTransmission(97); // transmit to device #97(0x70)
// the address specified in the datasheet is 224 (0xE0)
// but i2c adressing uses the high 7 bits so it's 97
Wire.write(myChar); // command sensor to measure in "inches" (0x50)
Wire.endTransmission(); // stop transmitting
delay(600);
// step 4: request reading from sensor
Wire.requestFrom(97, 6); // request 2 bytes from slave device #97
// step 5: receive reading from sensor
if (6 <= Wire.available()) { // if two bytes were received
reading = Wire.read(); // receive high byte (overwrites previous reading)
// reading = reading << 8; // shift high byte to be high 8 bits
reading |= Wire.read(); // receive low byte as lower 8 bits
Serial.println(reading); // print the reading
}
delay(250); // wait a bit since people have to read the output :)
}
I am getting error as:
requestFrom: readed=0, quantity=6 : ERROR
requestFrom: readed=0, quantity=6 : ERROR
A very humble request to please help me on this.
thanks a lot.