Tagged: raspi Toggle Comment Threads | Keyboard Shortcuts

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

    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.

     
  • julie 4:00 pm on March 17, 2016 Permalink
    Tags: , raspi,   

    Raspberry Pi 3B setup 

    install NOOBS from https://www.raspberrypi.org/downloads/noobs/ v 1.8.0 released 2016-02-29

    Get online using wifi dongle and QMUL Guest login (fuck eduroam for now)

    >sudo apt-get update

    >sudo apt-get install mysql-server

    >sudo apt-get upgrade

    >sudo pip install PyMySQL

    Changed mind and went for MariaDB as that is what I use on PEW
    >sudo apt-get install mariadb-server
    As MySQL was already installed this process migrates MySQL dbs etc to MariaDB and removes old MySQL stuff.

    Set-up remote access:
    VNC
    >sudo apt-get install tightvncserver
    >tightvncserver
    — Start a VNC server from the terminal: This example starts a session on VNC display one (:1) with full HD resolution:

    >vncserver :1 -geometry 1920×1080 -depth 24

    NOTE: With RPi3 and NOOBS 29-2-2016 DO NOT RUN the stop service as described on the RPi website as you’ll lose the GUI desktop you are working on… >service lightdm stop

    After this I couldn’t access the Pi from my mac like this – cmd-k from Finder and try to login vnc://PI-IPADDRESS :1
    Probably something to do with the university network bullshit.
    (automation set-up/start on boot instructs are here: https://www.raspberrypi.org/documentation/remote-access/vnc/README.md)

    Decided to try weaved:

    Weaved Connectd https://www.weaved.com
    >create account on https://www.weaved.com/
    >sudo apt-get install weavedconnectd

    To set-up SSH access:
    >sudo weavedinstaller
    — enter account details (email and passw)
    Then Option 1
    Option 1 again
    Option 1 again (SSH)
    yes to default port num
    Enter name
    Exit

    The above ref’d from: https://www.weaved.com/installing-weaved-raspberry-pi-raspbian-os/

    For VNC access via Safari on MacOSX:
    Check tightvnc is running (if not start a server as above)
    >ps ax | grep tightvnc
    Display what port(s) tightvnc is listening to
    >`sudo netstat -apn | grep tcp | grep LISTEN
    >
    Pick lowest port number and install a new Weaved Service Attachment for VNC using the default port of PORTNUMBER.
    >sudo weavedinstaller
    — enter account details (email and passw)
    Then Option 1
    Option 3 (you can change Port number if default isn’t what you want)
    Enter name
    Exit

    Sign in to Weaved account in Safari at weaved.com
    Your connections will be listed.
    Click on the one you want and follow instructs. You’ll need your TightVNC password.
    et voila.

    Generate key to SSH into pew:
    > ssh-keygen -t rsa

    Copy public key to clipboard
    > pbcopy < ~/.ssh/id_rsa.pub Add public key to PEW in the authorized_keys file in .ssh ----- Change hostname, first replace the default name in here: >sudo nano /etc/hostname

    ++ new name nmrpi ++

    Then find the line starting with 127.0.0.1, and change the name following it to your new hostname:
    > sudo nano /etc/hosts
    —–
    Find MAC address:
    > ifconfig

    The HWaddr is the MAC address
    —-

     
  • julie 10:25 am on July 24, 2015 Permalink
    Tags: raspi,   

    Raspberry Pi set-up (old) 

    On mac, Download NOOBS from https://www.raspberrypi.org/downloads/noobs/
    Unzip

    Format the microSD using SDFormatter software (I’ve used a 32GB card as I want to be able to backup the NMR data locally, just-in-case. This could be done to a USB stick too I guess).

    Copy files from root of NOOBS to freshly formatted SD card.

    Put card in Raspi and power up. Follow install instructs.

    To enter networking details use Run: wpa_gui BUT I have always had issues when doing this – unless your credentials are perfect the network is likely to mess up, and you’ll need to reset the wpa_supplicant.conf file. ALWAYS make a copy of a working version before editing it, manually or via the GUI.

    Making a copy of a file:

    Always – Update and Upgrade

    • sudo apt-get update
    • sudo apt-get upgrade

    Which version of Debian running?
    $ lsb_release -a

    • Generate SSH key on Pi and add public key to pew.
    • Add laptop public key to pi for ssh without passwrd
    • Install tightvncserver in case I need to access the GUI on the pi (i.e. for node-red)

    Setting up a light sensor on GPIO pins HEREHERE

    This is for PEW I think:

    To ensure start-up of these services on reboot (ensure you use the .service):

    $ sudo systemctl enable firewalld.service
    $ sudo systemctl enable mariadb.service
    $ sudo systemctl enable httpd.service

    Other commands:

    $ sudo systemctl status firewalld
    $ sudo systemctl start firewalld
    $ sudo systemctl stop firewalld

    • set-up static IP

    http://thepihut.com/blogs/raspberry-pi-tutorials/16683276-how-to-setup-a-static-ip-address-on-your-raspberry-pi

    access port 3306 on pew through frank
    $ ssh -NfL 9000:pew.eecs.qmul.ac.uk:3306 USERNAMEHERE@frank.eecs.qmul.ac.uk

    Set-up Python:
    $ sudo apt-get install python-setuptools

     
  • julie 5:40 pm on May 27, 2015 Permalink
    Tags: raspi,   

    Hardware set-up today

    Download Raspian
    Install raspian on the RPi
    Install wifi dongle
    Problems getting onto Eduroam.

    Will need to get the Pi on the network with a fixed IP

     
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