Instructables

Arduino feeding xively.com with temperature from DS18B20

Picture of Arduino feeding xively.com with temperature from DS18B20
This instructable will explain how to:
* connect a DS18B20 temperature sensor to an arduino
* read from the sensor using the 1-wire interface
* send that data to xively.com directly from the arduino
* view the resulting graph on the internet

http://xively.com is an Internet of Things host that generates graphs based on data you provide. In this example I am going to use it to monitor the temperature in my room. It's not a hackerspace, my wife keeps it far too tidy for that.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts list

Picture of Parts list
* Arduino with ethernet shield
I have an arduino Uno clone and a wiznet 5100 shield.
* Power supply (it can be powered via the USB port)
I was fortunate that my router has USB ports that provide the 5v output meaning the arduino  is powered whenever the router is and saves a plug, electricity, the environment and the  future of the world.
* DS18B20 temperature sensor
* RJ45 network cable connected between the arduino and your router

Step 2: Schematic

Picture of Schematic
* Arduino gnd to DS18B20 both outer legs
* Arduino 5v to 4.7k resistor leg 1
* 4.7k resistor leg 2 to DS18B20 middle leg
* Arduino digital pin 2 to DS18B20 middle leg
* RJ45 cable from Arduino to router
* Power to Arduino (via USB or barrel jack, I use USB from my router)

Step 3: Prerequisites

Picture of Prerequisites
Three libraries are required for the arduino:
onewire library from http://www.pjrc.com/teensy/td_libs_OneWire.html (specifically http://www.pjrc.com/teensy/arduino_libraries/OneWire.zip)
httpclient library from https://github.com/amcewen/HttpClient (https://github.com/amcewen/HttpClient/archive/master.zip)
Xively library from https://github.com/xively/xively_arduino (https://github.com/xively/xively_arduino/archive/master.zip)
install these libraries in your arduino/library directory.

An account with http://xively.com (formerly pachube.com and cosm.com)
Sign up for a free developer account at https://xively.com/get_started/
Pick a username, password, set your address and timezone etc. You will receive a confirmation email, click the activation link to avtivate your account.
You can choose to take the test drive to learn about xively or skip it, this is completely up to you.
Doing the test drive? I'll wait
- \ | / - \ | /
Done? Let's continue

I want to make circuit b using 4 sensors and 4 single resistor sensor connections print.4 sensor enough for my seven-inch screen. Is there another Arduino, or need

silver1116 months ago

Hi. if someone was able to run it with multiple sensors (5)?

erojs silver1112 months ago

for multiple sensors in the end of the code after Serial.println("Uploading it to Xively");

replace

datastreams[0] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

with

XivelyDatastream datastreams[0] = XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT);

Worked for me, hope that helps.

slightly corrected and in my code runs on multiple sensors.

I just have a problem with the naming of streams. What I mean is that the individual data struienia zwoimi call names and not the serial numbers of sensors.

silver111,

May I ask what you did to get multiple sensors working? I'd like to add additional temp probes but haven't been having much luck.

sidbin9 months ago

Error:

