I have problems with my code for a weather station ... I have 3 components Dallas OneWire .. a DS18B20, a DS2423 as a counter and a DS2450, with 4 outputs A / N ... DS2423 and DS2450, works well with the corresponding libraries from Joe Bechter ... These libraries use <Arduino.h> and <OneWire.h> ... On the other hand, the DS18B20 works with <OneWire.h> and <DallasTemperature.h> ..... it gets complicated when you want to have them all 3 on the same wire one wire, because in this case the DS18B20 goes into error at -127 ° C .... logical because the variable One wire are not not defined the same way in the 2 bookstores .. Has anyone ever had such problems ??? is there a way to solve this without rewriting the 2 libraries
Please post your code and attach a schematic. The problem may exist somewhere other than expected.
I am blocked by the forum to send all the bookstores Dallas OneWire, DS18B20, DS2423, DS2450, <Arduino.h> and <OneWire.h> as well as my sketch ... which is very heavy. but my question is mainly related to the compatibility problems of libraries that joe Bechter and associated with a DS18s20 already old and I can not adapt for a DS18B20 ....
If your actual project is too large to post and contains too much irrelevant code, then post a MCVE. This is a short, complete program that successfully compiles and demonstrates the problem you're seeing. But, it should contain no more code than absolutely necessary to achieve this.
EDIT:
Also provide a web link to this "bookstore".
I do not see how decreasing and reducing the code will help to understand my problem ... all my parts of code work well, even together ... I do not have a code error .... problem only appears when I plug the 3 DS from Dallas ... My problem comes from the fact that the library of the DS has been written by another author and that the ONeWire variables are not unified in the libraries DS18B20 and the DS 2450 and 2423 .... Thank you for responding if you master the Dallas OneWire...
richardpub:
My problem comes from the fact that the library of the DS has been written by another author and that the ONeWire variables are not unified in the libraries DS18B20 and the DS 2450 and 2423
My guess is that’s not the problem. Rather, I’m thinking it may be how you address the temperature sensor when it’s not the only device on the OneWire bus. You didn’t say if you’re using the milesburton temperature library. But, if you are, the typical Noob approach of ‘getTempFByIndex()’ or ‘getTempCByIndex()’ may fail depending on the actual ROM contents of all the devices.
But, I can’t test that theory because you seem unwilling to put in a little effort to make a concise example that demonstrates the problem. So, you obviously know better and must be able to solve the issue yourself.
Making a concise piece of code that just talks to the 3 sensors is an obvious de bugging strategy and eliminates all other possibilites; no one wants to wander through a mass of code; I hate looking at other peoples code and won't bother if its more than a few lines ( I have a life too).
With simple code you can easily get each working on its own, get a print of each address, try running two , or two on different pins to see where the problem lies; then post on here!!
If you are using multiple "one wire" sensors, it makes sense to use their specific addresses.
Thank you for your advice, I will put their address to chacon my sensors, and make a program to simplify for the reading of my 3 Dallas oneWire .... I should actually better understand the problem. My current version comes from the resolution of many other worries and I did not think to block at this level ....
and like 8 sensors on my station, your way of analyzing is really good ...
I left with the libraries Onewire and Dallas temperature and the simple example code of DallasTemperature, and with this simple code, it does not support the presence of DS2450 etr DS2423 on the wire onewire, while discovered with discovery of these same library , I display my 3 components onewire well ..... Will I have to rewrite a simpler library for the temperature ?? Yet DallasTemperature suited me really well with the possibility of refining the result ....
The simple example uses the 'getTempCByIndex()' function. That could be the problem. Go back and read what I wrote in Reply #6.
As a test, try the same setup but use 'getTempC()' and pass this function a pointer to the ACTUAL OneWire ROM Address for the DS18B20.
Also......
You should probably replace the 'requestTemperatures()' call with 'requestTemperaturesByAddress()'. Again, pass it a pointer to the correct OneWire ROM Address.
Actually the scanner of OneWire devices gives this:
~~ Scanner 1-Wire ~~
Found 20 28 FC 08 00 00 00 63 (DS2450): Quad channel A/D converter
Found 28 FF 85 D7 61 16 03 7C (DS18B20): Programmable resolution digital thermometer
Found 1D 9B 42 05 00 00 00 61 (DS2423): 4Kb NVRAM memory with external counters
End of Scan.
76/5000
and as soon as I connect something other than the DS18B20, my skit first finds 20 28 FC 08 00 00 00 63 (DS2450) and reading is impossible ....
I can not assign the fixed address of the device .... have to go through insideThermometer or deviceAddress ...
Thank you for your patience.....
Simple.pde (1.2 KB)
Did you ACTUALLY TRY the test I suggested in Replies 10 and 11?
If so, show the actual code you used. DON'T attach the file. Post it directly using CODE TAGS.
in the "simple" example I can not find the function 'getTempCByIndex ()'. I only have getTempC.
Copup I do not understand "As a test, try the same configuration but use 'getTempC ()'".
and to pass this function to a pointer to the ROM address ACTUAL OneWire for the DS18B20, I do not know in which format I have to manage a fixed address .....
I do not know how to replace the "requestTemperatures ()" call with "requestTemperaturesByAddress ()". (This variable is set in DallasTemperature.h and in what format should I return the correct OneWire ROM address.
But it is surely the right solution to put a fixed address ...
I have trouble making this part of the simple code active:
// Assign address manually. The addresses below will be changed
// to valid device addresses on your bus. Device address can be retrieved
// by using either oneWire.search (deviceAddress) or individually via
// sensors.getAddress (deviceAddress, index)
// Note that you will need to use your specific address here
// insideThermometer = {0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0};
// Method 1:
// Search for devices on the bus and assign based on an index. Ideally,
// you would have to go to this place
// use these addresses and manually assign them (see above)
// the devices on your bus (and assuming they do not change).
if (! sensors.getAddress (insideThermometer, 0)) Serial.println ("Unable to find address for Device 0");
// method 2: search ()
// search () looks for the next device. Returns 1 if a new address has been
// returned. A zero might mean that the bus is short, there are no devices,
// or you have already retrieved all of them. It might be a good idea
// check the CRC to make sure you did not get garbage. The order is
// deterministic. You will always get the same devices in the same order
//
// Must be called before search ()
//oneWire.reset_search ();
// assigns the first address found to insideThermometer
// if (! oneWire.search (insideThermometer)) Serial.println ("Unable to find address for insideThermometer");
Sorry for my beginner question on this forum, but how are we using CODE TAGS?
richardpub:
in the "simple" example I can not find the function 'getTempCByIndex ()'. I only have getTempC.
This is the file you attached to your previous post. Scroll down to the bottom:
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/*
* The setup function. We only start the sensors here
*/
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
/*
* Main function, get and show the temperature
*/
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
// After we got the temperatures, we can print them here.
// We use the function ByIndex, and as an example get the temperature from the first sensor only.
Serial.print("Temperature for the device 1 (index 0) is: ");
Serial.println(sensors.getTempCByIndex(0)); // <---------------------- RIGHT THERE -------------------
}
richardpub:
Sorry for my beginner question on this forum, but how are we using CODE TAGS?
There is a "sticky" topic at the top of every forum page: Read this before posting a programming question .... As the name implies, you should have read that before posting your questions. Read it now and scroll down to Item #6.
In the interest of bringing this rather drawn-out thread to a conclusion, let me suggest a simpler solution: Instantiate two OneWire buses on different GPIO pins. Place the DS18B20 device(s) alone on one of these buses. Put your DS2423 and DS2450 devices on the other bus (assuming that you've already confirmed these two devices play nicely together on the same bus).
Once you point to various libraries to the appropriate bus, things should work.
I tried with the single multibus example of Dallas temperature, and with this method I have the 3 devices with of course only the temperature of DS18B20, the other two devices can not be read with Dallas temperature ...
Dallas Temperature Multiple Bus Cont rol Library Simple Demo
============Ready with 3 Sensors================
Request ing temperatures ... DONE
Temperature ' 0< CO" sensor 0 '" - 127 . 00
Temperat ure ' 0< CO" sensor , '" 25 . 50
Temp erature ' 0< CO" sensor , '" - 127 . 00
I do not quite see how to separate the DS18B20, from the other two devices, because all three use the OneWire library, and I could not indicate in the same scketch different Bus addresses .....
Cordially....
richardpub:
I do not quite see how to separate the DS18B20, from the other two devices, because all three use the OneWire library, and I could not indicate in the same scketch different Bus addresses .....
Like I said, just instantiate two objects of the OneWire class using two different processor pins:
#include <OneWire.h>
const uint8_t ds18b20Pin = 2;
const uint8_t ds24xxPin = 3;
OneWire ds18b20Bus(ds18b20Pin);
OneWire ds24xxBus(ds24xxPin);
void setup() {
}
void loop() {
}
ok thanks for this advice, I do as much as possible ...