Flummoxed

Status
Not open for further replies.

Constantin

Well-known member
Not a unusual condition for me, but one that I wonder if any can help me with.

I have recently begun to 'libraries' my efforts since the Arduino IDE is somewhat impossible to work with once a program reaches a certain limit. I decided to start with my time work, since there are relatively few routines, variables, and so on. In other words, a good project to start learning libraries with.

However, I am running into one problem: How to let one library use another library to get a temperature measurement. For example, the sensiron library is initiated with

#include <Wire.h> //I2C Communications
#include <LibHumidity.h> //Temperature and Humidity Library for SHT-21 sensors
LibHumidity SHT21 = LibHumidity(0); // Initiate Temperature and Humidity Library Functions

I'd love to be able to use Libhumidity functions such as SHT21.GetTemperatureC() from within my time libraries. However, so far I've only done a great job of messing this up. See http://playground.arduino.cc/code/Sensirion for more info about the Sensiron humidity/temperature library.

I suppose an option is to simply import everything associated with getting a temperature from the Libhumidity library and calling it a day, but I'd like to keep the two separate, if possible.
 
I suspect what you are seeing is that the constructor to set up the SHT21 variable is being run before the LibHumidity constructors are run and they have all 0's or worse, random data in the fields. You might want to try having an explicit begin method, that does the initial work to initiate the functions, and just use the static constructor to allocate space, and indicate begin has not been called.
 
I have recently begun to 'libraries' my efforts since the Arduino IDE is somewhat impossible to work with once a program reaches a certain limit.

IMHO the Arduino IDE is a PITA to work with when developing libraries. That's why I've changed a good while ago to work with the Arduino Eclipse IDE and have not looked back. The way Eclipse works with libraries is that you have to specifically "import" any library you want to work with. This does not move, or copy any files but creates an Eclipse specific link. This totally avoids conflichts with libraries. The Arduino IDE gets confused for example if you want to use two differnet versions of a library that have the same files names.
 
As far as I know, the IDE alternatives now are
1. Arduino IDE such as it is.
2. Eclipse (free)
3. Atmel Visual Studio 6 + Visual Micro (both free, and support for AVR and Teensy 3 targets).
4. Code::Blocks (free).
5. variants of #4, different names
6. Apple-Mac specific IDE, XCode
 

You guys are all awesome, and I really appreciate the help. Keep in mind, manufacturing engineer here, not EE / CS / luminary. As in I need to do a lot of reading / looking up to even understand many of the wise words that Michael used, never mind understand everything he was getting at. Clearly, I have a lot of learning to do re: C and I appreciate the suggestions re: alternatives to the Arduino IDE - I am using BBEdit for the editing as of now but can see how Eclipse, et al. may be much better environments to work in - whenever I can find the time to install, debug, etc. the resultant environment.

For now, I have simply added a free-to-use SHT21/HTU21/Si7021 library into my logger library to allow me to address the HTU21 or Si7021 chip onboard. Not elegant, but it works. Still have to enable non-blocking operation, was thinking of using Metro for that.

What's curious is a statement inside the Sensiron SHT21 library stating that the SHT21 is not I2C compliant enough for AVRs, requiring bit-banging to get it going (see the cpp file, they even show the waveforms they're trying to achieve). FWIW, the HTU21 and the Si7021 are supposed to be drop-in replacements for the SHT21 and yet the LadyAda library for the HTU21 only uses hardware I2C. Another oddity!

Thanks again and if anyone knows a lot about I2C and wants to take a look at the Sensiron 2.0 library vs. the hardware implementation on a Teensy, I'd love to hear their opinion. Thank you, thank you, thank you!
 
As far as I know, the IDE alternatives now are
1. Arduino IDE such as it is.
2. Eclipse (free)
3. Atmel Visual Studio 6 + Visual Micro (both free, and support for AVR and Teensy 3 targets).
4. Code::Blocks (free).
5. variants of #4, different names
6. Apple-Mac specific IDE, XCode

7. Stino plugin for Sublime Text editor (Support for AVR, Teensy, ATTiny, etc). Comes with Serial monitor and upload capability using avrdude and/or Teensy Loader.
 
I've been using Sublime Text for a while now and it works great with Arduino/Teensy !
Does it do pop-up tool-tips for function params? "goto" where defined (file and line number), click on error from compiler and jump to file and line with error? and all those sort of things?

If so, it's comparable to the IDEs like #2,#3 above, and I'd like to give it a try. (difference of course between a nice editor and an IDE).
Is there a simple installer? Link to that is?
 
Sublime Text doesn't work like a traditional IDE in the sense that it's plugin based. There are plugins for a lot of IDE like features.
There is goto symbol/definition built-in, the other features might be available via plugins. If you're looking for a full featured IDE then I don't think you will like it. I personally enjoy it because it's very fast, lightweight and I can have the same workflow wether I'm coding for the Teensy/Arduino or developing a website or writing a Python app. You can try it for free for an unlimited amount of time:
http://www.sublimetext.com/3
 
About the libraries, believe that Arduino IDE scans pde and ino files to see what libraries to import. But it does not scan library code files for dependencies. So the user would have to be instructed to include <Wire.h> in her main ino file for it to work.

I also much prefer Eclipse to Arduino IDE! Sometime I will try out Code::blocks or variants.

Apparently Arduino are writing a whole new IDE, but really I find the current one unusable, apart from one line test sketches.
 
Status
Not open for further replies.
Back
Top