IT人在工廠日記 – 假期清閒,玩圍棋消譴


Temperature Sensor Setup on Raspberry Pi


Today, I setup my raspberry pi as a temperature sensor. I mainly use a LM35 temperature sensor and an IC “ADC0804″ as an analog to digital converter. I also setup a database to record down the temperature data and then display result on web browser with Chat format. The connection of the whole electronics circuit is as below diagram.

Program script:

1) The coding the a python program to take temperature data is as the program below:

#!/usr/bin/env python
# author: Powen Ko    Program Name:
import time, RPi.GPIO as GPIO
import urllib

read more

Speech with Raspberry Pi


Raspberry Pi is an excellent automation control unit, and we can use it to build a voice recognition feature in order to make it as a voice automation control unit. Yeah, is it very interesting ! In the following, I will show you the script to build voice feature, including converting speech to text, converting text to speech, auto-reply a text question.

Script to convert Speech to Text

I take the benefit of using google speech recognition ver 2 feature and arecord feature of Raspberry Pi. To remind that you should apply your google api key for usage in this script, as below:

read more

How to Capture Weather Forecast from web using Raspberry Pi's Python Program


We can use python to develop a program to capture any city’s weather forecast from web site under our Raspberry Pi computer. I list our program and screen capture result in the following for your reference.

Program Source Code under Python ver 3 as below:

import urllib.request,json

city = input(“Enter City: “)

def getForecast(city) :
    #url = “”
    #url = “”
    #url = “”
    url = “”
    url = url + city + “&lang=zh_cn&APPID=42443ecbdcad3d01842205e3745895cd”
    req = urllib.request.Request(url)
    return json.loads(“UTF-8″))

read more

Network Communication Script for Raspberry Pi


We can use python programs to start a server side and client side network communication service and allow them to transmit message  to each other under a Raspberry Pi. For example, we start two LXTerminal Sessions under a Raspberry Pi (or two difference Pi), and then run the following script.

In Server Side, run the following script:

import socket
comms_socket = socket.socket()
comms_socket.bind((‘localhost’, 50000))
connection, address = comms_socket.accept()
while True:
    send_data = input(“Reply: “)
    connection.send(bytes(send_data, “UTF-8″))

read more

Most Easy Way to Start a Web Server Service Using Python


Although it is easy to start-up IIS under Window O/S or Apache under Unix O/S, we still have another choice to start a web server service using Python programming tools. You only need to install python, and then start python and run the following script line by line:

import http.server, os
#define the server document directory with unix path;
#if it is window env with directory as c:\Users\administrator\Documents\
httpd = http.server.HTTPServer((‘′, 8000),

read more