[SOLVED] Read/write I/O Moxa ioLogik1242 using node-red

Hi,

I’m making a little project, and consist in to read the moisture and temperature. Both variables are analogic (4-20 mA), and i’m using a Moxa ioLogik. The model is 1242, and have DI, DO and AI.

I read the ioLogik with node-red, and then deploy the flow. I could create a dashboard. Until there all is perfect.

Now, i want to write in the iologik. I want to set on/off using the switch widget in one of the DO, but i can’t do it. The Ubidot_In connection it’s ok, but doesn’t write anything.

Thanks

Dear Jose, here’s a recent thread that might help: Ubidots_in - fail return value - the Ubidots_In problem was solved by updating the NodeRED version. Can you check if this is something that might be happening on your side?

Looking forward to hear about your integration with the Moxa ioLogik. It would be the first time (that we know of) integrating this device, so feel free to share further details on how you achieved the integration.

Hi,

Sorry, but today was a long day.
I update the node-red version and… all collapse. In resume, i was to do a new virtual machine; and I had some troubles to solve.

Well, all are running. I installed the last version, and i’m using now node version 12.18.1 and npm 6.14.5; but the error is the same, i connect the signal of the switch.

To test i did a flow with only a “ubidots_in” an a debug.
The flow is:
[{“id”:“379aa47b.fdcf1c”,“type”:“tab”,“label”:“Flow 1”,“disabled”:false,“info”:""},{“id”:“ff771797.c1a038”,“type”:“ubidots_in”,“z”:“379aa47b.fdcf1c”,“tier”:“educational”,“name”:“Ubidots in”,“token”:“BBFF-LRtkKVPzp9Mmft4iwmSqwNf4aCB7we”,“device_label”:“iologik”,“tls_checkbox_in”:true,“custom_topic_checkbox”:false,“label_variable_1”:“encendido”,“label_variable_2”:“humedad”,“label_variable_3”:"",“label_variable_4”:"",“label_variable_5”:"",“label_variable_6”:"",“label_variable_7”:"",“label_variable_8”:"",“label_variable_9”:"",“label_variable_10”:"",“checkbox_variable_1_last_value”:true,“checkbox_variable_2_last_value”:true,“checkbox_variable_3_last_value”:true,“checkbox_variable_4_last_value”:true,“checkbox_variable_5_last_value”:true,“checkbox_variable_6_last_value”:true,“checkbox_variable_7_last_value”:true,“checkbox_variable_8_last_value”:true,“checkbox_variable_9_last_value”:true,“checkbox_variable_10_last_value”:true,“x”:280,“y”:700,“wires”:[[“5579c22d.ee873c”]]},{“id”:“5579c22d.ee873c”,“type”:“debug”,“z”:“379aa47b.fdcf1c”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“false”,“x”:520,“y”:700,“wires”:[]}]

About the integration.
First all, i don’t have a large knowledge in programming, and the protocol MQTT is new for me.
I connect a moisture and temperature sensor to the AI of iologik 1242, both channel are 4-20mA. The scale is 0-80°C for temperature and for the moisture is 0-100ppm; with these parameters i configurated the ioLogik 1242.
Then i did two tests, one connecting directly the iologik to my computer and the other using a cellular modem (a Moxa OnCell 3150). I used a gateway (ioserver) to check the data. All successful.

Then, i did flow in node red. I configurated a “modbus getter” node to read the data. This was ok.

The first time i try to connect the “modbus getter” directly to the “ubidots_out”; but in the side of ubidots i couldn’t see anything. Obviously, the message didn’t have the structure that needs the system.
I resolved this with a function node, with the right configuration, connected to “ubidots_out” and the i could achieve the connection with ubidots.

The next step was to do a Dashboard. This is the link of the dashboard if you want to see:
https://industrial.ubidots.com/app/dashboards/public/dashboard/jERk2r9Zk-QkAwNq82PV2Fjyf5I

In the attached word you can see the complete flow in node-red.

Th following steps are:

  1. Incorporate to the dashboard a switch widget to on/off a digital output of the iologik (yes, my actual problem).
  2. Read digital input. For the moment only i can read 0/1, but in the dashboard, i want to associate a digital input and a alarm. For example, if i read a 0 all it’s ok, but if change to 1 i want to display a message like “overflow alarm”.

Thanks for the support

1 Like

Hello @jrahumadag,

Thank you for sharing your flow so I could inspect what was wrong and why the subscription didn’t work as expected. To this, although you have a STEM account, the type of account is still “Ubidots” within the nodes configuration (for both publish and subscription) and not “Ubidots for Education”, which is intended for Ubidots former education platform, soon to be shut down and completely replaced by the STEM.
Here’s a screenshot of the proper configuration and demonstration (to the right) that the Ubidots_in node works with your account (see last 4 characters of the token)

Now, as an advise, please delete the token you shared in the flow clipboard json and create a new one to prevent people from using it maliciously and avoid damages to your data and account.

Also, please make sure to read the expected output of the Ubidots_in node in its Github repository or within the in-node Docs from node-red.

