= Node-RED Node-RED can be used with the Gateworks SBCs. Typically, Node-RED may actually run on a server machine and the Gateworks SBC acts as a client and talks back to the server. Or, Node-RED can be install on the Gateworks SBC itself. = Install Node-RED on Gateworks SBC Doing the below commands will make the Gateworks SBC act as the 'server' {{{ sudo apt-get update sudo apt-get install mosquitto #if wanting to use the MQTT protocol to talk to client sudo apt-get install nodejs #beware Ubuntu default may be 10.19, and it would be better to use a newer version sudo apt-get install npm #get the node package manager sudo npm install -g --unsafe-perm node-red #install node-red using npm node-red }}} Once node-red is running, use a browser to open the node-red gui on port 1880. * eg http://122.24.11.93:1880/ [[Image(nodered.png,600px)]] = Create a Client on Gateworks SBC {{{ sudo apt-get update sudo apt-get install python #if wanting to use the MQTT protocol to talk to client sudo apt-get install nodejs #beware Ubuntu default may be 10.19, and it would be better to use a newer version }}} Then, create a python script (example below) to send MQTT messages from the client SBC to the server SBC. == Gateworks Python Script to send MQTT Messages {{{ root@focal-venice:~# cat gateworks.py # Compatible with python 2.* version import sys import os.path import json import time import random import paho.mqtt.client as mqtt from datetime import datetime def callbackMessage(msg): if msg: print("\n--- Command Message Received ---") print(str(msg['ack'])) print(str(msg['ackId'])) print(str(msg['command'])) print(str(msg['uniqueId'])) def callbackTwinMessage(msg): if msg: print("\n--- Twin Message Received ---") print(json.dumps(msg)) def main(argv): while True: try: env = "enter_evn_name_here" uniqueId = "enter_device_id_here_example_device1" cpId = "enter_company_id_here_from_avnet_portal" print("in loop") client = mqtt.Client("clientone") broker = "122.24.11.93" client.connect(broker) client.subscribe("house/bulbs") client.publish("house/bulbs","OFF") print("done publishing") except Exception as ex: print(ex.message) sys.exit(0) time.sleep(10) if __name__ == "__main__": main(sys.argv) }}}