Sensors not working/triggers wont save


#42

First delete the widgets from the dashboard. try this code:

//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>


// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

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

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
#define VIRTUAL_CHANNEL_1 1
#define VIRTUAL_CHANNEL_2 2
#define VIRTUAL_CHANNEL_3 3
#define VIRTUAL_CHANNEL_4 4

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

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

// Assign the unique addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress  ColdStorage1Thermometer = { 0x28, 0xFF, 0xAC, 0xCF, 0x02, 0x17, 0x04, 0x55 };
DeviceAddress  CooldStorage2Thermometer = { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress  ColdStorage3Thermometer = { 0X28, 0xFF, 0x34, 0x58, 0x02, 0x17, 0x05, 0xE5 };
DeviceAddress  GH1Thermometer        =   { 0x28 , 0xFF, 0xA2, 0xCD, 0x02, 0x17, 0x03, 0x73 };

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution( ColdStorage1Thermometer, 10);
  sensors.setResolution( CooldStorage2Thermometer, 10);
  sensors.setResolution(ColdStorage3Thermometer, 10);
  sensors.setResolution(GH1Thermometer, 10);
}


void loop(void)
{
  Cayenne.loop();
}

CAYENNE_OUT_DEFAULT()
{
  float tempC1 = sensors.getTempC(ColdStorage1Thermometer);
  if (tempC1 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC1);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_1, tempC1);
  }
  float tempC2 = sensors.getTempC(CooldStorage2Thermometer);
  if (tempC2 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC2);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_2, tempC2);
  }
  float tempC3 = sensors.getTempC(ColdStorage3Thermometer);
  if (tempC3 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC3);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_3, tempC3);
  }
  float tempC4 = sensors.getTempC(GH1Thermometer);
  if (tempC4 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC4);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_4, tempC4);
  }

}

This should auto add new green temporary widgets to your dashboard. Add them by clicking +


#43

the above sketch did add two widgets but not other two dont appear to be responding to temperature change


#44

Check you serial monitor if you are getting Error getting temperature


#46

me bad


#47

can you try the previous code again without the cayenne code and see if you can get reading from all the sensor.


#48

I am back been out of town and had a host of problems with ethernet board and bad arduino board. Went back and sensors are all getting a reading. Loaded your last code it did add 4 wingets i saved them but do not respond to temperature change.
Dave


#49

it shows 85 degrees on all four and the room is 70 degrees tried warming them up no response


#50

can you start from fresh? first follow this tutorial (replace the esp8266 with arduino) and try getting reading from each sensor. Do not add the cayenne code. https://randomnerdtutorials.com/esp32-with-multiple-ds18b20-temperature-sensors/


#51


Went thru both tutorials again earlier and this last one as you see all four sensors are reading and adjust to temperature change working fine. But when i go back to your code to get me working with cayenne i get this

I need to get this working plus alerts by oct first as i will be going in for cervical surgery and will be out of commission for some time
dave


#52

can you share the code you are using for getting sensor reading without the cayenne code (Serial monitor code)


#53

Here is code i used off tutorial you sent and all sensors working.

/*

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is connected to pin 3
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with a OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);

DeviceAddress sensor1 = { 0x28, 0xFF, 0xAC, 0xCF, 0x02, 0x17, 0x04, 0x55};
DeviceAddress sensor2 = { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress sensor3= { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress sensor4= { 0x28 , 0xFF, 0xA2, 0xCD, 0x02, 0x17, 0x03, 0x73 };
void setup(void){
Serial.begin(115200);
sensors.begin();
}

void loop(void){
Serial.print(“Requesting temperatures…”);
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println(“DONE”);

Serial.print("Sensor 1(*C): “);
Serial.print(sensors.getTempC(sensor1));
Serial.print(” Sensor 1(*F): ");
Serial.println(sensors.getTempF(sensor1));

Serial.print("Sensor 2(*C): “);
Serial.print(sensors.getTempC(sensor2));
Serial.print(” Sensor 2(*F): ");
Serial.println(sensors.getTempF(sensor2));

Serial.print("Sensor 3(*C): “);
Serial.print(sensors.getTempC(sensor3));
Serial.print(” Sensor 3(*F): ");
Serial.println(sensors.getTempF(sensor3));

Serial.print("Sensor 4(*C): “);
Serial.print(sensors.getTempC(sensor4));
Serial.print(” Sensor 4(*F): ");
Serial.println(sensors.getTempF(sensor4));

delay(2000);
}


#54

also the code along with cayenne code?


#55


shramiksalgaonkar
Community Manager

24d

First delete the widgets from the dashboard. try this code:

//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>


// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

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

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
#define VIRTUAL_CHANNEL_1 1
#define VIRTUAL_CHANNEL_2 2
#define VIRTUAL_CHANNEL_3 3
#define VIRTUAL_CHANNEL_4 4

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

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

// Assign the unique addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress  ColdStorage1Thermometer = { 0x28, 0xFF, 0xAC, 0xCF, 0x02, 0x17, 0x04, 0x55 };
DeviceAddress  CooldStorage2Thermometer = { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress  ColdStorage3Thermometer = { 0X28, 0xFF, 0x34, 0x58, 0x02, 0x17, 0x05, 0xE5 };
DeviceAddress  GH1Thermometer        =   { 0x28 , 0xFF, 0xA2, 0xCD, 0x02, 0x17, 0x03, 0x73 };

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution( ColdStorage1Thermometer, 10);
  sensors.setResolution( CooldStorage2Thermometer, 10);
  sensors.setResolution(ColdStorage3Thermometer, 10);
  sensors.setResolution(GH1Thermometer, 10);
}


void loop(void)
{
  Cayenne.loop();
}

CAYENNE_OUT_DEFAULT()
{
  float tempC1 = sensors.getTempC(ColdStorage1Thermometer);
  if (tempC1 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC1);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_1, tempC1);
  }
  float tempC2 = sensors.getTempC(CooldStorage2Thermometer);
  if (tempC2 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC2);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_2, tempC2);
  }
  float tempC3 = sensors.getTempC(ColdStorage3Thermometer);
  if (tempC3 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC3);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_3, tempC3);
  }
  float tempC4 = sensors.getTempC(GH1Thermometer);
  if (tempC4 == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC4);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_4, tempC4);
  }

#56

i made changes to the code you gave above. Give it a try:

/*

  Rui Santos
  Complete Project Details https://randomnerdtutorials.com
*/
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTEthernet.h>
#define VIRTUAL_CHANNEL_1 1
#define VIRTUAL_CHANNEL_2 2
#define VIRTUAL_CHANNEL_3 3
#define VIRTUAL_CHANNEL_4 4
unsigned long lastMillis = 0;
float tempC1;
float tempC2;
float tempC3;
float tempC4;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";
// Data wire is connected to pin 3
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with a OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);

DeviceAddress sensor1 = { 0x28, 0xFF, 0xAC, 0xCF, 0x02, 0x17, 0x04, 0x55};
DeviceAddress sensor2 = { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress sensor3 = { 0x28, 0xFF, 0x6E, 0xED, 0x02, 0x17, 0x03, 0x00 };
DeviceAddress sensor4 = { 0x28 , 0xFF, 0xA2, 0xCD, 0x02, 0x17, 0x03, 0x73 };
void setup() {
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID);

  sensors.begin();
}

void loop() {
  Cayenne.loop(5);
  if (millis() - lastMillis > 10000) {
    lastMillis = millis();
    Serial.print("Requesting temperatures…");
    sensors.requestTemperatures(); // Send the command to get temperatures
    Serial.println("DONE");

    tempC1 = sensors.getTempC(sensor1);
    Serial.print(tempC1);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_1, tempC1);
    tempC2 = sensors.getTempC(sensor2);
    Serial.print(tempC2);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_2, tempC2);
    tempC3 = sensors.getTempC(sensor3);
    Serial.print(tempC3);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_3, tempC3);
    tempC4 = sensors.getTempC(sensor4);
    Serial.print(tempC4);
    Cayenne.celsiusWrite(VIRTUAL_CHANNEL_4, tempC4);


    delay(2000);
  }
}

#57

Yahoo sensors working thanks a lot, but have doubles on dash board see pic. Set up email alert on sensor 1 does not send alert might have something to do with double channels cant seem to get rid of them when i save the temp winget it adds second but still leaves orginal temp under channel.


#58

got the double channel problem to go away still problems with notifications


#59

can you provide more details on notification issue, also share a screenshot of the trigger.


#60

Getting no tex or email room is 69-70 degrees set for notiofication if gets below 33 and over 60 degrees F. The code is set up for celsius but went into settings and changed to Farenheit
here are screen shot of triggers. Should give alert for over 60


#61

on left sidebar, still double widget name appear?


#62

no, did you get screen shot of triggers loaded them bur did not come thru