I want to create a GUI using processing to display 3 temperature probes I have connected to my Arduino.
I am able to get Processing to read the data. I have not seen anything about how to display this data in a window with text.
Any help I can get would be greatly appreciated. I am a very new to this program.
Example of the serial data processing is getting from the println. 3 printsof it.
70.25
70.25
70.25
70.2570
.2570.25
70.25
70.25
70.25
Thanks
Phil
Processing code:
// Example by Tom Igoe
import processing.serial.*;
PFont f;
Serial myPort; // The serial port
void setup() {
// List all the available serial ports:
size(480, 480);
println(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[1], 9600);
f = createFont("Arial",16,true);
}
void draw() {
background(255);
textFont(f,16);
fill(0);
text("TEMPERATURES:",10,50);
text("Temp 1:",10,100);
text("Temp 2:",10,150);
text("Temp 3:",10,200);
while (myPort.available() > 0) {
String inBuffer = myPort.readString();
if (inBuffer != null) {
println(inBuffer);
}
}
}
Arduino Code:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// 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.
DeviceAddress T1 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA };
DeviceAddress T2 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA };
DeviceAddress T3 = { 0x28, 0x0E, 0xFF, 0xE9, 0x03, 0x00, 0x00, 0xFA };
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(T1, 10);
sensors.setResolution(T2, 10);
sensors.setResolution(T3, 10);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print(" Error");
} else {
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(void)
{
delay(2000);
sensors.requestTemperatures();
printTemperature(T1);
printTemperature(T2);
printTemperature(T3);
}
1