Please help me my I2C problem

hallo !
I want to use this program in the Photon.
http://ore-kb.net/wordpress/wp-content/uploads/2013/03/bitbang_ina226.zip
but,every time happen error code.

I change the following point .

#include "Wire.h"     ------    #include "application.h"

Please help me

Where did you get that code from?
What are you trying to do?
Which IDE are you using?
How are you including those files?
Where did you make the mentioned change?
What’s the actual error output?

1:This is code
https://raw.githubusercontent.com/burainokan/I2C-Power-meter/master/Power.ino
2:I make power generating meter(wind or solar)

https://strawberry-linux.com/catalog/items?code=12031

3:I use particle web IDE
4: the original arduino code wright " include “wire.h” "

You didn't answer the single most important question

And the prefered way is #include "Particle.h" instead of #include "application.h"
But in .ino files you'll not need it anyway so just removing #include "Wire.h" should suffice.

This is error’s

power.cpp:3:37: error: 'word' has not been declared
 static void writeRegister(byte reg, word value);
                                     ^
power.cpp:5:8: error: 'word' does not name a type
 static word readRegister(byte reg);
        ^
	
			power.cpp:7:7: error: 'word' does not name a type
 void setup();
       ^
	
			power.cpp:65:37: error: 'word' has not been declared
 #define INA226_CONF_AVG_256                     (5<<9)  // 256
                                     ^
	
		power.cpp: In function 'void setupRegister()':

			power.cpp:84:41: error: 'INA226_CAL_VALUE' was not declared in this scope
 {

	
		power.cpp: At global scope:

power.cpp:87:8: error: 'word' does not name a type
       | INA226_CONF_MODE_CONT_SHUNT_AND_BUS
        ^

			power.cpp:125:10: error: 'word' does not name a type
   { INA226_REG_MASK_ENABLE,         "Mask/Enable"               },
          ^

			power.cpp:128:25: error: 'REGS' was not declared in this scope
 };
                         ^

		power.cpp:4:29: note: in definition of macro 'NELEMS'
 static void setupRegister(void);
                             ^
			power.cpp:130:38: error: 'readRegister' was not declared in this scope
 static void dumpRegisters(void)
                                      ^
	
			power.cpp:135:25: error: 'REGS' was not declared in this scope
   static char  buf[64];
                         ^

		power.cpp:4:29: note: in definition of macro 'NELEMS'
 static void setupRegister(void);
                             ^
power.cpp: In function 'void loop()':

			power.cpp:158:63: error: 'readRegister' was not declared in this scope
 }
                                                               ^
make[1]: *** [../build/target/user/platform-6power.o] Error 1
make: *** [user] Error 2

    Error: Could not compile. Please review your code.

It seems as if word was not declared as a data type.
Hence

To declare an otherwise undeclated type, do this

typedef uint16_t word;

After that you should be able to use word as data type.

1 Like