I am using 2 sensors ( photo resistor and temperature, in the middle is just LED and buzzer regarding on the response change with photo resistor sensor) and would like to put up on the gauge and chart in the dashboard. Right now, the reading reads in line with comma in between, the chart is combining them up which makes them unstable and gauge is only showing for 1 sensor. how could I separate and do different reading, gauge and chart for each sensor? Below is the arduino code and node red.
arduino:
int sensePin = 0;
int ledPin = 9;
int val;
int tempPin = 1;
const int buzzer = 12;
void setup()
{
pinMode(ledPin, OUTPUT);
analogReference(DEFAULT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// read the sensor
int val = analogRead(sensePin);
if(val < 960)
{
digitalWrite(ledPin, HIGH);
tone(buzzer, 1000);
}
else
{
digitalWrite(ledPin, LOW);
noTone(buzzer);
}
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float farh = (cel*9)/5 + 32;
Serial.print(cel);
Serial.print("*C , ");
Serial.println(analogRead(sensePin));
delay(1000);
}
node-red:
[{"id":"155d5a28.f6d206","type":"debug","z":"ef68beb7.75aa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":382,"y":196,"wires":[]},{"id":"99c64bbb.3ec6a8","type":"ui_text","z":"ef68beb7.75aa","group":"9aaba0ca.eddc2","order":0,"width":"0","height":"0","name":"","label":"PHOTORESISTOR, TEMPERATURE","format":"{{msg.payload}}","layout":"row-left","x":458,"y":103,"wires":[]},{"id":"792451eb.62aaa","type":"ui_gauge","z":"ef68beb7.75aa","name":"","group":"9aaba0ca.eddc2","order":0,"width":0,"height":0,"gtype":"gage","title":"direction","label":"units","format":"{{value}}","min":0,"max":"2000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"1000","seg2":"1500","x":358,"y":45,"wires":[]},{"id":"15dee299.b5ad8d","type":"ui_chart","z":"ef68beb7.75aa","name":"","group":"9aaba0ca.eddc2","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"bezier","nodata":"","dot":false,"ymin":"0","ymax":"1000","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"1","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":354,"y":420,"wires":[[],[]]},{"id":"e6a955df.4030b8","type":"serial in","z":"ef68beb7.75aa","name":"","serial":"2365f3c7.2d0b6c","x":159,"y":244,"wires":[["792451eb.62aaa","99c64bbb.3ec6a8","155d5a28.f6d206","15dee299.b5ad8d","9f39afc.9482e5"]]},{"id":"9f39afc.9482e5","type":"serial out","z":"ef68beb7.75aa","name":"","serial":"2365f3c7.2d0b6c","x":350,"y":289,"wires":[]},{"id":"9aaba0ca.eddc2","type":"ui_group","z":"","name":"SENSORS","tab":"c326fe58.3d375","order":1,"disp":true,"width":"14","collapse":false},{"id":"2365f3c7.2d0b6c","type":"serial-port","z":"","serialport":"COM3","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"c326fe58.3d375","type":"ui_tab","z":"","name":"READING","icon":"dashboard"}]