Node-red, raspberry pi and arduino communication issues

I'm not at brewery now to update the code.
i did mess with timing. made it longer and made it shorter.
right now i have it at 200 ms
i figured more readings per second would give me a decent average with the good readings.
i need to split the messages up in node red. so i can have something like msg.ferm1, msg.ferm2 .....
then i need to split the actual data "ferm1 : 88" so i can send the numerical value to a smooth node or something then send to the ui_gauge node

i also messed with the bit section. since the ds18b20 is 9,10,11, and 12 bit resolutions. i played with that a little. I probably should slow down and not make to many changes lol
but i did change speed first. then i cycled through the bit settings to ensure i had best bit setting with sensor and time.
they really didnt do much other then when at 12 bit settings the actual temps where reporting cooler then they should be.

ok now this may be a crazy thought.
so we are using the onewire protocol to get the data from the sensors.
that actual number is in celcious.
then in program we are converting that data into Fahrenheit using the dallaswire library.
maybe i should just change it to only give me the celcious data, and then i can convert that in nodered before it goes to the gauge.
the arduino will be doing less as far as communication goes.
how ever in the code it self it displays the "-127" if it gets a bad reading. and that is part of the onewire library. in other words.
is switching it to Fahrenheit causing a missmatch reading from the actual sensors because of the added step with reading the temps.
im assuming when pulling reading its not gonna hold that one sensors data till its done with calculations. and that may be whats causing the issue.
i lost myself did i loos you on this one?

Again I'm only guessing since I don't have any 1-wire sensors. Could there be a power issue?
Does the arduino have an independent power supply or is it powered from the PC USB (when we have seen it works) or the Raspberry Pi (when it has problems).
Is it the same USB cable?
You could try disconnecting each sensor in turn and see if the other three give a reliable reading.

I don't know why converting to farenheit would cause a problem, but using celsius would eliminate the conversion code in the arduino.

It has an independent 5 volt power supply connected to it.
that was actually the first thing i omitted as a problem.
i initially had all 7 sensors hooked up directly to the raspberry pi. but i had a lot of issues with it not finding the sensors at all.
so thats why im using the arduino for the fermenter room.
this spot in the coding how would it be changed to only give the raw data from sensor.
" } else {
return(DallasTemperature::toFahrenheit(tempC));
}
"
would it just say return (tempc) like this
"

} else {
return(tempC);
}
"

this is section im talking about..

To use celsius I think you could eliminate the printTemperature() function and do this

    float glycoltemp =  sensors.getTempC(glycol);
    float ferm1temp =  sensors.getTempC(ferm1);
    float ferm2temp =  sensors.getTempC(ferm2);
    float ferm3temp =  sensors.getTempC(ferm3);

that would replace the section just above in your reply?
so instead of float printTemperature(device.......

#include <OneWire.h>
#include <ArduinoJson.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 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 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 ferm1 = { 0x28, 0x9D, 0xFD, 0x07, 0xD6, 0x01, 0x3C, 0x38 };//0x28, 0x9D, 0xFD, 0x07, 0xD6, 0x01, 0x3C, 0x38
DeviceAddress ferm2 = {0x28, 0xAA, 0x5A, 0x07, 0xD6, 0x01, 0x3C, 0x32 };
DeviceAddress ferm3 = { 0x28, 0x1B, 0x55, 0x07, 0xD6, 0x01, 0x3C, 0x6D };
DeviceAddress glycol = { 0x28, 0xD9, 0xD7, 0x96, 0xF0, 0x01, 0x3C, 0xFF };//0x28, 0xD9, 0xD7, 0x96, 0xF0, 0x01, 0x3C, 0xFF
//DeviceAddress dogHouse3Thermometer = { 0x28, 0x9B, 0xE1, 0x96, 0xF0, 0x01, 0x3C, 0xFC };

void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
// sensors.setResolution(ferm1, 10);
sensors.setResolution(ferm1, 10);
sensors.setResolution(ferm2, 10);
sensors.setResolution(ferm3, 10);
sensors.setResolution(glycol, 10);
}

//float printTemperature(DeviceAddress deviceAddress)
//{
  //float tempC = sensors.getTempC(deviceAddress);
  //if (tempC == -127.00) {
 //   return(-127.00);
 // } else {
 //   return(DallasTemperature::toFahrenheit(tempC));
 // }
//}

