How to DS18b20+arduino to send to www.grovestreams,com

I would not know how to send data on the temperature of the DS18b20 via arduino to grovestreams(
If someone has a code I would share it.
thank you

moderator: updated the title

does provide any other arduino example?
Or does google?

You might need to merge DS18B20 example code with such.

1 minute later after visiting the grovestream website

Have you read this - GroveStreams Arduino - Quick Start -

just mix their example with another temp sensor code...

Hi there,

I am just new in using arduino and I could not find an easy code to send the DS18B20 signal through grovestreams. Could anyone have a look in my code and see what I am doing wrong?

#include <SPI.h>
#include <Ethernet.h>

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 10 on the Arduino
#define ONE_WIRE_BUS 10

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// soil is for the Hygrometer
int soil=0;

// Local Network Settings
byte mac = {
0x00, 0x16, 0x3E, 0x5F, 0x45, 0xA4 }; // Change this!!! Must be unique on local network.
// Look for a sticker on the back of your Ethernet shield.

// GroveStreams Settings
char gsApiKey = “6074-4bb8-3a67-a9bf-5bb3542739a5”; //Change This!!!
char gsComponentName = “Aquaponics”; //Optionally change. Set this to give your component a name when it initially registers.

char gsDomain = “”; //Don’t change. The GroveStreams domain.
char gsComponentTemplateId = “temp”; //Don’t change. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
// The blueprint is expecting “temp”.

//GroveStreams Stream IDs. Stream IDs tell GroveStreams which component streams the values will be assigned to.
//Don’t change these unless you edit your GroveStreams component definition and change the stream IDs to match these.
char gsStreamId1 = “s1”; //Temperature.
char gsStreamId2 = “s2”; //Humidity.

// Other Settings
const unsigned long updateFrequency = 20000UL; // Update frequency in milliseconds (20000 = 20 seconds). Change this to change your sample frequency.

char samples[35]; // Change this buffer size only if you increase or decrease the size of samples being uploaded.

char myIPAddress[20]; //Don’t Change. Set below from DHCP. Needed by GroveStreams to verify that a device is not uploading more than once every 10s.
char myMac[20]; //Don’t Change. Set below from the above mac variable. The readable Mac is used by GS to determine which component the
// feeds are uploading into. It must match an existing GroveStreams component’s ID

unsigned long lastSuccessfulUploadTime = 0; //Don’t change. Used to determine if samples need to be uploaded.
int failedCounter = 0; //Don’t change. Used for Internet Connection Reset logic

// Initialize Arduino Ethernet Client
EthernetClient client;

void setup()
// Start Serial for debugging on the Serial Monitor

// Start up the Temperature Sensor library

// Start Ethernet on Arduino

void loop()

// Update sensor data to GroveStreams
if(millis() - lastSuccessfulUploadTime > updateFrequency)


void updateGroveStreams()
//Assemble the url that is used to pass the temperature readings to GroveStreams and call it
unsigned long connectAttemptTime = millis();

if (client.connect(gsDomain, 80))

//You may need to increase the size of urlBuf if any other char array sizes have increased
char urlBuf[175];

sprintf(urlBuf, “PUT /api/feed?compTmplId=%s&compId=%s&compName=%s&api_key=%s%s HTTP/1.1”,
gsComponentTemplateId, myMac, gsComponentName, gsApiKey, getSamples());

//Uncomment the next three lines for debugging purposes
//Serial.print(F("urlBuf length = "));

client.println(urlBuf); //Send the url with temp readings in one println(…) to decrease the chance of dropped packets
client.print(F("Host: "));
client.println(F(“Connection: close”));
client.print(F("X-Forwarded-For: ")); //Include this line and the next line if you have more than one device uploading behind
client.println(myIPAddress); // your outward facing router (avoids the GS 10 second upload rule)
client.println(F(“Content-Type: application/json”));


if (client.connected())

//Begin Report Response

char c =;
//End Report Response

//Client is now disconnected; stop it to cleannup.

lastSuccessfulUploadTime = connectAttemptTime;
failedCounter = 0;



void handleConnectionFailure() {
//Connection failed. Increase failed counter

Serial.print(F(“Connection to GroveStreams Failed “));
Serial.println(F(” times”));

// Check if Arduino Ethernet needs to be restarted
if (failedCounter > 3 )
//Too many failures. Restart Ethernet.


void startEthernet()
//Start or restart the Ethernet connection.

Serial.println(F(“Connecting Arduino to network…”));

//Wait for the connection to finish stopping

//Connect to the network and obtain an IP address using DHCP
if (Ethernet.begin(mac) == 0)
Serial.println(F(“DHCP Failed, reset your Arduino and try again”));
Serial.println(F(“Arduino connected to network using DHCP”));

//Set the mac and ip variables so that they can be used during sensor uploads later
Serial.print(F(" MAC: “));
Serial.print(F(” IP address: "));


char* getMacReadable()
//Convert the mac address to a readable string
sprintf(myMac, “%02x:%02x:%02x:%02x:%02x:%02x\0”, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

return myMac;

char* getIpReadable(IPAddress ipAddress)
//Convert the ip address to a readable string
unsigned char octet[4] = {0,0,0,0};
for (int i=0; i<4; i++)
octet = ( ipAddress >> (i*8) ) & 0xFF;

  • }*
  • sprintf(myIPAddress, “%d.%d.%d.%d\0”,octet[0],octet[1],octet[2],octet[3]);*
  • return myIPAddress;*
    char* getSamples()
  • //Get the temperature analog reading and convert it to a string*
  • float degreesC, soil;*
    // request to all devices on the bus
  • sensors.requestTemperatures(); *
    // Send the command to get temperatures
  • degreesC = (sensors.getTempCByIndex(0));*

_ //voltage = (analogRead(temperaturePin) * 1);_
_ //degreesC = (voltage - 432) * 0.6761 - 0.5244 ;_
_ //degreesF = degreesC * (9.0/5.0) + 32.0;_

  • int sensorValue = analogRead(A0);*

  • sensorValue = constrain(sensorValue, 400, 1023);*

  • // print out the value you read:*

  • //Serial.println(sensorValue);*

  • //map the value to a percentage*

  • soil = map(sensorValue, 400, 1023, 100, 0);*

  • char tempC[15] = {0}; //Initialize buffer to nulls*

  • dtostrf(degreesC, 12, 3, tempC); //Convert float to string*

  • char Hum[15] = {0}; //Initialize buffer to nulls*

  • dtostrf(soil, 12, 3, Hum); //Convert float to string*

  • //Assemble the samples into URL parameters which are seperated with the “&” character*

  • //*

  • // Example: &s1=25.684&s2=78.231*

  • sprintf(samples, “&%s=%s&%s=%s”, gsStreamId1, trim(tempC), gsStreamId2, trim(Hum));*

  • return samples;*
    _char* trim(char* input) _

  • //Trim leading and ending spaces*

  • int i,j;*
    _ char *output=input;_

  • for (i = 0, j = 0; i<strlen(input); i++,j++) *

  • {*
    _ if (input*!=’ ') _
    _ output[j]=input;
    * j–;
    return output;
    It returns as temperature = 127 which means that it is not reading.
    I am sure that the sensor works because when I test it with different code it works.