Hello, I am kinda new to Photon and have read the documentation on the firmware, but the examples I found are not complete and do not seem to work.
I have two photons one as a temp server and the other as a display. I want to use UDP to send data between the two.
The temp code is, right now it just has a temp number in it:
UDP Udp;
IPAddress ipAddress = '192.168.1.4';
int port = 23;
void setup() {
pinMode(D2, INPUT);
Particle.variable("tempHotWater", &fahrenheit, DOUBLE);
Serial.begin(115200);
Udp.begin(23);
}
void loop() {
Serial.println(WiFi.localIP());
Serial.println("Sending");
int c = 66;
Udp.beginPacket(ipAddress, port);
Udp.write(c);
Serial.println(Udp.endPacket());
delay(1000);
}
Display Photon:
UDP Udp;
void setup() {
Serial.begin(9600);
Udp.begin(0);
tempDisplay.begin(0x70);
}
void loop() {
Serial.println("Hottub Display");
Serial.println(WiFi.localIP());
Serial.println(Udp.parsePacket());
Udp.parsePacket();
Serial.println("Read");
// Read first char of data received
int temp = Udp.read();
// Ignore other chars
Udp.flush();
Serial.println(temp);
tempDisplay.print(temp, DEC);
// Now push out to the display the new values that were set above.
tempDisplay.writeDisplay();
delay(3000);
}
All I get on the display is -1 or error, the Temp photon seems to send it as the sending code returned is 1.
I cannot seem to find any complete examples on how to do this between two photons. I am not sure why it doesnt display the number I put in from the temp photon.
These are the latest photons and firmware. Any assistance would be appreciated. Thanks, Chris