Sensors not working/triggers wont save


#22

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
#define VIRTUAL_CHANNEL 1
#define VIRTUAL_CHANNEL 2
#define VIRTUAL_CHANNEL 3
#define VIRTUAL_CHANNEL 4
i did only picking up channel 3, tried manually did not seem to work


#23

can you post the entire code you used and i hope you are using the code to read 3 sensor.


#24

code was in previous text


#25

you need to use this code to read data from all 3 sensors.
and change:

to

#define VIRTUAL_CHANNEL_1 1
#define VIRTUAL_CHANNEL_2 2
#define VIRTUAL_CHANNEL_3 3
#define VIRTUAL_CHANNEL_4 4

#26

Here it is do i need to go to bottom and add other three sensors?


#27

can you answer this question:

in the above code where is the part for reading data from all 3 sensor?


#28

At the bottom, i thought one wire some how did that, Here is sketch below but does not verifyIget this error??

Arduino: 1.8.3 (Windows 7), Board: "Arduino/Genuino Uno
C:\Users\Home Laptop\Documents\Arduino\onewirecs18\onewirecs18.ino: In function ‘void OutputHandler4(Request&)’:
onewirecs18:66: error: expected ‘)’ before ‘sensors’
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,1 sensors.getTempFByIndex(0));
^
onewirecs18:67: error: expected ‘)’ before ‘sensors’
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,2 sensors.getTempFByIndex(0));
^
onewirecs18:68: error: expected ‘)’ before ‘sensors’
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,3 sensors.getTempFByIndex(0));
^
onewirecs18:69: error: expected ‘)’ before ‘sensors’
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,4 sensors.getTempFByIndex(0));
^
exit status 1
expected ‘)’ before ‘sensors’
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

// This Arduino sketch reads DS18B20 “1-Wire” digital
// temperature sensors.
// Copyright © 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

#include <OneWire.h>
#include <DallasTemperature.h>
//#include <CayenneMQTTEthernet.h>
#include <CayenneMQTTEthernetW5500.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = “bd4a1000-a9d3-11e6-82ee-87310fcf8579”;
char password[] = “bada44eda9a38dd862c5a1afc0809579a6d882a9”;
char clientID[] = “09709a20-6a81-11e8-a76a-fdebb8d0010d”;

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
#define VIRTUAL_CHANNEL 1
#define VIRTUAL_CHANNEL 2
#define VIRTUAL_CHANNEL 3
#define VIRTUAL_CHANNEL 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);
// Start up the library
Cayenne.begin(username, password, clientID);
sensors.begin();

}

void loop(void)
{
Cayenne.loop();
}
// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL)
{

// Send the command to get temperatures.
sensors.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Channel.
// Cayenne.celsiusWrite(VIRTUAL_CHANNEL, sensors.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,1 sensors.getTempFByIndex(0));
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,2 sensors.getTempFByIndex(0));
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,3 sensors.getTempFByIndex(0));
Cayenne.fahrenheitWrite(VIRTUAL_CHANNEL,4 sensors.getTempFByIndex(0));
}


#29

what does this code do?


#30

I thought it would read data from all four sensors. I am not a coder trying to learn but i am a 63 year old dum ass i dont see or cant find any examples of one wire for more then one sensor to try to cut and paste . so I am stuck


#31

sorry sir, give me some time i will have a working code for you in 5 minutes.


#32

Give this code a try. i have not tested it. Add your MQTT credentials.

//  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(VIRTUAL_CHANNEL)
{
  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);
  }

}

#33

Thanks for code I wish i knew more sorry i am such a pain i love what you guys are doing i only know enough to make me dangerous LOL. So code verified fine loaded on to uno fine but cant get online now I am using ethernet W5500 changed code <CayenneEthernetW5500.h> reloaded but still cant get online
Dave


#34

open your Serial monitor and check what is causing the problem.


#35

got it back online shows one sensor #3 so manually added three more only #1 shows temp and it is not responsive to temperature change. Cell phone still shows sensor 3 and not responsive either.
4sensors


#36

can you share your serial monitor?


#37

serial monitor is blank


#38

set baud rate to 9600.


#39

it is at 9600


#40

Did your code upload successfully. make sure you select the correct port while uploading.


#41

didn’t right port when trying to view serial monitor here is the screen shotserialmon