First Basic Project: Wifi Temperature Sensor

For my first project with the SparkCore I am going to rehash one of my old temperature sensor projects and have it post its temperature data over Wifi to a service like Xively. The cool thing about this is that you basically set it up once and it is a real IOT device that can send useful data to the cloud for as long as it is plugged in. You can even easily remove the device and bring it somewhere else and simply reconfigure to the new wifi settings from your phone to get it posting again.

I have another version of similar temperature monitoring projects here:


(xively used to be pachube, then cosm but its the same service)

The new idea with the sparkcore will be so much better because of its small size and lack of anything other than a power supply, and I am going to try and build the entire thing into a small “wall wart” plug. I haven’t decided yet if I should use the SHT21 or the DS18B20 (I have used both), but I will post details and pics on my blog as work through the idea. Feel free to give me feedback or suggestions on the idea if you want, I am VERY excited to get started with the SparkCore!

1 Like

Would love to see where you get to with this! Interested in a similar thing for my own use but have zero skills in coding so any pointers or examples would be excellent.

So I’ve got temperature measurement going in a way I can monitor it… I went arguably a bit over the top and there were easy ways to solve it but I come from the enterprise development background so it’s easy for me… I developed a Java logger to extract variables via REST get calls from the device. These are made from a Rasberry PI acting as a server. It stores them in a Berkley DB and makes them available as REST requests (Tomcat and Jersey) which are in turn rendered up via high charts… This means it’s always available and up to date.

I’m still getting wild variations which I’ll look at in another thread. I’ll hook up a humidity and hopefully a particulate monitor as well shortly.

Have you had any thoughts on cases to hold all your monitors in?

I think there’s a thread somewhere around here about enclosure design… I’m pretty interested in creating a container as well.

Hi @contractorwolf,
I would like to realize something similar. If you are interested I’m working on this to automatically update data to xively: https://community.spark.io/t/interface-spark-core-with-xively/475 It is just an example to test the tcp connection with the service.
Let me know if you have some suggestions!
dk

Hi d82K, will try your example, thanks for posting.

I have built something like this but for an electric imp.

I would love to use a thermocouple and a spark core to do the same.

Would it be possible to adapt this code to work with a spark core? (Dom I suspect you are a GOD with code so could you have a look)

emc2, have you considered shapeways? http://www.shapeways.com

They have a few Arduino enclosures. I bet one could be modded to fit a core.

That’s an awesome site! Not too wild about the pricing, but I guess it’s far more convenient than buying a 3D printer and making the part yourself.

That said, I’ve got a Zim on order and am quite excited to start prototyping some cases :smile:

w00t! I was just going to reply "That's why I pre-ordered a Zim" ... because I can't stand the pricing of these online sites. I'm willing to hunker down now, to save later. lol. And here I come to keep reading and see you got a Zim as well! Nice. Can't wait to see my company name silkscreened on the top plate :wink:

Hah, what a coincidence! Man, I can’t wait to get working with that thing… I agree, very excited to see what it’s capable of.

Just saw the Zim printer… Never seen that before. If you don’t mind me asking what did they retail for?

The Zim printer looks very nice emc2. I trust you will post some pics of your proto enclosures?

What size of item will it print?

DOM can I ask, what sensors did you use in your office monitor?

If you used a thermocouple then can i offer :-

http://learn.adafruit.com/thermocouple/overview

They say :-

If you are using the MAX31855 v1.0 in a noisy environment, you may need to add a 0.01uF capacitor across the thermocouple leads.

Any use?

Some details:

Zim Kickstarter Page

  • Print volume: 5.9" x 5.9" x 5.9"
  • Fine resolution: 50 microns/layer
  • Print speed, fast: 110mm/s
  • Info table graphic
  • Built on open-source hardware and software bases: Ramps 1.4, Marlin, Slic3r, Meshlab, VLC, Lighthttpd etc.
  • Powered by Linux-based 1GHz ARM, 1GB RAM
  • onboard video streaming and remote mobile control :smiley:
  • Entry level backer: $600 USD

I think that in one of their updates they mention that the backer pricing was roughly half of the retail price, placing the printer at $1200 USD for the single-head extruder model. Not sure if that is accurate though.

I believe that they are aiming to ship in March!

@Julian that looks surprisingly similar to this :smile:

//double temperature = 0.0;
double thermoTemp = 0;
double internalTemp = 0;
bool hasError = false;
bool scvFault = false;
bool scgFault = false;
bool ocFault = false;
//unsigned int rawLow = 0;
//unsigned int rawHigh = 0;
unsigned long raw = 0;

typedef struct {
    int ThermoTemp : 14;
    unsigned char Reserved : 1;
    bool Fault : 1;
    int InternalTemp : 12;
    unsigned char Reserved2 : 1;
    bool SCVFault : 1;
    bool SCGFault : 1;
    bool OCFault : 1; 
} Temp;

union Reading {
  unsigned long bit32;
  unsigned int bit16[2];
  unsigned char bit8[4];
  Temp temp;
};


void setup() {
   // Spark.variable("temperature", &temperature, DOUBLE);
    Spark.variable("hasError", &hasError, BOOLEAN);
    Spark.variable("scvFault", &scvFault, BOOLEAN);
    Spark.variable("scgFault", &scgFault, BOOLEAN);
    Spark.variable("ocFault", &ocFault, BOOLEAN);
    Spark.variable("thermoTemp", &thermoTemp, DOUBLE);
    Spark.variable("internalTemp", &internalTemp, DOUBLE);
    Spark.variable("raw", &raw, INT);
//    Spark.variable("rawLow", &rawLow, INT);
//    Spark.variable("rawHigh", &rawHigh, INT);

    SPI.setClockDivider(SPI_CLOCK_DIV64);
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE3);
    SPI.begin();

    //digitalWrite(SS, HIGH);
}

void loop() {
    Reading reading;
    
    //clear the data
    reading.bit32 = 0;
    
    digitalWrite(SS, LOW);
    delay(1);
    
    //read in the 32-bit value
    for(int i =3; i >= 0 ; i--) {
        reading.bit8[i] = SPI.transfer(0);
    }
    
    thermoTemp = (double)((reading.bit32 >> 18) & 0x00003FFF) / 4.0;
    internalTemp = (double)((reading.bit32 >> 4) & 0x00000FFF) / 16.0;
    //temperature = reading.temp.ThermoTemp / 4.0;
    hasError = reading.temp.Fault;
    scvFault = reading.temp.SCVFault;
    scgFault = reading.temp.SCGFault;
    ocFault = reading.temp.OCFault;
    //rawHigh = reading.bit16[0];
    //rawLow = reading.bit16[1];
    raw = reading.bit32;
    
    digitalWrite(SS, HIGH);    
    delay(100);
}
2 Likes

@mattdot That looks just like what I am looking for. Do you have a wiring diagram? Have you tried to connect the data to a google spread sheet or xiveley?

Thanks for the post of the code:) much appreciated.

I did that… I still got no where near as accurate a measurement if I used a DHT22 or BMP180. Sure its not surprising I just wonder if its worth spending time to try and achieve that accuracy…

@Dom Please can you add this code to your index. I think that the idea of having a code index is fantastic. Could I suggest that we work out a standard way of reporting them. I am thinking something like a google docs spread sheet that anyone can add to? Maybe you can see a better way. Maybe this is something more for a spark core organiser (I suppose by definition, it is) I was just thinking that the idea of organising all the work that has been put into code, so that other people can easily access and use it.

Hi @Julian which code are you referring to?