Hi at all. I have 10 temperature sensor. Can i connect all sensor with standard onewire bus and utilize only one pin? Please help me.
Hi @marcoscalet, welcome the Cayenne Community, thanks for your question!
As far as Cayenne there is no limitation here, and my understanding of the 1-wire bus is that there is it can address uniquely an effectively unlimited (billions) number of devices. But youâll run into electrical issues at some point with many many devices sharing the same bus.
To answer more practically, yes, 10 should be fine. Weâve done 8 in series all on the same pin in house and had no issues with it. So as long as youâre talking numbers like 8 or 10 or 20, and not hundreds, I think youâll be OK. If you start seeing flakiness in their output, I would step down the number to see where it resolves.
Ok tanks for your reply. Please can you send me a modification of the original sketch for multi sensor in one pin?(for example pin 2)?
Update⌠ok i solved it. You can replicate the part of the sketch with the different virtual pin
Tanks
Hi guys,
I have the same problem with DS80B20 sensors and arduino uno . My project is read 8 sensors from one arduino pin ex.7. I am tired of searching information about it inthe Internet. Everything I was able to read 3 sensors from diferent 3 pins arduino - DS18B20 adding multiple identical sensors arduino uno - #5 by tvj.
Dear rsiegel can you help me fix this problem (sketch) to read 8 sensors with arduino uno,and use it in Canyenne.
Best regards,
Ramunas
ramunas@thek.lt
if you can wait four hours i place the code to connect 8 sensors on one pin only ok?
Hi marcoscalet,
Yes,of course,no problem. Thank You for good news!
// Virtual Pin of the DS18B20 widget.
#define VIRTUAL_PIN1 V1
#define VIRTUAL_PIN2 V2
#define VIRTUAL_PIN3 V3
#define VIRTUAL_PIN4 V4
#define VIRTUAL_PIN5 V5
#define VIRTUAL_PIN6 V6
#define VIRTUAL_PIN7 V7
#define VIRTUAL_PIN8 V8
const int tmpPin1 = 2;
OneWire oneWire1(tmpPin1);
OneWire oneWire2(tmpPin1);
OneWire oneWire3(tmpPin1);
OneWire oneWire4(tmpPin1);
OneWire oneWire5(tmpPin1);
OneWire oneWire6(tmpPin1);
OneWire oneWire7(tmpPin1);
OneWire oneWire8(tmpPin1);
DallasTemperature sensors1(&oneWire1);
DallasTemperature sensors2(&oneWire2);
DallasTemperature sensors3(&oneWire3);
DallasTemperature sensors4(&oneWire4);
DallasTemperature sensors5(&oneWire5);
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors7(&oneWire7);
DallasTemperature sensors8(&oneWire8);
char token = âxxxxxxxxxxxâ;
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
sensors1.begin();
sensors2.begin();
sensors3.begin();
sensors4.begin();
sensors5.begin();
sensors6.begin();
sensors7.begin();
sensors8.begin();
}
void loop()
{
Cayenne.run();
sensors1.requestTemperatures();
float temperatura1 = sensors1.getTempCByIndex(0);
sensors2.requestTemperatures();
float temperatura2 = sensors2.getTempCByIndex(1);
sensors4.requestTemperatures();
float temperatura3 = sensors3.getTempCByIndex(2);
sensors4.requestTemperatures();
float temperatura4 = sensors4.getTempCByIndex(3);
sensors5.requestTemperatures();
float temperatura5 = sensors5.getTempCByIndex(4);
sensors6.requestTemperatures();
float temperatura6 = sensors6.getTempCByIndex(5);
sensors7.requestTemperatures();
float temperatura7 = sensors7.getTempCByIndex(6);
sensors8.requestTemperatures();
float temperatura8 = sensors8.getTempCByIndex(7);
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN1)
{
// Send the command to get temperatures.
sensors1.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN1, sensors1.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN2)
{
// Send the command to get temperatures.
sensors2.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN2, sensors2.getTempCByIndex(1));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN3)
{
// Send the command to get temperatures.
sensors3.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN3, sensors3.getTempCByIndex(2));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN4)
{
// Send the command to get temperatures.
sensors4.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN4, sensors4.getTempCByIndex(3));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN5)
{
// Send the command to get temperatures.
sensors5.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN5, sensors5.getTempCByIndex(4));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN6)
{
// Send the command to get temperatures.
sensors6.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN6, sensors6.getTempCByIndex(5));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN7)
{
// Send the command to get temperatures.
sensors7.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN7, sensors7.getTempCByIndex(6));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN8)
{
// Send the command to get temperatures.
sensors8.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN8, sensors8.getTempCByIndex(7));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
Thank you marcoscalet for sketch.
Or youâve used this sketch? I am doing copy it from you post and paste to IDE, next step - I am doing verify in IDE, and I am geting a lot of errors.Are you can check this skecth in your IDE-copy/paste/verify. If you do not get errors, I think this problem is from copy/paste to internet.If in your IDE all is ok,then you can send me skecth file .ino from (IDE-Sketch-Show Sketch Folder) in email.
Arduino: 1.6.7 (Windows 7), Board: âArduino/Genuino Unoâ
sketch_marcoscalet:3: error: âdefineâ does not name a type
define VIRTUAL_PIN1 V1
^
sketch_marcoscalet:13: error: âOneWireâ does not name a type
OneWire oneWire1(tmpPin1);
^
sketch_marcoscalet:14: error: âOneWireâ does not name a type
OneWire oneWire2(tmpPin1);
^
sketch_marcoscalet:15: error: âOneWireâ does not name a type
OneWire oneWire3(tmpPin1);
^
sketch_marcoscalet:16: error: âOneWireâ does not name a type
OneWire oneWire4(tmpPin1);
^
sketch_marcoscalet:17: error: âOneWireâ does not name a type
⌠.
you must include the libraries
I am included OneWire and DallasTemperature libraries. Let me know what I missed (libraries).
Hi @ramunas
Can you confirm that those libraries are not just added to the Arduino IDE, but also to the beginning of your sketch file in the form of these two lines?
#include <OneWire.h>
#include <DallasTemperature.h>
In the code you posted above, I can see that youâre missing the # character in the line where you define virtual pin V1, which should look like:
#define VIRTUAL_PIN1 V1
If you can send your current sketch file (either post it here or by PM if you prefer), Iâm sure I can help you sort out any remaining errors youâre seeing, if I can see the whole thing at once, try it in my compiler, etc.
Hi rsiegel,
Yes, I think this sketch problem is from simple copy/paste to post , not using performatted text function, and # character is missing like in post marcoscalet. Please verify all sketch and let me know which characters is mising too.
Thanks,
#include <DallasTemperature.h>
#include <OneWire.h>
// Virtual Pin of the DS18B20 widget.
#define VIRTUAL_PIN1 V1
#define VIRTUAL_PIN2 V2
#define VIRTUAL_PIN3 V3
#define VIRTUAL_PIN4 V4
#define VIRTUAL_PIN5 V5
#define VIRTUAL_PIN6 V6
#define VIRTUAL_PIN7 V7
#define VIRTUAL_PIN8 V8
const int tmpPin1 = 2;
OneWire oneWire1(tmpPin1);
OneWire oneWire2(tmpPin1);
OneWire oneWire3(tmpPin1);
OneWire oneWire4(tmpPin1);
OneWire oneWire5(tmpPin1);
OneWire oneWire6(tmpPin1);
OneWire oneWire7(tmpPin1);
OneWire oneWire8(tmpPin1);
DallasTemperature sensors1(&oneWire1);
DallasTemperature sensors2(&oneWire2);
DallasTemperature sensors3(&oneWire3);
DallasTemperature sensors4(&oneWire4);
DallasTemperature sensors5(&oneWire5);
DallasTemperature sensors6(&oneWire6);
DallasTemperature sensors7(&oneWire7);
DallasTemperature sensors8(&oneWire8);
char token[] = "jdpgxxxx";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
sensors1.begin();
sensors2.begin();
sensors3.begin();
sensors4.begin();
sensors5.begin();
sensors6.begin();
sensors7.begin();
sensors8.begin();
}
void loop()
{
Cayenne.run();
sensors1.requestTemperatures();
float temperatura1 = sensors1.getTempCByIndex(0);
sensors2.requestTemperatures();
float temperatura2 = sensors2.getTempCByIndex(1);
sensors4.requestTemperatures();
float temperatura3 = sensors3.getTempCByIndex(2);
sensors4.requestTemperatures();
float temperatura4 = sensors4.getTempCByIndex(3);
sensors5.requestTemperatures();
float temperatura5 = sensors5.getTempCByIndex(4);
sensors6.requestTemperatures();
float temperatura6 = sensors6.getTempCByIndex(5);
sensors7.requestTemperatures();
float temperatura7 = sensors7.getTempCByIndex(6);
sensors8.requestTemperatures();
float temperatura8 = sensors8.getTempCByIndex(7);
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN1)
{
// Send the command to get temperatures.
sensors1.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN1, sensors1.getTempCByIndex(0));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN2)
{
// Send the command to get temperatures.
sensors2.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN2, sensors2.getTempCByIndex(1));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN3)
{
// Send the command to get temperatures.
sensors3.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN3, sensors3.getTempCByIndex(2));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN4)
{
// Send the command to get temperatures.
sensors4.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN4, sensors4.getTempCByIndex(3));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN5)
{
// Send the command to get temperatures.
sensors5.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN5, sensors5.getTempCByIndex(4));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN6)
{
// Send the command to get temperatures.
sensors6.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN6, sensors6.getTempCByIndex(5));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(VIRTUAL_PIN7)
{
// Send the command to get temperatures.
sensors7.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN7, sensors7.getTempCByIndex(6));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
CAYENNE_OUT(VIRTUAL_PIN8)
{
// Send the command to get temperatures.
sensors8.requestTemperatures();
// This command writes the temperature in Celsius to the Virtual Pin.
Cayenne.celsiusWrite(VIRTUAL_PIN8, sensors8.getTempCByIndex(7));
// To send the temperature in Fahrenheit use the corresponding code below.
//Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
}
Hi again @ramunas,
On my system, that file is only missing one line in order to compile properly. Try adding
#include <CayenneEthernet.h>
to the block of include statements at the top of the file. If that still doesnât work for you, let me know what output youâre seeing from error section of the IDE and I can further troubleshoot.
Thank You,after adding #include <CayenneEthernet.h>
everything works fine! Super !
ok now i have a big problem. if âALLARMEâ is set in a value greater than 1 inch. But if I enter into the modification of the trigger itself, as you can see from the picture, the trigger is not set to alarm. âALLARMEâ does not even appear in the list. In fact, even if the value changes to 2 inches not get any email or sms.
the second problem (less important than the first) is the frequesza of renovation. The sensor temperature is updated about 1 time every 5 minutes. even the âALLARMEâ is updated about 1 time every 5 minutes. For what reason?
this is the second arduino mega.
in this case ALLARME appears correctly, but I do not receive similarly, no texting and no email.
Could you show me the detail for of the settings for both ALLARME widgets (the one on AREA VENDITA, and the one on MAGAZZINO)?