Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

node red rookie questions

joe camilli
joe camilli Member ✭✭
edited December 2019 in SmartSDR for Windows
i am trying to understand how to use node-red to control a SainSmart
16-Channel 12V Relay Module using a Raspberry Pi over i2c. Using the following i2c interface:
Here is the Python code to make it work:
Controlling it with Python

When it comes to scripting languages, python’s really hard to beat.  It’s simple, quick, and you can do almost anything with “import some-module”.

In this case, I’ve made a class called “relay16” – it’s a really simple wrapper around the smbus calls needed to run the PCA9671 part on the I2C-RELAY16 board.   The example code is in the src/RasPi-Python subdirectory of the I2C-RELAY16’s Github project.

Let’s start with the very minimum amount you need to make this work:

#!/usr/bin/python  import smbus  import relay16  import time    bus = smbus.SMBus(1)  address = 0x20    relayBoard = relay16.relay16(bus, address)  relayBoard.setRelay(1)  time.sleep(1)  relayBoard.clearRelay(1)    



Answers

  • Dave Garber
    Dave Garber Member ✭✭
    edited November 2019
    is this Flex related??  not understanding
  • joe camilli
    joe camilli Member ✭✭
    edited November 2019
    Yes the relay switch will be used for my 2x6 matrix antenna switch for use on my 6600
  • Nick RN3KK
    Nick RN3KK Member ✭✭
    edited December 2019
    https://github.com/rn3kk/RemoteSwitcher 16 reLay, web server. All done.
  • W7NIK
    W7NIK Member ✭✭
    edited November 2019
    SainSmart boards are Junk , 2 returned. Fyi
  • Joe N3HEE
    Joe N3HEE Member ✭✭
    edited November 2019
    Joe, you can find more Node Red info and help in the Node Red Thread located here. 

    https://community.flexradio.com/flexradio/topics/remote-operating-and-node-red

    I am using an 8 channel SainSmart relay to control my Six Pak antenna switch.  It is connected directly to my Flex 6600M via usb cable.  I've had no issues with my relay board.  Works great ! 

    Joe
    N3HEE
  • Mike-VA3MW
    Mike-VA3MW Administrator, FlexRadio Employee, Community Manager, Super Elmer, Moderator admin
    edited November 2019
    We have been supporting Node-Red integration for projects just like this for remote station operation.  There is an entire thread regarding it as other have posted.

    Bob, while I appreciate you are trying to be funny, please take a movement and delete your recipe.  

    Mike 
  • Mike-VA3MW
    Mike-VA3MW Administrator, FlexRadio Employee, Community Manager, Super Elmer, Moderator admin
    edited November 2019
    Joe

    What I would do first is to get this working outside of Node-Red with your python scripts.  Once you have that part playing well, you should then be able to call the script from within Node-Red with the ‘exec’ I think.

    I don’t have one to test with, so I can’t help you out much unless I order the board to play with.   My i2c experience is pretty limited to I hook it up and pray it works. :). That being said, I do have 6 temperature gauges on i2c on my Flex 6000 remote control interface.  

    We do have lots of customers using SainSmart devices directly connected to the 6000 series radios with wonderful success.   Others can comment if they have some experience.

    Mike


  • Steve Sterling
    Steve Sterling Member ✭✭
    edited November 2019
    Thanks for the link. Appreciated.
  • joe camilli
    joe camilli Member ✭✭
    edited December 2019
    Michael,

    thanks for the feedback. yes i have the relay working just fine using a python program. The use of i2c in way easier than GPIO.

    Joe N7QPP
  • Mike-VA3MW
    Mike-VA3MW Administrator, FlexRadio Employee, Community Manager, Super Elmer, Moderator admin
    edited November 2019
    Have you now also got Node-Red able to control it by calling your python script?

    As for easier, etc.  I guess it it based on your comfort level. 

    All my Relays are TCP connected to external to the RPI.  That way, if I need to reboot the RPI, the relays don't toggle and shutdown other things in the process.  

    Mike
  • W7NIK
    W7NIK Member ✭✭
    edited November 2019
    I use FOX delta RUSS board and KMtronics, does  not cycle of relays, I have couple connected to the ALS1300 amp , power on and another relay for operate/standby ,  the sainsmart  boards cycle,  the two  work sometimes then it would disappear, restart the computer, work couple more times then it  will lock the relay on . 

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.