Author Topic: i2c RPI Help  (Read 143 times)

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
i2c RPI Help
« on: December 04, 2017, 03:54:51 PM »
I've seen some old posts (as in last year, not super old) about pending i2c support; does anyone know if this has been done?  I'm new to this whole light thing (as in i just started building a Raspberry Pi controller with relays this weekend [yes I know I'm late for a full show this year which is why I'm just doing a small indoor thing and will work on doing a full show for next year]) and even newer to FPP and don't have a whole ton of an idea of what I'm doing with FPP.  Basically my controller uses relay boards attached to an expansion hat (using two MPC23017 chips) where the relays switch power outlets to control dumb lights.  I'd like to try using Vixen to build a sequence that I then run using FPP on the Pi.  Before I installed FPP I was able to get my relay setup to work with some python scripts but I'm not sure how to get FPP to control them.  In one of the posts I saw something about copying a Hill320 controller and I tried doing that but I have no idea what to do from there (or where the outputcontrollers.json file is located that it said i needed to add something to).  So, anyone have any ideas how to get FPP to work with i2c addressing?

Online CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 8,268
  • Kudos: 151
Re: i2c RPI Help
« Reply #1 on: December 05, 2017, 04:09:33 PM »
I just committed a MCP23017 Channel Output to the master-v1.x branch of FPP if you want to test that code.  There isn't any UI for it yet, but I can tell you what to add to the /home/fpp/media/config/channeloutputs.json file or you can check the MCP23017.cpp source file to view a sample config in the header comments.  The Device ID is configurable, so you should be able to use multiple MCP23017's by adding each as a separate FPP Channel Output.
-
Chris

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #2 on: December 05, 2017, 05:14:22 PM »
I'd definitely love to test it. How do I get that code to my pi? Do I have to rebuild it like I did when I first loaded things on to my SD card or is there a way to do it from the fpp interface like the updates?

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #3 on: December 05, 2017, 05:21:38 PM »
I think I figured it out, going to tinker now

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #4 on: December 05, 2017, 05:59:20 PM »
After I add the json file, should I see the outputs in the Output Channel section of the fpp interface or is that part of the "no interface" thing?

Online CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 8,268
  • Kudos: 151
Re: i2c RPI Help
« Reply #5 on: December 05, 2017, 09:24:39 PM »
This output won't show in the UI at all.

To get to the master-v1.x branch you will need to change the web browser URL to go to the /developer.php page and set the branch dropdown to master-v1.x and it will switch branches and compile the master-v1.x code.

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #6 on: December 06, 2017, 05:59:01 AM »
Ah ok, I thought I had gotten it pulled by updating again since I had an MCP2317.cpp but it's possible that I just did too thorough of a job renaming Hill320 to MCP23017 when I tried one of the fixes you had posted last year.  I'll try doing the pull from the dev page later when I get home and see if that helps; then I just have to figure out how to use the testing page and go from there.

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #7 on: December 06, 2017, 06:41:46 PM »
So I rebuilt my fpp to get rid of all the custom stuff i did, updated to the master-v1.x branch, found the MCP23017 cpp file, and used the comments to create an entry in channeloutputs.json.  I then rebooted everything.  I still can't get it to work; not sure if I'm just too much of a n00b and not sure how to do use the Channel Testing page or my test sequence or whether something else is wrong.  I tried adding channel output mapping to move things around and see if that helped.  I tried tinkering with what my starting channel is.  Still nothing.  I'm done for the night lol.  If anyone has any ideas let me know.

Online CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 8,268
  • Kudos: 151
Re: i2c RPI Help
« Reply #8 on: December 06, 2017, 07:28:20 PM »
Have you used the MCP23017 with any test or sample code with the Pi?  Did the wiring pinout match what is in the FPP source file?  I assume it should be the same.

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #9 on: December 07, 2017, 02:51:37 PM »
I have used it with python code on another SD card to test the set up.  I started with this code (which runs as is) from a video I found. https://docs.google.com/document/d/1WDOksXmZK3CoDaLj0Z-FrUwsacQicgz4B4Nf9rcXPKc/mobilebasic

I'm not sure if the pinout matches because I didn't hook up the chip myself, I bought a hat for the pi that had the chips already wired up. The hat I bought is https://www.amazon.com/gp/aw/d/B01MYD2QTP?psc=1&ref=yo_pop_mb_pd

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #10 on: December 07, 2017, 04:33:33 PM »
I'm trying to dig more into the pin out but having trouble reading the schematic (https://github.com/nationelectronics/nationelectronics_schematics/blob/master/RPI-HAT-32IOPE-schematic.pdf) of the hat i got.  I think it might match, but i think it might not.  I'm going to try switching my relays to the other MCP chip and see if that makes a difference. 

Online CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 8,268
  • Kudos: 151
Re: i2c RPI Help
« Reply #11 on: December 07, 2017, 05:25:58 PM »
It should match, I was just curious what you used.

Did you leave the deviceID as 32 (hex 0x20) in the channeloutputs.json file?

Can you check the fppd.log file for any errors in case it couldn't initialize for some reason.  I think I might have a mcp23017 here somewhere but would have to find it and breadboard up a test circuit to test the channel output.

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #12 on: December 08, 2017, 05:46:45 PM »
I had it set to 35 because it was on the second chip which is set to 0x23. I put it back to 0x20 though since I moved them to the first chip.


I'll check the logs tonight or tomorrow, I had to unplug it to move it.

Offline TerpZone

  • Newbie
  • *
  • Join Date: Dec 2017
  • Location:
  • Posts: 11
  • Kudos: 0
Re: i2c RPI Help
« Reply #13 on: December 09, 2017, 11:20:30 AM »
I didn't see any errors in the log (attaching in case i missed something).


Also going to attach the channeloutput.json file just in case i did something wrong (i've tried the starting channel as 1 and as 101)

Online CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 8,268
  • Kudos: 151
Re: i2c RPI Help
« Reply #14 on: December 09, 2017, 12:00:19 PM »
You need to set the enabled flag to 1.    I updated the comment in the .cpp header to reflect this.  Sorry about that...

 

Back to top