I still get the same error despite removing that block of code. I don't understand as in DallasTemerapture.cpp line 3 is now blank and line 4 is completely different now I have removed that chunk of code but I am getting the same error..... (I have copy and pasted the first 15 lines of the file below):
DallasTemperature.cpp:3:32: error: expected constructor, destructor, or type conversion before ';' token
DallasTemperature.cpp:4:25: error: expected constructor, destructor, or type conversion before ';' token
make: *** [DallasTemperature.o] Error 1
@gorstj and @gilius, I think I have found the issue, but am not sure about the correct solution.
The error is cause at the end of the DallasTemperature.cpp file. There is a statement:
#if REQUIRESNEW
// MnetCS - Allocates memory for DallasTemperature. Allows us to instance a new object
void* DallasTemperature::operator new(unsigned int size) // Implicit NSS obj size
{
void * p; // void pointer
p = malloc(size); // Allocate memory
memset((DallasTemperature*)p,0,size); // Initalise memory
//!!! CANT EXPLICITLY CALL CONSTRUCTOR - workaround by using an init() methodR - workaround by using an init() method
return (DallasTemperature*) p; // Cast blank region to NSS pointer
}
// MnetCS 2009 - Unallocates the memory used by this instance
void DallasTemperature::operator delete(void* p)
{
DallasTemperature* pNss = (DallasTemperature*) p; // Cast to NSS pointer
pNss->~DallasTemperature(); // Destruct the object
free(p); // Free the memory
}
#endif
Since the header declares REQUIRESNEW=false, these are unneeded (unless you want the new and delete operators).
If you simple remove that whole logic block, it compiles just fine.
Any other gurus know how to get that code to compile properly using the WebIDE?
I just ran through the code looking for unusual declarations. I also tested out by removing large chucks of code and seeing if it would compile.
As for the impact, I am not 100% sure. If you look in the header, the ifndef statement looks like that chunk of code would not have even been included unless you added the REQUIRESNEW=true somewhere else in your app.
Semi unrelated, but I ended up porting a 1-wire lib from another project that is much smaller than this one. Give it a shot if you like. Here is the link to the github.
Anyone have a link to the hardware 1-Wire library another user posted awhile back? Search isnāt turning it up for me. (IMO I think itās the best implementation for the Core so far.)
mattande, if I understand correctly, your interrupt driven OneWire library is now incorporated in the core master? Or is it a separate implementation of the OneWire library than the master?
None of this work has been merged (or pull requested) to the spark repositories. If you are building locally you can merge the mattande/core-firmware@onewirehw and mattande/core-common-lib@onewirehw branches to bring in the hardware onewire support.
The onewirehw,cpp, onewirecrc.c and onewire_ds18b20.cpp files could be used as external libraries in the web ide (by including the required files), except there is a change in it_stm32.cpp which is needed to add the interrupt sharing between the OneWireHW object and the Serial1 object (They both use the STM32ās USART2). At least this USART2 interrupt sharing change would have to be merged on the spark master.
I am open to pushing this upstream if there is interest.
I added an option to use the STM32ās internal open drain driver and bridge the USART RX and TX pins internally (half-duplex mode), eliminating the need for an external drive circuit. The only required hardware is the 4.7K pull up resistor if you use that option.
Thereās an update on this a few posts down in the thread.
The only issue is how to make sure the user doesnāt try to use both Serial1 and one-wire. Hopefully users would figure out the problem when they tried to connect to the coreās pins!
I donāt think thatās really an issue as theyād physically be hooking the 1-Wire device up to the TX pin, which means they canāt very well hook something else up to it. (Well, I guess they can but in that case Serial1 wouldnāt work either!)
And yes, please do a pull request on this! Itās awesome! (It actually inspired me to do my own implementation on the MSP430 using a spare USART.)
Iāve been testing the code form Google Drive and got it to compile with @billprozacās tips. It all compiles. When I hook the DS18B20 sensors up, though, with any combination of pull-up resistors ranging from 1k-5k, I get ā85.0ā readings indicating an error somewhere. Iāve re-wired and triple-checked the wiring a dozen times over (so it feels anyway). Iāve tried the sensors backwards, which makes them get extremely hot, so at least I know they are orientated correctly.
Also: sensor.getDeviceCount()) is returning ā0ā when run in setup(). Seems plenty is not right here but Iām a little new to this.
Whatās the consensus on the best library to use at this point? I may have exhausted my attempts with the Gdrive version.
I used this one from @wgbartley but you have to edit out all the other stuff you donāt need since this was from a time before the webIDE supported multiple files.
Find this section and copy starting here:
// ONE-WIRE CLASS
#define OneWire_h
#include <inttypes.h>
and end here:
return crc;
}
// THERMISTOR CLASS
The example in that gist does not check crc but I have tried adding those checks and it works fine. I took the CRC calculation out for now since on the breadboard they were not needed. Over a longer wire,I would put them back in.
I am using 4.7k a pullup. Here is the code to read the temp:
One other point: with heavy use, the spark core runs warm and can get the DS18B20 up a few degrees if it is in close proximity. The one on the desk next to me is reading 76.2 degrees in room where the air temp is closer to 70.0. They are very sensitiveātry putting your finger tip on it and see if it doesnāt jump up quickly.
When you have more than one 1-wire sensor on a shared data line, there is different discovery protocol you have to use to find them all and address them individually.