forked from RaspberryPints/RaspberryPints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.txt
90 lines (67 loc) · 4.56 KB
/
instructions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
First things first:
Assemble the Alamode according to the user guide:
https://docs.google.com/document/d/1HBvd3KNmcs632ZgO6t_u37B-qwV6P9o9FQe62lGkumM/edit
The quick version is this:
on Page 7 follow the instructions to install the headers (requires solidering)
Open LXTerminal (or connect via ssh) and type following commands:
pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install arduino python-serial python-mysqldb php5-cli xdotool
To make the necessary changes for the Arduino IDE to recognize AlaMode, download AlaMode set up from the link given below.
https://github.com/wyolum/alamode/raw/master/bundles/alamode-setup.tar.gz
From the command line, unpack and install it:
pi@raspberrypi ~ $ tar -xvzf alamode-setup.tar.gz
pi@raspberrypi ~ $ cd alamode-setup
pi@raspberrypi ~ $ sudo ./setup
Then:
pi@raspberrypi ~ $ sudo shutdown -h now
(this halts the rPi so you can safely remove power)
To Power the Alamode and the rPi, set the 5V_link jumper to on (see page 11). This allows you to connect power to the alamode board
to power both the alamode and the rPi. This is important as the flow meters will draw more power than the rPi can safely supply via GPIO
To connect the flow meter to the alamode:
Pin1(red) -> Ground
Pin2 (middle)-> Any digital pin 2-13. Be sure to set this at the top of the Arduino code
Pin3 -> VIN
Once the alamode has been seated on the rPi (on the gpio pins) and the flow meter has been attached you can power the
rPi up. Plug the power in to the micro usb on the alamode and not the rPi.
Log in to the GUI on the rpi and go to the menu -> Programming -> arduino
This opens a program used to edit the ino file for arduino as well as compiler and uploader.
Click on file -> open
Browse to your raspberrypints directory, look for the arduino -> raspberrypints folder and select the raspberrypints.ino file
At the top of the file locate two lines:
//This line is the number of flow sensors connected.
const uint8_t numSensors = 4;
//This line initializes an array with the pins connected to the flow sensors
uint8_t pulsePin[] = {8,9,10,11};
Change the number of sensors to the total number of flow meters you have in line (in my case I have 4) and set the next one to the pin numbers that
the meters are attached to (not the ground or vin). I started at 8 simply because it was easier to attach to these pins. MAKE A NOTE OF THE PINS AND TAPS
you will need this information later.
Save the file, do not close.
Go to Tools -> Board and select the Alamode
Go to Tools->Serial and click the box for the serial connection (there should only be one)
In the menu bar there is a button that is a circle with an arrow in it ->
Click that button to compile and upload the ino file to the Alamode board **This is important, the alamode needs the code uploaded to it in order to
read the flow meters. If you add meters you have to recompile and reupload**
In phpmyadmin on your machine (if you haven't installed it yet, sudo apt-get install phpmyadmin then go to localhost/phpmyadmin)
You need to run:
ALTER TABLE `pours` ADD `pinId` INT( 11 ) NULL AFTER `tapId`;
ALTER TABLE `taps` ADD `pinId` INT( 11 ) NULL AFTER `tapNumber`;
INSERT INTO `raspberrypints`.`config` (`id`, `configName`, `configValue`, `displayName`, `showOnPanel`, `createdDate`, `modifiedDate`) VALUES (NULL, 'useFlowMeter', '0', 'Use Flow Monitoring', '1', NOW(), NOW());
Log in to the admin area of your raspberrypints install.
click on taps
edit the taps and add the pinId.
At this point you should be ready to run the python script.
Copy the flowmon file from the python (/var/www/python) directory to /etc/init.d
$ sudo cp flowmon /etc/init.d
Then give it the proper permissions:
$ sudo chmod a+x /etc/init.d/flowmon
**IF YOUR INSTALL IS IN /var/www you should be good to go forward. if not, you need to edit the 14th line and set the root dir for your install.
You can test the program by running:
$ sudo /etc/init.d/flowmon start $ ps aux | grep flow_monitor.py
Should return:
pi 3508 0.0 0.9 8796 4112 ? S 15:35 0:00 /usr/bin/python /home/pi/raspberrypints/python/flow_monitor.py pi 3558 0.0 0.1 3548 808 pts/0 S+ 15:43 0:00 grep --color=auto flow_monitor.py
then run:
$ sudo update-rc.d flowmon defaults
to ensure it runs at startup.
This will start the script. You will not see anything output until you actually pour a pint. When a pint is poured it passes the pin number and the pulse count
to a php script which then updates the pours table in the database and then refreshes the chromium browser on the localhost.
You should also see output on the terminal window where you started the python script.