Tag Archives: Node-Red strangeness

Node-Red Strangeness

node

THIS ONE  HAS BEEN SOLVED – SEE “SOLUTION”.

I freely admit to being utterly stumped. Having spent the day getting node-red on the Blackberry Pi2 I’ve made this simple page… an MQTT message coming in is passed out… and also goes to GPIO 0. This works – send a 1 in the message – the LED comes on – send a 0, the LED goes off. The litttle indicator below GPIO 0 shows the 1 or the 0.

TCP in… I’m using NETIO on my phone to sent a TCP package with 1 or 0 in it.  The TCP reply is necessary or NETIO won’t respond. Send a 0 via TCP – and the light goes off (if, say turned on by MQTT).

Lovely.

But – send 1 via TCP and the light flashes ever so briefly – ending up OFF – even though the little indicator on GPIO 0 says 1.

It’s as if the 1 command I’m sending from the phone is being followed by a 0.

The other strange thing about GPIO is that if you send a blank message or a space from MQTT it also turns off – it’s only supposed to be affected by 1 or 0.

SOLUTION:

Well, it turns out that any whitespace or a RETURN sent to the GPIO module – turns the output OFF – how DAFT is THAT? The solution was simple.. filter whitespace out of the incoming TCP signal.

 

var newMsg = { payload: msg.payload.trim() };
return newMsg;

 

And here it is in action…

 

image

Facebooktwittergoogle_pluspinterestlinkedin