piACC Overview

Forums:

Raspberry Pi Accessory Controller

Console Unit

Startup:The initial startup menu.

System Menu

Currently working on the system menu. Will be adding tools and webpages if online.

Light Bar Control Menu

Operate the lightbar via the 4 10amp relays.

Scrolling Graphics

When not operating a menu it will scroll a list of images. (Currently 24)

Original V1

Notes

It has been a few days of playing but I think I have everything working as expected.

I will post up additional info once I have everything set up on the controller pi software-wise, but everything is currently working.
I probably spent too much time playing with the display and layout web page, but every time I had it ready I added something else, like the selectable background images, clock and power button to hide the switch buttons.
Everything is html and the buttons do trigger the relays. For only a few minutes to get them to work, the relays to me were impressive that they worked without little effort at all. I did not do a toggle on a single switch, each relay has a relay off and relay on button. I do not believe it would much to do via javascript to toggle them just like I do the switch table though.
I will probably do a single toggle and change the button image for on/off in the future.
There is also not much error checking or hardening of it.. if any at all. I will also need to add some error handling and possibly a password unlock to get into it if I get really ambitious.
For now it is just light controllers but I am sure in the near future I will be adding some additional pages and options.

Background Image Transition Button

Note: since there are 23 images, they are the majority of the file size of 8MB. You can probably get it down to under 1 MB if you simply delete the background images. I may do that in the future for faster downloads and make the image folder separate. Again, please be sure to respect the image authors and only use them if you have their permission from Jeep. I will be removing the images from the download as soon as I can compile a new package.
You can use the background image to step through the background image for the controller.

As these were used for testing only, I (or you) will have to replace them with my own images since they are probably copyrited by Jeep. I simply pulled them from the Jeep website because I thought they are some very nice images! (I wouldn't mind having one of those new 2018 Wranglers.. but I do love my 2017 Willy's!)
Here is the unit itself. It is a base Raspberry Pi 3 with wifi and blue tooth built in.
(approx $35 US)
I have added a four relay board from Micro Centers ($35 US) rated at 10amp per relay. It is basically plug and play on the gpio pins. The nice thing abourt this board is that it also has passthru gpio pins so I was able to plug the 7 inch touch display to the relay board pins.

Web Server

It is running flask for a simple web page on port 5000. I will probably change the port though.

Added folder to /pi/bin
Run the install script.
Run the init script to load the GPIO switches.
Run web service.
http://0.0.0.0:5000
Hit it with a browser.
abitowhit's picture

To prevent corruption, the pi needs to be shut down before the power drops. I am thinking a usb backup input power which appears to work on pizero but possibly lacking for pi3. Testing a few models for amperage to sustain for the 30 second approx shutdown time. Trigger via gpio.

Source article:
https://www.raspberrypi.org/forums/viewtopic.php?t=158848
fdr4prez

These relays are used often in cars for various aftermarket applications:
https://www.amazon.com/gp/r.html?C=2KVQ ... BEG2AJRUIA

You would connect the relay's coil to the car's ground (wire 85) and the accessory (wire 86).

Then you would connect the relay's common (wire 30) to Pi's GPIO ground pin (not car ground), and the NC (normally closed) (wire 87a) to one of the GPIO I/O pin.

When the relay has power, then the this will open the relay and the GPIO I/O is open.

When the car turns off, then the relay has no power and the contact will close and this will pass the Pi ground into the GPIO I/O.

Now you need a Python script running in the background monitoring the GPIO pin, so that when the pin goes to ground, then the shutdown command will be issued.

A Python script like this would work:

Script:
import RPi.GPIO as GPIO
import time
import os

GPIO.setmode(GPIO.BOARD)
GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)
while True:
if(GPIO.input(5) == False):
os.system(“sudo shutdown -h now”)
break
time.sleep(1)

abitowhit's picture

Added to the relay_web_interface.py python file
app = Flask(__name__,static_url_path='/static')

This allows the controller page to display images under the static folder.

Source Doc:
https://stackoverflow.com/questions/28207761/where-does-flask-look-for-i...

To use images in flask you must put path in python script.
use absolute path where the image actually exists (e.g) '/home/artitra/pictures/filename.jpg'

or create static folder inside your project directory like this

| templates
- static/
- images/
- yourimagename.jpg
then do this

app = Flask(__name__, static_url_path='/static')
then you can access your image like this in index.html

src ="/static/images/yourimage.jpg"
in img tag

abitowhit's picture

Added wireshark to the PD controller.
In terminal type:
sudo apt-get install wireshark

At first I could not access any interfaces due to permissions. To set permissions I followed this article.

Open terminal and type:
type:
sudo dpkg-reconfigure wireshark-common
This will bring up the ws config.
Select Yes. (I selected no to begin with, it prompted this on install)
type:
sudo chmod +x /usr/bin/dumpcap
After doing this the interfaces were then active.
abitowhit's picture

You can chose to fire up rpVAC on load or launch it from icons.
I create two shortcuts on the desktop. The first is rpVACInit which you use to start the web server. Once the webserver is launched you can launch the second shortcut just named rpVAC which will bring up the rpVAC window in kiosk mode. Become a Patron!This page is being written. Become a patron to get a preview.
abitowhit's picture

The default port for the Flask web server is 5000. You can easily change this port by editing the python script in your relayweb directory. Keep in mind that if you change the port, you will have to change the port in your web URL (i.e. from http://0.0.0.0:5000 to http://0.0.0.0:8080)

The very last few lines of the file is where you add the port number.
Here is what it looks like, simply change the port to an available port of your choosing on your device. In this case the port is 8080.
File: relay_web_interface.py
#this will allow the server to be seen by outside world
app.run(host='0.0.0.0',port=8080)