Write / Read to EEProm on IND.I/O D21G

I have try example sketch from :https://github.com/Industruino/democode/blob/master/i2c_eeprom_D21G/i2c_eeprom_D21G.ino

My result :
INDUSTRUINO D21G I2C EEPROM DEMO
================================

Writing a fixed byte value to all addresses at I2C address 0x50..
Reading from all addresses at I2C address 0x50..
addr: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 
val: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

Writing a LONG type number to address 10-13 (4 bytes) at I2C address 0x51:-987654321
Reading LONG type from I2C address 0x51: 0

Writing a FLOAT type number to address 252-255 (4 bytes) at I2C address 0x53:-123.456
Reading FLOAT type from I2C address 0x53: 0.000

END

Why there are only zeros ???

 

 

Janusz Imiołczyk
Janusz Imiołczyk
7
| 0 0 0
Asked on 10/10/17, 12:58 PM
0
vote
388 Views

Hi all,

I still have a problem with I2C_EEPROM read or write on a D21G V1.7 board.

I write 2 unsigned integers in bytes 0-1 an 2-3 of the first I2C_EEPROM adress during init (eeprom50). I then power off the controller (USB and main) and power it on again some seconds later. On init, I test what I get in these 4 bytes against what I wrote (or tried to, anyway) there before power-off, and it does not seem to match. All I get seems to be 4 in bytes 0-1 and 0 in bytes 2-3.

I tried reading these 4 bytes right after writing in them, and I still get 4 and 0. There should be values of 1121 an 1 in these pairs of bytes, in the form of unsigned integers.

I tried with a direct adaptation of the code in the example, and still no change.

I also tried to change from eeprom50 to eeprom51. Same result.

Any ideas ?

 

Didier DORGUIN
Didier DORGUIN
17
| 0 0 0
Answered on 11/9/17, 1:50 PM
0
vote

Hi Didier, i just tried this and cannot reproduce your error. For reference, here's an example in the same style as the demo sketch: union uint_2bytes { // define a union structure to convert uint into 2 bytes and back unsigned int ui; byte b[2]; }; SerialUSB.print("Reading UNSIGNED INT type from I2C address 0x51: "); union uint_2bytes union_uint_read; union_uint_read.b[0] = eeprom51.readByte(0); union_uint_read.b[1] = eeprom51.readByte(1); SerialUSB.println(union_uint_read.ui); // SerialUSB.println(); SerialUSB.print("Writing a UNSIGNED INT type number to address 0-1 (2 bytes) at I2C address 0x51:"); unsigned int uint_number = 1121; SerialUSB.println(uint_number); union uint_2bytes union_uint_write; // create a variable of this union type union_uint_write.ui = uint_number; // asign the value eeprom51.writeByte(0, union_uint_write.b[0]); delay(1); eeprom51.writeByte(1, union_uint_write.b[1]); delay(1000); SerialUSB.print("Reading UNSIGNED INT type from I2C address 0x51: "); union_uint_read.b[0] = eeprom51.readByte(0); union_uint_read.b[1] = eeprom51.readByte(1); SerialUSB.println(union_uint_read.ui); SerialUSB.println();

Tom
on 11/10/17, 12:05 AM

Got it right now. Works fine !

Didier DORGUIN
on 12/29/17, 2:20 PM

Hi Janusz,

We had an initial batch of D21G that shipped without this EEPROM chip, please check on your topboard whether is says version 1.6 or the current one, 1.7. If you have a 1.6 version, then contact us by email for a replacement.

Kind regards, Tom

Tom
Tom
5210
| 0 0 1
Answered on 10/11/17, 12:50 AM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

40 follower(s)

Stats

Asked: 10/10/17, 12:58 PM
Seen: 388 times
Last updated: 11/9/17, 1:50 PM