Not all DS18B20 sensors present on ThingSpeak | Arduino | Forum


Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Not all DS18B20 sensors present on ThingSpeak
No permission to create posts
July 3, 2016
11:45 pm
New Member
Forum Posts: 3
Member Since:
July 3, 2016
sp_UserOfflineSmall Offline

I have successfully compiled a sketch that collects and displays an analog temperature, 2 (of 4)  DS18B20 sensors, and a digital temperature and humidity output from a DHT11 sensor.  All sensor data mirrors on the COM port, but 2 of the DS18B20 fields do not display on ThingSpeak.  When I include those fields no data is updated on ThingSpeak.  When I comment them out all other data is updated.

The sketch follows:

This sketch builds upon V5 by trying to incorporate 2 more DS18B20 sensors for Field 4 and 5
independant of the Field 2 and 3 sensors

This sketch successfully logs 1 analog, 2 DS18B20 signals, and 1 set of DHT11 data.
It doesn't transmit Field 3 and Field 4 from the DS18B20 sensor. Don't know if it is a voltage issue or a
String composition limitation

#include "ThingSpeak.h"
#include <OneWire.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <DHT.h>
// Use wired ethernet shield
#include <SPI.h>
#include <Ethernet2.h> // Make sure there is a 2 after Ethernet!
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;

// Analog Pin setup -
// On Arduino: 0 - 1023 maps to 0 - 5 volts
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0

// Define DHT11 for room temperature and humidity measurement
#define DHTPIN 4 // what digital pin we're connected to.. Digital Pin 4 in this case
#define DHTTYPE DHT11 // DHT 11

// DS1820 Setup.... A oneWire instance to communicate with any OneWire devices
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
//#define ONE_WIRE_BUS 5
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of 1-Wire temp sensors.
DeviceAddress HPWH_TempOut = { 0x28, 0x37, 0x08, 0x1E, 0x07, 0x00, 0x00, 0x1F }; // Tested
DeviceAddress HPWH_TempIn = { 0x28, 0x80, 0x8D, 0x1C, 0x07, 0x00, 0x00, 0x83 }; // Tested
DeviceAddress DWH_TempOut = { 0x28, 0x92, 0x38, 0x1D, 0x07, 0x00, 0x00, 0xA4 }; // Not working when DHT11 robs power
DeviceAddress DWH_TempIn = { 0x28, 0xA4, 0xA8, 0x2A, 0x07, 0x00, 0x00, 0x82 }; // Shows at Serial Print but not on ThinkSpeak: maybe voltage problem

unsigned long myChannelNumber = 130737;
const char * myWriteAPIKey = "F0QA9UVAQWWQ0G1E";

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

// set the resolution to 10 bit (way more than I need)
sensors.setResolution(HPWH_TempOut, 10);
sensors.setResolution(HPWH_TempIn, 10);
sensors.setResolution(DWH_TempOut, 10);
sensors.setResolution(DWH_TempIn, 10);

// Temp debugging of the DHT11 sensor
Serial.println("DHTxx test!");