void loop() {
  delay(1000);
    StaticJsonBuffer<400> jBuffer;
    JsonObject& mydata = jBuffer.createObject();
   
  sensors.requestTemperatures();
  
    float glycoltemp = printTemperature(glycol);
    float ferm1temp =  printTemperature(ferm1);
    float ferm2temp =  printTemperature(ferm2);
    float ferm3temp =  printTemperature(ferm3);
    
    mydata["ferm1"] =  ferm1temp;
    mydata["ferm2"] =  ferm2temp;
    mydata["ferm3"] =  ferm3temp;
    mydata["glycol"] = glycoltemp;
    
    mydata.prettyPrintTo(Serial);   
    Serial.println();
}

the way above or

#include <OneWire.h>
#include <ArduinoJson.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 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 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 ferm1 = { 0x28, 0x9D, 0xFD, 0x07, 0xD6, 0x01, 0x3C, 0x38 };//0x28, 0x9D, 0xFD, 0x07, 0xD6, 0x01, 0x3C, 0x38
DeviceAddress ferm2 = {0x28, 0xAA, 0x5A, 0x07, 0xD6, 0x01, 0x3C, 0x32 };
DeviceAddress ferm3 = { 0x28, 0x1B, 0x55, 0x07, 0xD6, 0x01, 0x3C, 0x6D };
DeviceAddress glycol = { 0x28, 0xD9, 0xD7, 0x96, 0xF0, 0x01, 0x3C, 0xFF };//0x28, 0xD9, 0xD7, 0x96, 0xF0, 0x01, 0x3C, 0xFF
//DeviceAddress dogHouse3Thermometer = { 0x28, 0x9B, 0xE1, 0x96, 0xF0, 0x01, 0x3C, 0xFC };

void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
// sensors.setResolution(ferm1, 10);
sensors.setResolution(ferm1, 10);
sensors.setResolution(ferm2, 10);
sensors.setResolution(ferm3, 10);
sensors.setResolution(glycol, 10);
}

//float printTemperature(DeviceAddress deviceAddress)
//{
  //float tempC = sensors.getTempC(deviceAddress);
  //if (tempC == -127.00) {
 //   return(-127.00);
 // } else {
 //   return(DallasTemperature::toFahrenheit(tempC));
 // }
//}

void loop() {
  delay(1000);
    StaticJsonBuffer<400> jBuffer;
    JsonObject& mydata = jBuffer.createObject();
   
  sensors.requestTemperatures();
  
    float glycoltemp = sensors.getTempC(glycol);
    float ferm1temp =  sensors.getTempC(ferm1);
    float ferm2temp =  sensors.getTempC(ferm2);
    float ferm3temp =  sensors.getTempC(ferm3);
    
    mydata["ferm1"] =  ferm1temp;
    mydata["ferm2"] =  ferm2temp;
    mydata["ferm3"] =  ferm3temp;
    mydata["glycol"] = glycoltemp;
    
    mydata.prettyPrintTo(Serial);   
    Serial.println();
}

Hmm. Try it and see. :smiley: One of those alternatives won't compile!

If I remember right a -127 means the reading failed so you should ignore that, donā€™t send it to the Node-red at all (why bother) and just go and do another reading.

1 Like

how would i code it to ignore the errors and only send valid info to serial

ok , man human error is so fatal!
well i have now wired all sensors straight to the pi.
i was originally using braided wire 18 gauge. that was obviously the reason why i couldn't get 7 sensors to work. they are all now wired in parallel with Phone wire.
I was still getting messed up readings on a couple of sensors then it would randomly changed to other sensors. However while i was getting the "bad numbers" the Gauge was in the proper position.
so i dug further in. while doing the conversion from Celsius to Fahrenheit I forgot to round to 2 decimals.
So everything is working now like it should , and i need to figure out the temp control side of it.
here is dashboard now. thanks a S ton for the help guys.
Oh, and i made sure i had the latest Node-red installed also that made a difference and stability.
I also changed witch ds18b20 node i was using and i no longer have Node Red resetting


cheers

So I have them all connected to the pi now.
Working but I get bad readings still.
Someone mentioned using extra pull up resistors closer to the sensors.

  1. What size resistor should I use for those.
  2. How would I wire this up.
  3. How do those actually help, what are they doing....
    Thanks

In the arduino code check the reading and see it is equal to -127 and ignore it if it is.

I'm actually not using arduino now,
By using the proper size lines the raspberry pi sees them all.
I need to fugue out to replace bad readings in node red.
I'm using the smoothing node. It helps but not when receiving bad readings.
As soon as I get laptop powered up I'll share my current flow.
Cheers

So which ever node you have reading the sensor send the output to a switch node and test the reading and only pass it on if it is not -127.

Not sure how to do that is there an example?
also i am trying to share flow but it has to many characters in it.