Install BOINC on a Pi

  1. Update software with sudo apt-get update and sudo apt-get upgrade
  2. Install Bonic with sudo apt-get install boinc
  3. Connect to account manager with boinccmd –join_acct_mgr URL name password

State queries

–get_cc_status
Show CPU/GPU/network run modes and network connection status (version 6.12+)
–get_state
Show complete client state
–get_tasks
Show tasks
–get_simple_gui_info
Show projects and active tasks
–get_file_transfers
Show file transfers
–get_project_status
Show status of all projects
–get_project_urls
List URLs of attached projects, one per line
–get_disk_usage
Show disk usage by project
–get_proxy_settings
Get proxy settings
–get_messages seqno
Show messages with sequence numbers beyond the given seqno
–get_host_info
Show host info
–version, -V

Setup a new Pi

  1. Win 32 Disk Imager to write the Raspbian image to sd card.
  2. Boot Pi
  3. Using sudo raspi-config change the following
    1. Hostname
    2. Password
    3. Enable SSH
    4. Resize filesystem
    5. Boot options
    6. Timezone
  4. Update software with sudo apt-get update and sudo apt-get upgrade

GETTING TEMPERATURE AND HUMIDITY

GETTING TEMPERATURE AND HUMIDITY

Run sudo apt-get update and sudo apt-get upgrade -y to ensure your system is up to date.
The temperature and humidity refers to a time of the day. For the data to be correct, your timezone must be set correctly. When you execute date you should see the local time. If not, then you can set the correct timezone in sudo raspi-config.
To communicate with the sensor, the Adafruit_Python_DHT library is used. It talks to the GPIO pins without using the Wiring Pi library. To install it, get the dependencies with
sudo apt-get install -y build-essential python-dev git and then download and install the library with

mkdir -p /home/pi/sources  
cd /home/pi/sources  
git clone https://github.com/adafruit/Adafruit_Python_DHT.git  
cd Adafruit_Python_DHT  
sudo python setup.py install  

Now you can already get the temperature and humidity with the command
sudo /home/pi/sources/Adafruit_Python_DHT/examples/AdafruitDHT.py 2302 4. The first argument is the sensor type, it can be 11 or 22 or 2302. The second argument is the RPi GPIO pin which is connected to the sensor data pin.Actually the sensor can be queried from any Python script with just two lines of code. You can try this by starting Python interactive with sudo python then in the interactive mode type

import Adafruit_DHT  
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 4)  
temperature  
humidity  

Press Ctrl-D to quit Python interactive mode.

Python Code – Raspberry Pi to ThingSpeak Temperature Sensor

import os

import glob

import time

import httplib, urllib

 

os.system(‘modprobe w1-gpio’)

os.system(‘modprobe w1-therm’)

 

base_dir = ‘/sys/bus/w1/devices/’

device_folder = glob.glob(base_dir + ’28*’)[0]

device_file = device_folder + ‘/w1_slave’

 

def read_temp_raw():

f = open(device_file, ‘r’)

lines = f.readlines()

f.close()

return lines

 

# Converts the raw temp to C and F

def read_temp():

lines = read_temp_raw()

while lines[0].strip()[-3:] != ‘YES’:

time.sleep(0.2)

lines = read_temp_raw()

equals_pos = lines[1].find(‘t=’)

if equals_pos != -1:

temp_string = lines[1][equals_pos+2:]

temp_c = float(temp_string) / 1000.0

temp_f = temp_c * 9.0 / 5.0 + 32.0

return temp_f

while True:

# This Code writes to Thing Speak

params = urllib.urlencode({‘field1’: (read_temp()), ‘key’:’keyhere’})

headers = {“Content-type”: “application/x-www-form-urlencoded”,”Accept”:

“text/plain”}

conn = httplib.HTTPConnection(“api.thingspeak.com:80”)

conn.request(“POST”, “/update”, params, headers)

response = conn.getresponse()

print response.status, response.reason

data = response.read()

conn.close()

# Writes the temp to the screen.

print(read_temp())

time.sleep(60)