Remote operating and Node Red

  • 1
  • Idea
  • Updated 2 days ago
I have always wanted to build a better remote station interface, but I struggle with coding anything beyond "Hello World" and usually even that has a bug or two.  

Several times, I have played with NodeRed on the PI, and I keep coming back to it.  

NodeRed is a GUI based coding platform, much like wiring, and it has great promise.  I do know 1 or 2 hams that are using it, so I am hoping they might jump in and help mentor the rest of us and share some ideas.

https://nodered.org/docs/hardware/raspberrypi

This is what it looks like controlling my simple 4 relay RPI board:



And, this is an export of the code that you can paste into a NodeRed console.  

[{"id":"6fc89136.65404","type":"rpi-gpio out","z":"2c0e83c7.f7ad2c","name":"Relay 3","pin":"31","set":true,"level":"0","freq":"","out":"out","x":380,"y":540,"wires":[]}]

Next, add MQTT to the above to send out messages to other bits, including IOT devices.

At this point, this is about as far as I have gotten, but my goal is a control panel I can read/use on a web page or an iPhone to turn things on or off.

I have seen Dashboards added, reading wattmeters and maybe even handling rotator control too.

Mike 
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes

Posted 7 months ago

  • 1
Photo of Lee

Lee, Elmer

  • 680 Posts
  • 287 Reply Likes
I've been looking at this using ESP 8266 wifi modules and the arduino environment.  Here is a node red example  

https://randomnerdtutorials.com/esp8266-and-node-red-with-mqtt/

The 8266 has multiple digital I/O and an analogue input as well plus an I2C bus and can drive an OLED display.  You can do the "relay control" from a phone or browser without MQTT but MQTT can be configured to receive as well as feed back in a publish/subscribe format with several levels of robustness to understand if the job really got done.  I would love to see I2C enabled in the radio to allow status query and thing like freq query and then set up wif AP wireless intranets around the station off the main router and maybe a rasp pi as a MQTT broker for running relays, like antenna switching or 4 square controllers or turning rotors with positive feed back of the status of the remote device.  The best dev board is the NodeMCU 12E   Here is a web based web server relay control

https://www.instructables.com/id/Control-ESP8266-Over-the-Internet-from-Anywhere/

MQTT servo controller

https://www.instructables.com/id/Simple-IoT-Remote-Switch-With-MQTT-and-ESP8266/ 

There are a million pages and youtube vids on this kind of setup 

Alternatively you could do the radio query over ethernet but more complicated 

I built a band switch capable of being run from Yaesu BCD as an experiment.  The Flex USB puts out Yaesu BCD

73  W9OY
 

Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
Thanks Lee

You are way ahead of me.

But, I did get my basic switch working and a web page built for it.  The learning curve is key, but in about an hour, I now have my basic web interface that even looks good on an iPhone.  If anyone is interested in the very very basics, I'm happy to explain further as I find getting from getting it installed to sort of working is a big jump and all the tutorials have a different focus.    Let me know and I can a video in baby step mode and how it works for us ham operators.

I even added a few hosts to ping to see if they are running.  

This is with 2 relays and I really didn't have to write a single line of code.  Relays 3 and 4 haven't been moved to display on a web page yet.

This is how I created the actual dashboard http://www.steves-internet-guide.com/node-red-dashboard/

Mike va3mw




