Search

Register

Thanks for signing-up! You will receive an email with further instructions to activate your account!

username already taken
You already have an account? .

Login

Forgot password?
Don't have an account yet? Register now for using the UI-Designer and the forum or creating projects.
Login to create topics and posts!



NodeRed and Arduino

#1 March 17, 2020 00:54:37 by meccip

NodeRed and Arduino

Hello,
First, I hope i find all of you well regarding the COVID19 problem !!

My question is about node red and arduino connection, it is not about netIO.

So, i have this code in arduino that communicate with netIO, my question is can I use this code with nodered to send and receive data like in netIO ?

Any info about this is welcome.
Thank you.

...........

void androidInterface() {
int index = 0; // reading the socket IF
char Remote[BUFSIZ];
EthernetClient clientApp = androidServer.available();
if (clientApp) {
if (clientApp.connected()) {
while (clientApp.available()) {
char c = clientApp.read();
if (c != '\n' && c != '\r') { // no linefeed or CR, so keep reading
Remote[index] = c;
index++;
if (index >= BUFSIZ)
index = BUFSIZ -1;
continue;
}
Remote[index] = 0;
}

if (strstr(Remote, "led1state")) {
if (LED_state[0]==0) { // send switch initialize back to NetIO APP
clientApp.println("led1stateoff");
}
if (LED_state[0]==1) { // send switch initialize back to NetIO APP
clientApp.println("led1stateon");
}
}
if (strstr(Remote, "led1on")) {
clientApp.println("OK");
LED_state[0]=1;
}
if (strstr(Remote, "led1off")) {
clientApp.println("OK");
LED_state[0]=0;
}

} // end of if clientApp.connected
} // end of if clientApp
} // end of android interface function

#2 March 19, 2020 01:39:15 by meccip

NodeRed and Arduino

I managed to turn on/off the LED with a simple node red switch and tcp request node. (send “led1on” when switch is pressed)
I got stuck with state reading.
How to get led state and write to switch node to know when it is on or off ?
Any ideas will be nice.