====== Raspberry Pi ======
Purchased a Raspberry Pi Version 3 Model B+ on line with promo discount for about $25 (12/9/2017). Took a while to figure out that the OS has to be installed on a Micro SD. Had problems with a Micro SD that previously was used in a cell phone. Got it working, but then after booting it, nothing would happen. Found out that the power light alone only indicates that the voltage is adequate. There is a separate green activity light tneeds to flicker to indicate that it is booting. The video will not work until after the OS loads. The BIOS is on the Micro SD.
There was two options of OS to install. I tried both, the one that worked was NOOBS. This started up in GUI mode, so I had to connect monitor via HDMI and mouse/keyboard. After configuring to work from CLI (Command Line Interface) and embedding the WiFi SID and password, it now starts up "headless."
Can connect to the IO pins with an old 40-pin Hard Drive capable. They warn on-line not to use the 80-pin special cable because this can short out the pins.
* Purchased some accessories to make the Panel Clock
* {{:raspberrypi:adafruit_had_proto_hat_rev_a.pdf|Adafruit Perma-Proto Pi HAT (HAT circuit board) Board Diagram}}
* {{:raspberrypi:permaprotopihateagle.pdf|Adafruit Perma-Proto Pi HAT (HAT circuit board) Schematic}}
* {{:raspberrypi:1787ahc125.pdf|74AHCT125 Data Sheet (Chip that level matches between 5 and 3.3 volt signals)}}
* //To use, apply ~5V power to the VCC pin, common ground to the ground pin, and tie the /OE (output enable) pins to ground. Data goes in on the A pins and goes out on the matching Y pins//
===== Dec. 26 2017 =====
Starting over with installation of a more minimal OS to run the Panel Clock.
* Formatted 16 Gb Micro SD with SD formatter utility
* Copied NOOBS 2.4.5 (11/2017) to root of Micro SD with PC
* Connected HDMI and keyboard directly to Raspberry Pi 3 B+
* Booted into the NOOBS GUI.
* Connected to network. After doing so, the number of OS options increased a lot
* Installing Raspian Lite
* Ran ''sudo apt-get upgrade'' - didn't do anything, the software was probably all up-to-date
* Ran ''sudo apt-get install python-imaging''
I seem to have Python version 2.7.
===== Dec. 27.2017 =====
SSH service keeps shutting down. Read to run these commands:
* sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server
* Going to set up a static IP address: 192.168.0.7
* Edit ''/etc/dhcpcd.conf''
interface eth0
static ip_address=192.168.0.6
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0
static ip_address=192.168.0.7
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
* Initially had trouble because another device was occupying 192.168.0.8, so changed this to 7.
* Setting up web server:
==== Lighttpd ====
Lighttpd is a lightweight web server, with all the essential functions of a web server. Instructions: http://www.instructables.com/id/Setup-a-Raspberry-Pi-PHP-web-server/
sudo apt-get update #download package lists from the repositories
sudo apt-get -y install lighttpd
Configuration file is at ''/etc/lighttpd/lighttpd.conf''
Needed to make sure to install php-cgi with ''sudo apt-get install php-cgi''
Start with:
sudo service lighttpd start
==== Install PHP ====
PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.
sudo apt-get -y install php
# original instructions: sudo apt-get -y install php5-common php5-cgi php5
sudo lighty-enable-mod fastcgi-php #Enable the Fastcgi module which will handle the PHP pages
sudo service lighttpd force-reload #restart the Lighttpd service
==== Test Web Server ====
To access the web pages from server, enter http://192.168.0.223 (please use your own web server IP)
By default web servers communicate over port 80. You can easily change it by editing the lighttpd.conf file: server.port = 8000
Restart needed for update to take effect sudo /etc/init.d/lighttpd restart #restart the lighttpd service Enter http://raspberryPi_IP:port (eg. http://192.168.0.223:8000) to access web pages from web server
http://192.168.0.7
===== Open Weather =====
https://openweathermap.org/forecast5
===== Weather Underground =====
Switching to Weather Underground because they allow more frequent hits.
List of possible conditions:
https://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary
===== Install PIP (Package Installer for Python =====
Get installer
* ''wget https://bootstrap.pypa.io/get-pip.py''
* Install it ''sudo python get-pip.py''
===== Install PYTZ timezone ======
Needed to install PIP installer first, then the package gets installed with this:
* ''sudo pip install pytz''
===== Socket =====
I'm thinking I'll need to establish a client/server socket connection between the PHP controller web page, and the Python LED control programming. After this is working, I might be able to move to Python-only, but initially establishing a PHP web page seems easier.
**Example:** https://docs.python.org/2.4/lib/socket-example.html
https://docs.python.org/2.4/lib/socket-example.html
Remove "HOST" from client to get this to run. It worked the first time.
The first two examples support IPv4 only.
# Echo server program
import socket
HOST = '' # Symbolic name meaning the local host
PORT = 50007 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data: break
conn.send(data)
conn.close()
# Echo client program
import socket
HOST = 'daring.cwi.nl' # The remote host
PORT = 50007 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('Hello, world')
data = s.recv(1024)
s.close()
print 'Received', repr(data)
===== Troubleshooting =====
1/3/2018 - Keep having problems where the raspberry PI becomes unreachable. Ran this:
* ''sudo systemctl disable bluetooth.service''
Did this because I'm seeing a lot of memory read errors. It might be a collision between Bluetooth and WiFi.
See https://raspberrypi.stackexchange.com/questions/62722/pi-zero-w-wifi-interference-with-tty
===== Changing Approach 1/4/2018 =====
The driver I had been using from Adafruit is a compiled C library. This would not run under Python 3.5, nor would it compile (using make) with Python 3.5 C libraries from Python. Looked for another approach, found a Python normal module that runs under Python 3.5 and doesn't use a C library. (I don't think a C library should be required, because the DotStar LEDs are programmed by setting both data and clock bits.)
* https://github.com/tinue/APA102_Pi (the apa102.py contains a class which represents the strip)
Did require some prerequisite modules:
* https://github.com/adafruit/Adafruit_Python_GPIO (allows access to the GPIO pins)
Used these instructions to install.
Activate SPI: sudo raspi-config; Go to "Interfacing Options"; Go to "SPI"; Enable SPI; Exit exit the tool and reboot
Install the git client: sudo apt-get install -y git
Prepare GIT: git config --global user.name "John Doe" && git config --global user.email johndoe@example.com
Install Python 3 and some packages required by the Adafruit library: sudo apt-get install -y python3 python3-dev python3-pip python3-smbus python3-rpi.gpio build-essential
Fetch the Adafruit_Python_GPIO library: cd /tmp && wget https://github.com/adafruit/Adafruit_Python_GPIO/archive/master.zip && unzip master.zip
Install the library: cd Adafruit_Python_GPIO-master && sudo python3 ./setup.py install
Create a development directory and change into it: mkdir ~/Development && cd ~/Development
Get the APA102 Library and sample light programs: git clone https://github.com/tinue/APA102_Pi.git
You might want to set the number of LEDs to match your strip: cd APA102_Pi && nano runcolorcycle.py; Update the number, Ctrl-X and "Yes" to save.
Run the sample lightshow: ./runcolorcycle.py.
Additionally, had to change the pins used by my circuitry (23, 24), definition is within the apa102.py file.
===== Using Git and Jenkins =====
Changed to using Git and Jenkins to get knowledge about these tools for IBM work.
[[.gitinfo|Git Info]]
===== Installing other packages ======
For interpolation:
sudo apt-get install python-numpy python-scipy python-matplotlib python-pandas python-sympy python-nose
(There were others like "ipython" but they failed, so I removed them, and it worked anyway.)
===== PCA9685 Servo Card =====
Purchased another Raspberry Pi ("Conner") received 1/22/2019. Purchased another MicroSD, installed Raspian on it.
* {{:raspberrypi:adafruit-16-channel-servo-driver-with-raspberry-pi.pdf|Instructions to use PCA9685 with Raspberry Pi}}
After doing the installation, this successfully moved the servo:
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
kit.servo[0].angle = 135
time.sleep(1)
kit.servo[0].angle = 0
time.sleep(1)
kit.servo[0].angle = 45
''python3 test2.py''
===== 7-Inch 1024x600 Touch Screen =====
^Resolution|1024x600 (aspect ratio ~1.71 (128/75))|
^Amazon|[[https://www.amazon.com/gp/product/B075QCXLPF/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1|Detail web page|
^Version|v2.04|
^Manufactuer|GeeekPi|
^Size|SVGA Wide|
^Purchased|1/14/2019|
Purchased a 7-Inch 1024x600 Capacitive Touch Screen, which serves as a small HDMI monitor. Had to use regular monitor temporarily to set up configuration at ''/boot/config.txt''. Added these entries to support 1024x600:
hdmi_group=2
hdmi_mode=87
hdmi_cvt 1024 600 60 3 0 0 0
hdmi_force_hotplug=1
Later followed this:
git clone https://github.com/yoyojacky/52Pi.git
cd ~/52Pi
chmod +x restool.sh
./restool.sh
Which further manipulated ''/boot/config.txt''
===== MCP4725 DAC =====
This is I2S compatible. Worked well the first time. The problem is that I need a lot of these, and normally you can only have two, selectible with an A0 address line.
It is rated at 25 ma of output. Connected to aviation simulator instrument, it only consumed about 0.5 ma, so connected directly to it.
https://www.adafruit.com/product/935
This could be multiplexed.
It can also be connected to an external op amp, e.g., LM358
This shows simple comparator, and simple gain amp: https://www.youtube.com/watch?v=g3TybiZHQ-A
==== Problem to use more than two ====
To get more than two, get a TCA9548a multiplexer. This allows 8 devices to connect, you hit the multiplexer with the number of the device to hit. Perhaps this means that I can have 16 DACs per Raspberry Pi. You can also have multiple multiplexers, each can respond on a different address themselves. It is also possible to get Raspberry Pi zeros for about $5
https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout
===== To Code With C =====
Using "Geany" - an IDE which is installed and comes with Raspberry Pi. It is a GUI app, but can run it remotely from Windows via vnc server.
**On Raspberry Pi**
* Run ''vncserver''
* ''vncserver :1 -geometry 1920x1080'' to set up a larger window.
**On Windows**
* Run VNC Client. Connect to pi 192.168.0.8. Login with "pi" credentials (regular ssh login).
* You can see the GUI. Launch Geany
===== Trying VisualGDB =====
[9/21/2019] Because I'm doing more programming for the Raspberry Pi, decided to try VisualGDB. This is a go-between which lets you develop in Visual Studio C++, and then build/run on Raspberry Pi.
* https://visualgdb.com/download/
After reviewing some of this, it is very complicated. Trying to use Geany instead on the Raspberry Pi. The code for this is not that involved.