(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
An update.

I managed to figure out the KPA500 communication and I had some help from some others for the W2 watt meter and the Rotator Controller (thanks N6NU).

The hardware is a Raspberry PI, KMTronic Web Switch, a StarTech USB to 4 Port RS232 controller, KPA500  Amp, an RC-1 RS232 Rotator Controller and a W2 wattmeter.

There is a 'little bit' of Java code for the KPA500 band detection.  I still need to do the Alarms and resets for the Wattmeter and the Amp.  The differences in the wattage are due to calibration and I need to get the Bird wattmeter out and do the calibration (right now, I don't know which one is right! LOL ).

Now I don't have multiple little applications and I can run this from a PC or a mobile device.

Mike va3mw



Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
An update on this.

I feel I have been reasonably succesful with this, especially since I'm not really a programmer and the last time I did some programming, Basic had Line numbers and my $3000 IBM PC booted off single sided floppies.  

I'm headed down the path of now being able to do things like:

  • IF Amp is turned on in Operate mode and if RF Power of Flex radio is greater than 25 watts, set drive to 25 watts on radio.
  • Or, if RF power of radio is set higher than 26 watts as example (maybe that is my maximum RF drive), send a command to move the Amp into a StandBy state
  • Or, if, in the CW portion of the band, set mode automatically to CW
  • Or, if the PA Temp on the Amp is starting to climb maybe reduce the RF drive level of the radio.
What is great with using NodeRed is the ability to make it look like 1 big RF solution.

I haven't done any of the above yet, but it can be done with limited programming skills.  Maybe over the coming days I'll get it done.

Anyone else want to play?  I know of 2 others who are working to streamline their station.

Mike va3mw 


Photo of John - K3MA

John - K3MA

  • 373 Posts
  • 122 Reply Likes
Mike

Thanks for your work and sharing.  I already have a reasonably good control interface but it can always be better.  And it fun to play with new tools.  A couple questions I have that you might be able to answer.

1) Does Node Red interface with the Digital Logger Web Switch?  https://www.amazon.com/Web-Power-Switch-Pro-Model/dp/B0765NCB2L/ref=asc_df_B0765NCB2L/?tag=hyprod-20&linkCode=df0&hvadid=228860412633&hvpos=1o1&hvnetw=g&hvrand=8963734946813561216&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1024840&hvtargid=pla-377660188761&psc=1

2) Does Node Red have capability to intercept from the Flex and send UDP info to devices like the Palstar HFAuto?

3) Is there voice control capability like Alexa control?