void loop() {

// Reading DHT11 temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
int h = dht.readHumidity();
int humidity = h * 1.25; // Correction multiplier
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");

// Read the input on each pin, convert the reading, and set each field to be sent to ThingSpeak.

// On Arduino: 0 - 1023 maps to 0 - 5 volts
float pinVoltage = analogRead(A0) * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
float TMP36 = (pinVoltage - 0.5) * 100 * 9 / 5 + 32;
//Print Temperatures
Serial.print ("Getting temperatures...

Serial.print("TMP36... Room Temperature....");
float HPwhTempOut = sensors.getTempF(HPWH_TempOut);
float HPwhTempIn = sensors.getTempF(HPWH_TempIn);
float DWHTempOut = sensors.getTempF(DWH_TempOut);
float DWHTempIn = sensors.getTempF(DWH_TempIn);

Serial.print("Heat Pump Water Temp out is:(Field 2)");
Serial.print("F: ");


Serial.print("Heat Pump Water Temp in is: (Field 3)");
Serial.print("F: ");


Serial.print("Water tank Temp out is: (Field 4)");
Serial.print("F: ");


Serial.print("Water tank Temp in is: (Field 5)");
Serial.print("F: ");


Serial.print("Humidity: ");
Serial.println(" %RH");
Serial.print("DHT11 Temperature: ");
Serial.println(" *F\t");

// The following lines of code convert the DHT11 individual values to strings that ThingSpeak can us

/*//The following lines of code convert DS19B20 to a string value that ThingSpeak can use
String(HPwhTempOut,DEC); // ThingSpeak Field 2
String(HPwhTempIn, DEC); // ThingSpeak Field 3
String(DWHTempOut, DEC); // ThingSpeak Field 4
String(DWHTempIn, DEC); // ThingSpeak Field 5
/*char buffer[12];
String tempStr=dtostrf(HPwhTempOut,6,2,buffer);
String tempStr2=dtostrf(HPwhTempIn,6,2,buffer);
String tempStr3=dtostrf(DWHTempOut,6,2,buffer);
//pinVoltage = analogRead(A1) * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);





// pinVoltage = analogRead(A7) * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);

// Write the fields that you've set all at once.
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

delay(20000); // ThingSpeak will only accept updates every 15 seconds.

July 4, 2016
12:47 am

Forum Posts: 261
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

Have you tried setting DWHTempIn to a fixed value and testing if that updates correctly?  Are you sure you have enabled channels 4 and 5 on your thingspeak channel and that the value is within the range you set? 

Does it work if you disable the DHT11 and send only the DS1820 temps?

I've not used the arduino TS client but these may narrow down the problem a bit.


(You may wish to change your API key now that you've posted the old one to the internet...)

July 4, 2016
11:04 am
New Member
Forum Posts: 3
Member Since:
July 3, 2016
sp_UserOfflineSmall Offline

Thanks for looking at this.  I tried to set DWHTemp to a fixed value and uncomment it and that did not work.

When I disable the DHT11 temp I can include 1 more DS18B20 sensor and get it to show in a ThingSpeak Field for a total of 5 fields.

That made me think there is a limit to 4 - 5 Fields without changing some parameter.

I then created a sketch with 8 identical analog Fields. None presented to ThingSpeak.

I then eliminated all but the first Field and it showed 1 field on ThingSpeak.... 

I then included 1 more and tested out the presentation.  2 fields presented.

I than kept incrementing the number of fields included in the sketch and when I got to 5 none were presenting / updating.

This is consistent with what I'm experiencing in the original sketch.  This indicates to me that it isn't' an issue of String configuration, as I tried the above test with and without the variable being labeled as a String.

Any thoughts or guidance would be very much appreciated.

July 4, 2016
3:50 pm
New Member
Forum Posts: 3
Member Since:
July 3, 2016
sp_UserOfflineSmall Offline

I got the WriteMultipleVoltages sketch to produce 8 fields so it has something to do with the digital reads..... Damn.  DS18B20's are more accurate than TMS36s.

July 4, 2016
10:50 pm

Forum Posts: 261
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

Thats weird.. maybe its a memory corruption problem or something with the Thingspeak arduino client. Or maybe the total length of the data being sent exceeds some preset limit and gets chopped off.

Is it that it only sends field1 to field5 or will it work with, say, field3 to field8?


Unfortunately Thingspeak doesnt have a debug console so you can view.  You might try saving the return code from writeFields() and printing it out to see if you can spot a pattern


Otherwise you might be forced to hack into the source code. According to if you locate the file ThingSpeak.h on your computer and add


Near the other define statements it might produce some helpful comments.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

celinabw2, FitoSprayscroma, LunnonGor, lancevl16, bernicenk60, veronicadq18

Administrators: Hans: 387, lee: 457