Hello i've made 2 other post about this already but i still don't have the solution.
I am trying to send data from my arduino to the nodemcu with the use of Serial Communication.
If the Nodemcu receives the data it will put a message on a site.
Arduino void loop:
void loop()
{
unsigned int Pos;
int data=50;
int data1=60;
if(s.available()>0)
//
pixy.line.getAllFeatures(); //get line features
if (pixy.line.barcodes) // detected road sign
{
int code = pixy.line.barcodes[0].m_code;
Serial.println(code);
switch(code)
{
s.write(data);
s.write(data1);
Dont worry about the barcodes thats the pixy2 camera its part of my project.
Heres the Nodemcu void loop:
void loop() {
s.write("s");
if (s.available()>0)
if (!client.connected()) {
reconnect();
}
client.loop();
data=s.read();
if (data <= 20) {
unsigned long now = millis();
++value;
snprintf (msg, MSG_BUFFER_SIZE, "HIGHERT #%ld", value);
Serial.print("Publish message: ");
Serial.println(msg);
client.publish("Senne123", msg);
}
if (!client.connected()) {
reconnect();
}
client.loop();
data1=s.read();
if (data1 <= 60) {
unsigned long now = millis();
++value;
snprintf (msg, MSG_BUFFER_SIZE, "LOWERT #%ld", value);
Serial.print("Publish message: ");
Serial.println(msg);
client.publish("Senne123", msg);
}
}
It keeps on putting both messages on the site, HIGHERT and LOWERT. Is there any other way that i can read from the serial monitor ?
I've been working on this for 2 months already and still didn't find the solution. Every bit of help will be appreciated.