Serial.println("Uploading it to Xively");
datastreams[0] = {
XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

  • ------------------------
sketch_feb13d.ino: In function 'void loop()':

sketch_feb13d:178: error: expected primary-expression before '{' token
sketch_feb13d:178: error: expected `;' before '{' token

silver111 sidbin6 months ago

Hi. if you were able to run the project with multiple sensors?

gregoryfenton (author)  sidbin9 months ago
There is a missing after the , in that line. I will have a look shortly and get b back to you.
chetan04127 months ago

Error,

Please give solution...

IP address: 192.168.1.6.

Chip = DS18B20

Current temperature: 33.13 celsius

Uploading it to Xively

xivelyclient.put returned -3

chetan04127 months ago

Connection and setup done but not working...

denisr7 months ago

Greg; Hi. As with rparkera and sidbin below, I have the same problem with the multiple sources sketch that they have.

I get the following errors:

Multiple_Xively.ino: In function 'void loop()':

Multiple_Xively:179: error: expected primary-expression before '{' token

Multiple_Xively:179: error: expected `;' before '{' token

Multiple_Xively:188: error: expected `}' at end of input

You were going to get back to sidbin, but don't seem to have done so.

And for the record, I have only just started using Arduino as it's the most practical solution (I think) to a long running temperature monitoring problem I have.

Thanks...!

rparkera8 months ago

Hi there - great instructable. Many thanks

Did you ever get back on sidbin's query? I have exactly the same problem. The single datastream works fine - but I can't get the multiple sources working. Help!

agavrin8 months ago

Some other example to use for xively reporting - use it to track URL performance..

http://linuxadvices.blogspot.ru/2014/02/log-url-performance-in-xively.html

fiolin9 months ago

Works for me thank you to share it

la3bna9 months ago

here is my feed:

https://xively.com/feeds/163946092

But I don't think it's public yet. Can you help me with that?

gregoryfenton (author)  la3bna9 months ago

It works for me :)

la3bna9 months ago
(removed by author or community request)
gregoryfenton (author)  la3bna9 months ago

Check step 5 and look at the picture. At the top it says "public".

If yours is set to private, click on the button (it looks like a pencil) to edit the settings.

Change it from "Private Device" to "Public Device", click "save and continue".

All done :)

Feel free to post a link to your public feed :)

Thanks! I didn't see that until you pointed it out for me

(facepalm)

boernic11 months ago
hi i have followed your instructable and it works great!

im am thinking of adding some xtra ds18b20 sensors and wonder how to adress them any hints?

thanks

Nico
gregoryfenton (author)  boernic11 months ago
Just plug them in in parallel. The code will read them in order.
To update more than one datastream, look at the dataStreams[] parts of the code.

Thanks for the tutorial. I tried it and its working great with 1 sensor, but i cant see how to get a second or more sensors working. Any chance you could elaborate on the above a little more? Thanks in advance...

marijnbilsen10 months ago
Hi guys I need your help,

I've followed all the steps in this great tutorial but it doesn't work for me.

I keep on getting "No more addresses" in the serial monitor and xively is not receiving any datapoints.

What does this mean and how could it be solved?

It would be really great if one of you could help me
speedy2511 months ago
Hey guys I have a problem.
I would like to add more sensors (DS18B20) and it fails.

Could you help me i am a beginner.

Thank you in advance for your help

standa
zenius1 year ago
Hi,
Thanks for your intructable ! :-)
It worked perfectly for 9 minutes, but now it's not sending anything…
What is the problem ?
gregoryfenton (author)  zenius1 year ago
Hi Zenius :)

Are you powering the Arduino from a steady power supply?
Have you tried resetting the Arduino?
Mine has been running pretty much continuously since it was set up with no issues apart from when the network cable became loose a couple of times. I think it has also only been turned off a couple of times too when I was sorting out round the router.

Get back to me :)
theohegg1 year ago
Hi there! Im trying to use your xively code but Im getting an "i" was not declared in this scope error. Would you know why this might be ? Im a bit new to arduino
gregoryfenton (author)  theohegg1 year ago
Fixed in the code.

I missed the line
int i;
after
float celcius;

I apologise for the oversight.
Thx a lot. Now it works perfect
gregoryfenton (author)  theohegg1 year ago
Glad I could help :)

What's your xively link so I can see it working? :)
This is my link. https://xively.com/feeds/1172808344 Tried to get a second temp read working but luck so far
cpoplawski1 year ago
I have everything wired up the same way as in your sketch except I don't seem to be getting any data from the sensor. When i use the example one wire sketch specific to the sensor it has no problems. any ideas?
gregoryfenton (author)  cpoplawski1 year ago
I apologise, I forgot to do the actual reading of the chip in the above code :P

You need to add the following

for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();

after

ds.write(0xBE); // Read Scratchpad

josephyong1 year ago
Please help, everything is fine just unable to get data from 18B20 Sensor it show IP address: 192.168.0.102.
Chip = DS18B20
Current temperature: 0.00 celsius
Uploading it to Xively
xivelyclient.put returned 200
i have double check the connection is correct.
gregoryfenton (author)  josephyong1 year ago
I apologise, I forgot to do the actual reading of the chip in the above code :P

You need to add the following

for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();

after

ds.write(0xBE); // Read Scratchpad

gregoryfenton (author) 1 year ago
I apologise, I forgot to do the actual reading of the chip in the above code :P

You need to add the following

for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();

after

ds.write(0xBE); // Read Scratchpad