The simulated EEPROM sketches that come with Nano Matter documentation in
Arduino IDE don't work.
Tried adding a 24LC256 as 2nd I2E device to my circuit, and using
SparkFun_External_EEPROM.h. NM recognizes it and seems to communicate, put
put/get 7.35 returns nan, overwriting the float target.
Next tried another NM with nothing but the 24LC256 connected to it, running
Example 1 that comes with the SparkFun library. put/get of byte 200 works, but
put/get of -355 returns -1, 7.35 returns nan, and the character string doesn't
work at all.
Looks like another library/microprocessor incompatibilty.
Help! Is there an EEPROM library that supports put/get for floating point
values and works with Nano Matter? And because I am new to Nano, hopefully one
as easy to understand and (try to) use as the SparkFun library.
Can you post an annotated schematic showing exactly how you wired this. I can think of several possible problems but I do not have the time to post all of them. Be sure to show all hardware connected including capacitors, resistors, diodes, etc.
Photo of minimal test circuit attached. 24LC256 faces right.
SCL blue A5 to pin 6
SCA yellow A4 to pin 5
Address pins 1, 2, 3 and write protect pin 7 to Gnd
Powered by 5v pin on Nano
Pull-up resistors 5.1k
Ran Example 1 sketch that came with SparkFun library.
Photo of output also attached.
My actual circuit is much larger with a second I2C device (SparkFun MCP4725 breakout) which works fine with or without the EEPROM attached. EEPROM is recognized and appears to communicate but responds nan as with the simple circuit whether-or-not the other device is attached.
EEPROMTyped.h appears to work with Nano Matter connected to 24LC256, at least the Example sketch runs A-OK.
EEPROMTyped.write and EEPROMTyped.read are equivalent to “put” and “get” with other libraries with all variable types tested in the Example. Also easy to efficiently assign memory addresses in EEPROM.
Only one capability seems to be missing: No way to assign I2C address of the EEPROM itself, which is useful or essential when using another I2C part along with the EEPROM. Wiring A0, A1, and A2 to Gnd works, suggesting that the default is address is 000. Would be nice to at least change it to 001 !
I tried I2C_EEPROM.h and got it working with Nano Matter. I was reluctant to try it before because, even with many years experience with Fortran, I am new to C and C++, and it took me awhile to figure out how the pointers work. (In Fortran pointers actually point => !)
However, your I2C_EEPRO_struct.ino Example would not run until I stripped it down to bare essentially without the timing code. This may be a problem specific to Nano Matter.
A Newbie question: Is the Arduino compiler written to compile C or C++ ? I bought Bjarne Stroustrup’s C++ text and found it terrifying. Would I be missing much if I bought a C text and relied on it ?
However, this is not anything like compiling, and the preprocessed code is then handed over to GCC.
As for your question. After sketch preprocessing, the code from the .ino files is compiled as C++. Likewise, files with a .cpp file extension are compiled as C++ (without any sketch preprocessing at all). Files with a .c file extension are compiled as C (again without sketch preprocessing).
So, if you wanted to, you can write your sketch programs in C and compile them as such. However, note that C++ is a superset of C. So you can also write C code in the .ino file, even though it will be compiled by a C++ compiler.
I think the best approach is to write your code in a more simple C-ish manner, but also take advantage of the useful additional capabilities of C++ as you find the need for them. Don't get overwhelmed by trying to understand the myriad of complex C++ features off the bat. This is actually the approach taken in a lot of code in the Arduino ecosystem, and in the field of embedded systems in general.
If you are using the code provided by the Arduino core or Arduino libraries, you are going to end up using some C++ regardless. So this is a good reason for putting your code in the .ino files of the sketch (or .cpp files if you like), even if you don't have any intention of intentionally using C++ features in your code. For example:
Serial.println("Hello, world!");
Serial is an instance of a C++ class:
You don't actually need to understand C++ classes or implement classes in your code if you don't like, but you can still make use of what is provided by the C++ code written by others.