I just registered to this forum but I already know the Arduino platform, C and some hardware stuff. I'm working on a small project where I have to read one analog sensor and a 1wire device (DS18B20). The data has to be sent using a RFM12B module. Looks like my only problem is the OneWire library…
When I try to compile the code I get these errors:
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)':
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:105: error: 'digitalPinToBitMask' was not declared in this scope
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:106: error: 'digitalPinToPort' was not declared in this scope
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:106: error: 'portInputRegister' was not declared in this scope
I'm a bit confused because all these functions are defined in Arduino_1.0/hardware/tiny/cores/tiny/pins_arduino.h. Actually these are not functions but preprocessor macros but why doesn't this work?
I'm planning to make some custom pcb's and don't like the idea to go to a ATmega only because of this 1wire library… Any ideas? I could provide some demo-code if needed.
I suggest using Paul Stoffregen's library. You can get it working by...
• Locate and open OneWire.h
• Locate this section of code towards the top...
#if ARDUINO >= 100
#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc
#else
#include "WProgram.h" // for delayMicroseconds
#include "pins_arduino.h" // for digitalPinToBitMask, etc
#endif
• Change it to this...
#if ARDUINO >= 100
#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc
#include "pins_arduino.h" // for digitalPinToBitMask, etc
#else
#include "WProgram.h" // for delayMicroseconds
#include "pins_arduino.h" // for digitalPinToBitMask, etc
#endif
• Save and close OneWire.h
• It is not necessary to restart the Arduino IDE
To be quite clear about the matter: This is not a problem with the OneWire library but rather a deficiency in the Tiny Core. Essentially, Paul has made OneWire compatible with Arduino 1.0 while the Tiny Core is only partial compatible.
hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25/libgcc.a(_exit.o)
The problem goes away when I remove all references to OneWire OR rfm12b. Looks like some kind of resource problem. It's not the sketch-size, it has to be something else… I'll try to restructure my code.
It's not the first time I run into a problem with the Arduino 1.0 toolchain. It's a 1.0 - there have to be problems XD
Thanks for the links, google actually wasn't really useful on this problem. Too bad I can't use your install instructions as I'm running Arduino on OS X, not Windows. WinAVR sounds a little bit like a Windows application…
I just found a nice OS X package with all the required files. Here's how to install it: