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)