Jump to content
Sign in to follow this  
rwblinn

MQTT IO-4 v2 Input No Message

Recommended Posts

Hi,

using Node-RED - trying to MQTT listen to input state changes of an IO-4 v2 bricklet having a push-button connected to channel 1 configured as input pull-up.

Issue: When pushing the button, no MQTT message is received - see 2).

Tested first in the Brick Viewer 2.4.11 and the value changes for channel from low to high when pressing the push-button.

Node-RED Nodes Configuration

1) mqtt in with topic tinkerforge/#. Messages are received (see below test channel 0 as output)

Tested OK (MQTT message received) the IO-4 state change of channel 0 (output) - led connected - using in a function node with msg.payload input true or false

//Bricklet: IO-4 - Example to set pin 0 high | low
var brickletUID = "G4d";
var topicPrefix = "tinkerforge/request/io4_v2_bricklet/";
var topicSuffix = "/set_configuration";

msg.topic = topicPrefix+brickletUID+topicSuffix;
msg.payload = {"channel": 0, "direction": "out", "value": msg.payload};
node.status({text:"State:"+msg.payload.value});

return msg;  

2) Channel 1 as Input with a push-button connected.

Configured a function node as follows - no MQTT message received when pushing the button

//IO-4 - example set callback configuration
var brickletUID = "G4d";
var topicPrefixRequest = "tinkerforge/request/io4_v2_bricklet/";
var topicPrefixRegister = "tinkerforge/register/io4_v2_bricklet/";

msg.topic = topicPrefixRequest+brickletUID+"/set_configuration";
msg.payload = {"channel": 1, "direction": "i", "value":true}; 
node.send(msg);

msg.topic = topicPrefixRequest+brickletUID+"/set_all_input_value_callback_configuration";
msg.payload = {"period": 0, "value_has_to_change": true}; 
node.send(msg);

msg.topic = topicPrefixRegister+brickletUID+"/all_input_value";
msg.payload = {"register":true}; 
node.send(msg);

msg.topic = topicPrefixRequest+brickletUID+"/get_configuration";
msg.payload = {"channel":1}; 
node.send(msg);

What is wrong in the configuration?

Share this post


Link to post
Share on other sites

Hi,

msg.topic = topicPrefixRequest+brickletUID+"/set_all_input_value_callback_configuration";
msg.payload = {"period": 0, "value_has_to_change": true}; 
node.send(msg);

A period of 0 disables the callback, you have to set it to (at least) 1.

Share this post


Link to post
Share on other sites

Got it - overlooked the documentation "A value of 0 turns the callback off." = got mis leaded by the default value 0 (period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0).

After changing, its working fine.

Thanks for the swift help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...