Best,

–David

HI David,

First all, thanks to the advise. I changed the token.

When i open an account, i did using an education account. Few week ago i update the account to stem, but i didn’t know that i have to do that change. Thanks for this notice.

I did the change, but the problem still persist. I read the info in the repository of Git Hub, but… no news. To publish info i don’t have any problem, but to suscribe is other thing.

Hi @jrahumadag,

  1. Can you share the subscription portion of your flow making sure NOT to share the token as well?
  2. Can you confirm you’re running node-red (not NodeJS) version >1. You can check this when running/launching node-red command: image
  3. Make sure to be using the nodes latest version v2.0.1. To check that up, head to Hambuger icon (top-right corner) > Manage pallete > See Ubidots nodes.
    node-red-palette

You mentioned in one of your messages that you’re not yet used to MQTT. It is really not a difficult protocol so that’s why I’d like to point some resources that will clarify lots of doubts.
MQTT Essentials by HiveMQ
Ubidots MQTT Docs

Hi David,

About the version of Node-Red:
image

About the latest version:
image

About the flow:
I separated the process in two flowa, one to published an other to suscribe.
I tried to make it easy (suscribe node), that means, two nodes:
[{“id”:“379aa47b.fdcf1c”,“type”:“tab”,“label”:“Flow 1”,“disabled”:false,“info”:""},{“id”:“5579c22d.ee873c”,“type”:“debug”,“z”:“379aa47b.fdcf1c”,“name”:"",“active”:true,“tosidebar”:true,“console”:true,“tostatus”:true,“complete”:“true”,“targetType”:“full”,“x”:500,“y”:700,“wires”:[]},{“id”:“ff771797.c1a038”,“type”:“ubidots_in”,“z”:“379aa47b.fdcf1c”,“tier”:“business”,“name”:“Ubidots_in_iologik”,“token”:“AAAAAA”,“device_label”:“iologik”,“tls_checkbox_in”:true,“custom_topic_checkbox”:false,“label_variable_1”:“Encendido”,“label_variable_2”:"",“label_variable_3”:"",“label_variable_4”:"",“label_variable_5”:"",“label_variable_6”:"",“label_variable_7”:"",“label_variable_8”:"",“label_variable_9”:"",“label_variable_10”:"",“checkbox_variable_1_last_value”:true,“checkbox_variable_2_last_value”:true,“checkbox_variable_3_last_value”:true,“checkbox_variable_4_last_value”:true,“checkbox_variable_5_last_value”:true,“checkbox_variable_6_last_value”:true,“checkbox_variable_7_last_value”:true,“checkbox_variable_8_last_value”:true,“checkbox_variable_9_last_value”:true,“checkbox_variable_10_last_value”:true,“x”:310,“y”:700,“wires”:[[“5579c22d.ee873c”]],“outputLabels”:[“exe”]}]

About MQTT:
Really, i’m using… but i’m learning step by step. To publish in Ubidots i’m using this protocol, but in a low level; with your tutorials i structure the message, because in the beginning i can’t read anything.
Thanks for the other link, i will read it.

And again, thanks for you support.

Hello @jrahumadag,

Thanks for sharing this flow. Based on it, I was able to figure out what’s the issue.
Please keep in mind that the nodes ask you to enter Labels, not Names, and these are always all in lowercase.


So instead of “Encendido”, you need to enter “encendido”. Same logic applies to the fields asking you for a Device Label.
Here’s the corrected flow:

[{"id":"132ae01c.cd07","type":"debug","z":"a3070846.77d4b8","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","x":500,"y":700,"wires":[]},{"id":"e06dcaa0.a08808","type":"ubidots_in","z":"a3070846.77d4b8","tier":"business","name":"Ubidots_in_iologik","token":"aaaaaaa","device_label":"iologik","tls_checkbox_in":true,"custom_topic_checkbox":false,"label_variable_1":"encendido","label_variable_2":"","label_variable_3":"","label_variable_4":"","label_variable_5":"","label_variable_6":"","label_variable_7":"","label_variable_8":"","label_variable_9":"","label_variable_10":"","checkbox_variable_1_last_value":true,"checkbox_variable_2_last_value":true,"checkbox_variable_3_last_value":true,"checkbox_variable_4_last_value":true,"checkbox_variable_5_last_value":true,"checkbox_variable_6_last_value":true,"checkbox_variable_7_last_value":true,"checkbox_variable_8_last_value":true,"checkbox_variable_9_last_value":true,"checkbox_variable_10_last_value":true,"x":310,"y":700,"wires":[["132ae01c.cd07"]],"outputLabels":["exe"]}]

–David

Hi David,

I changed the name of the label, and it’s working.
Seems doesn’nt matters the name of labbel, if in upper or lowercase … but matters

Thanks again for all

@jrahumadag glad to know it worked already. Hope this serves you well for your application with Ubidots.

Hello, how did you read the registers of the analog inputs, I know they are 400321, 400323, etc., how can I read them with node red and send that data through an iot 2050? Thanks