Thanks, John K3MA
(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
Hi John

If the Digital Logger Web switch can be commanded via an API or something similar, I would say yes.  You  may want to look in the NodeRed repository and see if anyone else has done it.  

Yes, it could.  I am already querying the radio for RF power and such.  This is a big advantage of the Flex  product and their API's.

No idea, as I don't do any remote connections such as that.  Again, you could ask in the NodeRed user group and I am sure someone has played with it already.

Mike va3mw
Photo of David Decoons wo2x

David Decoons wo2x, Elmer

  • 1443 Posts
  • 309 Reply Likes
John

I have the DLI Web Switch Pro working fine now.

Also you can parse the radio frequency and send it out as a UDP broadcast (I haven't done it since I no longer have the HF Auto).

Dave wo2x
Photo of Steve K9ZW

Steve K9ZW, Elmer

  • 1554 Posts
  • 768 Reply Likes
@Michael - Just set up Node-Red on a Linux box to experiment with the environment.  Looks great!

Would appreciate a step-by-step guide on how you did your implementation.  Thinking this could be a very fine way to handle some of the things I want to do in an integrated fashion.

Thank you for pointing out the possibilities of Code-Red to the community and sharing you implementation!  

73

Steve
K9ZW

Blog:  http://k9zw.wordpress.com 
(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
Hi Steve

If you got it running, that is great.  

I think the next step is to build some of your own flows and see if you can get a GPIO port to turn on and off.  

Since all our HAM stuff is generally RS232 (except Flex Radios which does LAN based communication), what is it that you want to control?  Let me know and I can help you get started.  If it is RS232, there are some Palettes, you'll need to install.  

The Palettes are the plug ins to do things.  You will need the Dashboard palette.  And the Serial (RS232) one.  

See if you can get those loaded and then share with us what you want to control.

Mike
Photo of David Decoons wo2x

David Decoons wo2x, Elmer

  • 1445 Posts
  • 309 Reply Likes
Hi all,

To revive the topic of Node Red, I've been out on medical leave and needed something to take my mind off my recovery. So I worked on my Node Red project.

Node Red is software I am running on a Raspberry Pi 3B plugged in my network. I've interfaced it to my Flex 6600, Elecraft KPA1500, Yaesu G1000dxa rotor with Idiom Press serial card, and my DLI Web Switch Pro network controllable outlet strip.

This gives me a simple web page to provide control and status of the various equipment. It also allows controlling equipment without the need for a PC to be on. We all know a bad Windows update can wreak havoc on a remote station depending on a PC.

The only band I need a tuner on is 80 and I set up the KPA1500 to memorize settings every 20 kHz.

My antenna switching is done via a SainSmart USB8 board connected to a W2IHY 1x4 antenna switch and antenna switching follows active TX slice on radio. So amp is set to have tuner active on 80 and only use antenna 1 out.

Here is a screenshot of Node Red as seen in a normal web browser. When using a Smartphone such as my iPhone XS each section is stacked vertically so I only need to scroll down the page to the section I want. Very handy when operating remote.

I have some more work to do and will probably add rest commands to allow shortcuts in Node Red to radio functions such as preprogrammed memories, profiles, etc.

Always fun! And thanks to Mike Walker, VA3MW and Andreas Junge, N6NU for getting me started and providing some guidance along the way.

73
Dave wo2x





Photo of Alan

Alan

  • 55 Posts
  • 10 Reply Likes
Hi Mike

Well...you got me hooked!

I do not have a Rasberry Pi, so I loaded up Debian Linux on my Mac using Parallels which created a virtual Rasberry Pi.

Next, I loaded up Node-Red simply by running the script in Debian terminal shown on the Node-Red website.

So far using Node-Red, I connected to the Flex Server, I created a switch to control the GPIO pins on a Rasberry, loaded the Dashboard Pallet and made a simple switch on the dashboard (very ugly, not as pretty as others on this page).

I ordered a real Raspberry Pi and relay board from Amazon.

My first goal is to control eight relays for various functions in the station using a web interface.  I really do not like using Apple HomeKit and Node-Red as a more refined remote solution.

Ok, I was able to connect to the Flex 6600 Server, but could not figure out how to do anything useful.  Could you or others give me an example of how to set up Node-Red to send a Flex Command and display the result?


Alan
WA9WUD


(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
That is awesome!!  Nice job.  

What I liked about playing with Node-red is that it was easy to make progress and be successful.


Case in point.

I added 2 temperature probes to my RPI so that I could see and be alerted if the cooling fans in my remote case failed.  

But, first, I need to be able to read the LM75s could be imported into the Dashboard.

The LM75 uses the I2C buss and getting them working is well documented.  http://www.pibits.net/code/raspberry-pi-and-lm75-temperature-sensor-example.php

But, I needed to be able to just see the temperature.  I had to make sure I2C was working on the RPI and what 'address' they were using.  Again, Google.   There are other Temperature probes like the bmp180, bmp280, bme280 and more (https://www.adafruit.com/product/2652).  

Then, I found this code, which I could never write on my own to pull the temperature from the probe (I am going to strip this line apart so I understand it later this week).

sudo i2cget -y 1 0x48 0x00 w |awk '{printf("%0.1f C\n",(a=((("0x"substr($1,5,2)substr($1,3,1))*0.0625)+0.1) )>128?a-256:a)}'

That turned into this using the Node-red Exec box (you paste the above in the Exec).  That means you want Node-Red to Execute the command on the RPI which is a Linux operating system.  



And, then using the Dashboard tools (for others to see how it is done).  This is called a Pallet and you will need to install it https://flows.nodered.org/node/node-red-dashboard.  This is the tool that helps you to be so successful to create a web interface.

Now, I can monitor the temperature in my case, and even write some more actions to turn fans on and off.  




Here is my flow in case you want to look at it.  I added the I2C scan stuff.

[{"id":"e91d7619.a8a808","type":"tab","label":"Temps","disabled":false,"info":""},{"id":"ebd6490b.83a8d8","type":"inject","z":"e91d7619.a8a808","name":"","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":true,"onceDelay":0.1,"x":147,"y":95,"wires":[["94bd0a6b.717018","962dd4e9.d622d8"]]},{"id":"94bd0a6b.717018","type":"exec","z":"e91d7619.a8a808","command":"sudo i2cget -y 1 0x48 0x00 w |awk '{printf(\"%0.1f C\\n\",(a=(((\"0x\"substr($1,5,2)substr($1,3,1))*0.0625)+0.1) )>128?a-256:a)}'","addpay":false,"append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"Temp","x":431,"y":130.5,"wires":[["3f59295f.8041e6","fb9bbee7.2754c"],[],[]]},{"id":"962dd4e9.d622d8","type":"exec","z":"e91d7619.a8a808","command":"sudo i2cget -y 1 0x4a 0x00 w |awk '{printf(\"%0.1f C\\n\",(a=(((\"0x\"substr($1,5,2)substr($1,3,1))*0.0625)+0.1) )>128?a-256:a)}'","addpay":false,"append":"","useSpawn":"false","timer":"10","oldrc":false,"name":"Temp","x":435,"y":216,"wires":[["f04cc7b4.eb6988","98197d69.8d7c3"],[],[]]},{"id":"3f59295f.8041e6","type":"ui_text","z":"e91d7619.a8a808","group":"2dbe67ac.f10de8","order":12,"width":0,"height":0,"name":"","label":"Mid Temp","format":"{{msg.payload}}","layout":"row-spread","x":784,"y":221,"wires":[]},{"id":"f04cc7b4.eb6988","type":"ui_text","z":"e91d7619.a8a808","group":"2dbe67ac.f10de8","order":11,"width":0,"height":0,"name":"","label":"Top Temp","format":"{{msg.payload}}","layout":"row-spread","x":753,"y":309,"wires":[]},{"id":"98197d69.8d7c3","type":"ui_chart","z":"e91d7619.a8a808","name":"","group":"cd1c8110.1e37e","order":1,"width":0,"height":0,"label":"Top Temp","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":778,"y":390,"wires":[[]]},{"id":"fb9bbee7.2754c","type":"ui_chart","z":"e91d7619.a8a808","name":"","group":"cd1c8110.1e37e","order":2,"width":0,"height":0,"label":"Mid Temp","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":791,"y":270,"wires":[[]]},{"id":"7de9d007.be84c","type":"i2c in","z":"e91d7619.a8a808","name":"","address":"74","command":"0","count":"1","x":432.07643127441406,"y":544.6805801391602,"wires":[["a76aec42.2ce13"]]},{"id":"c0ed8a1e.519778","type":"i2c scan","z":"e91d7619.a8a808","x":427.07643127441406,"y":443.72571563720703,"wires":[["a76aec42.2ce13"],[]]},{"id":"7222be8f.680f5","type":"inject","z":"e91d7619.a8a808","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":195.07987213134766,"y":439.9722261428833,"wires":[["c0ed8a1e.519778","7de9d007.be84c"]]},{"id":"a76aec42.2ce13","type":"debug","z":"e91d7619.a8a808","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":717.5277862548828,"y":495.94791412353516,"wires":[]},{"id":"2dbe67ac.f10de8","type":"ui_group","z":"","name":"RF Info","tab":"d6ba9a2a.f3f0d8","order":7,"disp":true,"width":"5","collapse":false},{"id":"cd1c8110.1e37e","type":"ui_group","z":"","name":"Temps","tab":"1abf24f5.9cd13b","disp":false,"width":"8","collapse":false},{"id":"d6ba9a2a.f3f0d8","type":"ui_tab","z":"","name":"VA3MW Shack Control","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"1abf24f5.9cd13b","type":"ui_tab","z":"","name":"RPi Control","icon":"dashboard","order":1}]
(Edited)
Photo of Alan

Alan

  • 55 Posts
  • 10 Reply Likes
Mike

Looks good.

Check this node out for reading temperature sensors like these;

https://www.amazon.com/gp/product/B013GB27HS/ref=ox_sc_act_title_4?smid=ADHH624DX2Q66&psc=1

and

https://www.amazon.com/DS18B20-Temperature-Waterproof-Electronic-Building/dp/B0753VSGP1/ref=as_li_ss...

On a Rasberry Pi:

https://www.youtube.com/watch?v=j7LLVkPpQ78&t=421s

Using this Node-Red Node:

https://flows.nodered.org/node/node-red-contrib-sensor-ds18b20

I found the forums and Flow Library on the Node-Red web site to contain lots of useful information and many "plugin" building blocks for flows.  You can also search for nodes; like I found the DS1820 Temperature Sensor Node.

For example, here is a flow from the Node-Red library for a configurable switch that toggles and changes color:

https://flows.nodered.org/flow/7325d06be6c8a415c877a941172dbc86

The developer incorporated the ability to configure the switch within the function node on the flow.

I looked for "ham radio" flows in the Node-Red library and found a few.  I would suggest we could start populating the Node-Red library with flows for common Flex User devices....like the KAP500 and the wattmeter flows.

The Node-Red Flow Library solves my lack of programming knowledge by allowing me to use building blocks containing code written by others.

Alan


(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 936 Posts
  • 269 Reply Likes
Hi Alan

I have used those devices on my Arduino for a weather station.  I think those require an A/D converter on the RPI and I forgot how many of those there are on  RPI3.  

I wanted the I2C ones so that I could have a whole bunch on the 'buss'.  I think with the ones I use I can more than I will ever use as there is 3 binary bits that you can solder on the board.

Lots of options too.  

We have been discussing where to host the Node-Red stuff we want to share and should it be on GIT or Node-Red Flows.  I think GIT makes more sense so that you can easily modify and share your own version.  Personally, I think I will use GIT for my stuff.

Mike
Photo of N2WQ

N2WQ

  • 15 Posts
  • 3 Reply Likes
How do you guys monitor the RX/TX state to prevent hot switching? How about some sort of conflict resolution for SO2R or when accessing from multiple clients?
Photo of Michael Walker

Michael Walker, Employee

  • 935 Posts
  • 267 Reply Likes
Hi Rudy

I don't, but then, I am the only user and I don't hot switch.  :)  When I change bands, I stop for 10 seconds and check Antenna settings and RF power settings.  That comes from blowing a few things up at 3 in the morning.  At least any current equipment today has amazing protection built-in, and the Flex radios are no exception.  

However, since all the status of the radio is available by doing a TCP connection to the radio, you could script it then do some lockouts.

As for SO2R and multiple clients, I haven't tested that at all personally.  Others are playing with it, so you might want to ask in the main community as they might miss it in this thread.

FRStack has some of these features http://www.mkcmsoftware.com/Flex/Index.  I think that Carl N4PY's Pegasus may also have some features to help with that. http://www.n4py.com/.  And, both Authors are active on the community here and have been known to make changes to improve the user interaction.  Check out the features on both.

Both of those programs have some very slick add ons.  

I also know we have a significant number of stations that have our radios but have their own members who program.  They have done some cool stuff, but they choose not to share it since they don't want to have to support it.  With the right person, you could actually write your own GUI.


Mike
Photo of N2WQ

N2WQ

  • 15 Posts
  • 3 Reply Likes
Mike, is there a ham Node Red community? Perhaps I am over-engineering switching, but chances are others are thinking of such issues. Was thinking of using MQTT messages that go into a buffer that will take care of multi-client conflicts...but who knows, there might be easier solutions.
Photo of Michael Walker

Michael Walker, Employee

  • 935 Posts
  • 267 Reply Likes
To the best of my knowledge, this is it but I haven't really searched.  I  posted about it once in the Facebook ham radio group that has over 20,000 members  and no one had heard about it.   

Andreas N6NUis doing the most to the best of my knowledge.  He is using MQTT to share data to muliple stations and offloading the RPI of data.  I only use MQTT to move the Rotator Data.