Can I use 1-Wire devices with Spark Core?

tidwelltimj, I cannot get your code to work. All it prints is “no more addresses”. I put a pull-up on the data pin but still no luck. I even changed the input to D4, again without luck. Any thoughts?

that sounds like its not pulling up correctly or the DS18B20 is responding at all. Can you get it to work with any other micro controller?

Good question. I’ll scope it and try it on an a 3.3V arduino to be sure.

Oh garsh, I’m embarassed :stuck_out_tongue: I was using Serial as the output instead of Serial1 and I missed one of the suckers and it basically hung the code. As soon as I fixed it, everything worked superbly.

Thanks!

2 Likes

no worries, happy to hear its working!

I am relatively new to SparkCore/Arduino but have used One-Wire library in an arduino project.

I would like to use it with Spark but have no idea of how to change it to a library file .h .cpp, have you managed it yet?

gorstj, Yes, I have it split up for an 18B02 temperature sensor demo I have on my web IDE. If you’re interested, I can put it up on my github. :smile:

someone has already posted it to Github, its here.

I wish we had a central, searchable git repository. Sigh!

Thanks tidwelltimj!

Something like this is coming soon! I can’t give details right now, but suffice it to say it will make you very happy! :smile:

1 Like

I can still use the Web IDE with this (just copy and paste into the .h and .cpp tabs)?

I am still coming to terms to leaving Arduino IDE.... which I wasn't that good with in the first place!

Now I just need to hunt down a rotary encoder library and sort out PID and my Sous Vide should be ported to Spark!

1 Like

i just tried this and it worked out that simple! just copy and paste from github.

I have trouble getting this to compile in the web IDE, problems finding the OneWire.h etc.
Have you made any changes ?

you need to name the new tabs OneWire.h and OneWire.cpp and have #include “OneWire.h” at the top of your main program

Already there, the problem is that DallasTemperature.h refers to OneWire.h on line 22 and there it looks like something goes wrong. I already have the OneWire.h / .cpp and DallasTemeprature.h /.cpp in place and I get the following error:

In file included from DallasTemperature.cpp:10:0:
DallasTemperature.h:22:21: fatal error: OneWire.h: No such file or directory
compilation terminated.
make: *** [DallasTemperature.o] Error 1

When I change DallasTemerature line 22 from #include <OneWire.h> to #include "OneWire.h" I get this error and somewere there my knowledge ends:

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

So what am I missing?

/g

gilius, take a look at the code in my github. One thing for sure is the #include should be with quotes, not brackets; #include "OneWire.h". :smile:

I am getting the same error too..... using the Web IDE.
If you get a solution please post!

The problem seems to revolve around working out the Arduino version so it will compile on old versions of the Ardiono IDE..... I'm not experienced enough to see what we should do in Spark?

#ifdef __AVR__
  #if ARDUINO >= 100
      #include "Arduino.h"   
  #else
  extern "C" {
      #include "WConstants.h"
  }
  #endif
#endif
#ifdef STM32F10X_MD
   #include "spark_wiring.h"
#endif

gorstj, you can get rid of the entire section of code you show above. On the web IDE, the line:

#include "Application.h"

is included implicitly so you don’t have to. It takes care of everything that the #ifdef AVR is trying to do. :smile:

Just remove that entire block about the arduino and it should compile... unless there are some macros in the Arduino.h that are not defined in the spark_wiring.h (and there may be some)... but you don't need to include the spark_wiring.h to find out. Post your errors after you do that, if you get any.