Tagged: tech_notes Toggle Comment Threads | Keyboard Shortcuts

  • julie 2:22 pm on April 27, 2016 Permalink
    Tags: macmini, , tech n, tech_notes   

    Set-up MacMini 1.4Ghz Intel Core i5 4GB (OS X El Capitan 10.11.2) 

    $ sudo easy_install pip
    $ sudo pip install -U setuptools already installed on El Cap
    $ sudo pip install pyserial

    install MariaDB as that is what is installed on pew
    ==

    • make sure Xcode is uptodate or install it   (this triggered an OS install, do it)

    $ xcode-select –install

    • install homebrew

    $ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

    • Check Homebrew

    $ brew doctor

    This will give you a message – “Your system is ready to brew.”

    • Update Homebrew

    $ brew update

    • Check MariaDB version in brew repo

    $ brew info mariadb

    • Install MariaDB

    $ brew install mariadb

    • Run the Database Installer (change the version number in the path to match where MariaDB was installed in previous step)

    $ unset TMPDIR
    $ cd /usr/local/Cellar/mariadb/10.1.13/
    $ mysql_install_db

    • Version first installed 10.1.13 (on 27-4-16)
    • To have launchd start mariadb now and restart at login:

    $  brew services start mariadb

    • Start MariaDB

    $ mysql.server start

    • Secure the Installation

    $ mysql_secure_installation

    • Connect to MariaDB

    Follow security questions (remove anon users, enable access as root user remotely, set up root password)

    $ mysql -u root -p

    • Verify MariaDB Version

    $ select @@version;

    ===

    • $ sudo pip install MySQL-python

    $ sudo pip install PyMySQL

    version at 27-4-16 PyMySQL 0.7.2

    ===

    • Generate rsa key for SSH access to server:
      $ ssh-keygen -t rsa
    • Copy public key to clipboard
      $ pbcopy < ~/.ssh/id_rsa.pub
    • plug in USB to serial convertor and a sensor. You may have FTDI drivers installed – check using from root dir:

    $ ls /dev/cu.*

    You are looking for /dev/cu.usbserial or /dev/tty.usbserial (see http://pbxbook.com/other/mac-tty.html )

    If not showing up install driver at http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41 and restart. [note Macmini didn’t need driver install]

    ===

    • Change paths in python script to be correct serial port paths, note these are in a weird order:

    ser0 = serial.Serial(‘/dev/tty.usbserial’, 9600, timeout=5)

    Use CoolTerm to establish which serial port is which reader: http://freeware.the-meiers.org/

     

    ===
    To get up and running on the command line:
    $ mysql.server start
    then
    $ mysql -u root -p
    created nmr db on iMac and created tables using latest schema hosted on github.

     
  • julie 11:35 am on March 20, 2016 Permalink
    Tags: , , sensor, tech_notes   

    Light sensor Python script 

    “””script to read a Light Dependent Resistor on GPIO pin 11
    must be run in command line:
    –login as root
    >sudo su
    — run python command from directory
    >python lightsensor.py
    — ctrl-C to quit
    “””
    #!/usr/bin/python
    import time
    import os
    import RPi.GPIO as GPIO

    GPIO.setmode(GPIO.BOARD)

    def LDRtime(LDRpin):
    reading = 0
    GPIO.setup(LDRpin, GPIO.OUT)
    GPIO.output(LDRpin, GPIO.LOW)
    time.sleep(0.1)

    GPIO.setup(LDRpin, GPIO.IN)
    while (GPIO.input(LDRpin) == GPIO.LOW):
    reading += 1
    return reading

    while True:
    print LDRtime(11)

    “””
    put LDRtime into a variable
    see if LDRtime is higher than a certain value
    if it is send a 1 to the MySQL database with timestamp
    if it goes lower than a certain value then send a 0 to the MySQL database with timestamp

    “””

    NOTE: paste code from editable post to preserve indents.

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel