示例#1
0
    def show(self, text):
        LOGGER.debug(text)

        if text != self.last_text:
            #grove_oled.oled_clearDisplay()
            grove_oled.oled_setTextXY(0, 0)
            grove_oled.oled_putString(text.center(12))
            self.last_text = text
示例#2
0
if __name__ == "__main__":

    grove_oled.oled_init()
    grove_oled.oled_setNormalDisplay()
    grove_oled.oled_clearDisplay()
    while True:
        # GPIO.output(led,GPIO.HIGH)
        # time.sleep(1)
        # GPIO.output(led,GPIO.LOW)
        # time.sleep(1)
        # print 'led'
        temperature = grove_temperature_sensor.read_temperature()

        grove_oled.oled_setTextXY(0, 0)
        grove_oled.oled_putString('Temp:{0:0.1f} *C'.format(temperature))
        grove_oled.oled_setTextXY(5, 0)
        grove_oled.oled_putString("SeeedStudio")

        print 'Temp \n {0:0.2f} *C'.format(temperature)

        rqsString = dweetIO + myName + '?' + myKey + '=' + '{0:0.1f} '.format(
            temperature)
        # +'/' +  myKey + '=' + '{0:0.1f} *C'.format(sensor.read_temperature())
        # rqsString = dweetIO + myName + '?' + "{'Temperatuer':'23C','ADC':'123'}"
        print rqsString
        rqs = requests.get(rqsString)
        print rqs.status_code
        print rqs.headers
        print rqs.content
        if temperature >= THRESHOLD_TEMPERATURE:
示例#3
0
if options.withAccel:
    adxl345 = ADXL345()
    axes = adxl345.getAxes(True)

print("starting display")
grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()

while True:
    if options.withAccel:

        time.sleep(0.2)  # only update as often as necessary

        axes = adxl345.getAxes(True)

        if options.printDebug:
            print("accel: x = %.3fG, y = %.3fG, z = %.3fG" %
                  (axes['x'], axes['y'], axes['z']))

        grove_oled.oled_clearDisplay()
        grove_oled.oled_setTextXY(0, 0)
        grove_oled.oled_putString("x = %.3fG" % (axes['x']))
        grove_oled.oled_setTextXY(1, 0)
        grove_oled.oled_putString("y = %.3fG" % (axes['y']))
        grove_oled.oled_setTextXY(2, 0)
        grove_oled.oled_putString("z = %.3fG" % (axes['z']))
        grove_oled.oled_setTextXY(3, 0)
import time
import grove_oled
import pyowm
APIKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
placeName = 'Toronto,CA' #change this to your city name

owm = pyowm.OWM(APIKey)

grove_oled.oled_init()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_clearDisplay()

while True:
	observation = owm.weather_at_place(placeName)	
	weatherData = observation.get_weather()
	temperature = weatherData.get_temperature(unit='celsius')['temp']
	humidity = weatherData.get_humidity()
	weatherCondition = weatherData.get_status()
	#printing weather on the OLED
	grove_oled.oled_setTextXY(0,0)
	grove_oled.oled_putString(placeName)
	grove_oled.oled_setTextXY(2,0)
	grove_oled.oled_putString('Temp :'+ str(temperature) +'C')
	grove_oled.oled_setTextXY(4,0)
	grove_oled.oled_putString('Humid:'+ str(humidity) +'%')
	grove_oled.oled_setTextXY(6,0)
	grove_oled.oled_putString("- Weather -")
	grove_oled.oled_setTextXY(8,0)
	grove_oled.oled_putString(weatherCondition)
	time.sleep(1800) #check weather after every 30 mins
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

# Connect the OLED to any I2C port eg. I2C-1
# Can be found at I2C address 0x3c

import grove_oled
import time

grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()
time.sleep(.1)

for i in range(0, 12):
    grove_oled.oled_setTextXY(i, 0)
    grove_oled.oled_putString(" L O L I N ")
示例#6
0
#!/usr/bin/env python
#
# GrovePi Example for using the Grove OLED Display 96*96 (http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_1.12%22)
#
# The GrovePi connects the Raspberry Pi and Grove sensors.  You can learn more about GrovePi here:  http://www.dexterindustries.com/GrovePi
#
# Have a question about this example?  Ask on the forums here:  http://www.dexterindustries.com/forum/?forum=grovepi
#
# LICENSE:
# These files have been made available online through a [Creative Commons Attribution-ShareAlike 3.0](http://creativecommons.org/licenses/by-sa/3.0/) license.

# Connect the OLED to any I2C port eg. I2C-1
# Can be found at I2C address 0x3c

import grove_oled
import time

grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()
time.sleep(.1)

for i in range(0, 12):
    grove_oled.oled_setTextXY(i, 0)
    grove_oled.oled_putString("Hello World")
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

# Connect the OLED to any I2C port eg. I2C-1
# Can be found at I2C address 0x3c

import grove_oled
import time

grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()
time.sleep(.1)

for i in range(0,12):
    grove_oled.oled_setTextXY(i,0)
    grove_oled.oled_putString("Hello World")
示例#8
0
文件: station.py 项目: imrehg/bbgw1
 print("Reading: {0:0.1f}; a[t]: {1:0.3f}; b[t]: {2:0.3f}".format(x, a, b))
 # Do long blink if temperature change is more than 1 unit/min
 blinktime = blinklong if abs(b) >= SENSOR_THRESHOLD / 60.0 * PERIOD else blinkshort
 if abs(b) < 0.001:
     blinks([pin0, pin1], blinktime)
     trend += '-'
 elif b < 0:
     blink(pin0, blinktime)
     trend += '\\'
 else:
     blink(pin1, blinktime)
     trend += '/'
 if len(trend) > 12:
     trend = trend[-12:]
 grove_oled.oled_setTextXY(0, 0)
 grove_oled.oled_putString(printreading.format(x))
 grove_oled.oled_setTextXY(1, 0)
 grove_oled.oled_putString(trend)
 grove_oled.oled_setTextXY(2, 0)
 grove_oled.oled_putString("Location:")
 grove_oled.oled_setTextXY(3, 0)
 grove_oled.oled_putString(os.getenv("LOCATION", "unknown"))
 message.ts = int(round(time.time() * 1000))
 message.data = {'Temperature': x}
 if i % SENDPERIOD == 0:
     try:
         response = messages_api.send_message(message)
         print(response)
     except ApiException as e:
         print("Error sending message to ARTIK Cloud:{}".format(str(e)))
         error_count += 1
示例#9
0
# dht(pin,module_type), change module_type number to use other kind of dht
# module_type:
#             DHT11 0
#             DHT22 1
#             DHT21 2
#             DHT2301 3

from grovepi import *
import grove_oled 
#from grove_oled import *

dht_sensor_port = 7		# Connect the DHt sensor to port 7
grove_oled.oled_init()
grove_oled.oled_clearDisplay()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_setVerticalMode()
time.sleep(.1)

while True:
	try:
		[ temp,hum ] = dht(dht_sensor_port,1)		#Get the temperature and Humidity from the DHT sensor
		print "temp =", temp, "C\thumadity =", hum,"%" 	
		t = str(temp)
		h = str(hum)
		
		grove_oled.oled_setTextXY(0,0)
		grove_oled.oled_putString("Temp:" + t + "C")
		grove_oled.oled_setTextXY(1,0)
		grove_oled.oled_putString("Humi:" + h + "%")
	except (IOError,TypeError) as e:
		print "Error"
示例#10
0
        sensor_file = open(SENSOR_FILENAME, "w")
        sensor_file.write('{0:0.1f},{1:0.1f},{2:0d}'.format(
            temperature, humidity, int(time.time())))
        sensor_file.close()

        # We are going to look to a file for any message to display on our OLED
        try:
            message_file = open(MESSAGE_FILENAME, "r")
        except IOError:
            if (countdown == 0):
                if (clear == 1):
                    grove_oled.oled_clearDisplay()
                    clear = 0

                grove_oled.oled_setTextXY(0, 0)
                grove_oled.oled_putString('Temp:{0:0.1f}C'.format(temperature))
                grove_oled.oled_setTextXY(1, 0)
                grove_oled.oled_putString('Hum: {0:0.1f}%'.format(humidity))
                grove_oled.oled_setTextXY(5, 0)
                grove_oled.oled_putString("SpaceTime")
            else:
                countdown = countdown - 1
        else:
            message = message_file.readline()
            print('message = ' + message)
            message_file.close()
            os.remove(MESSAGE_FILENAME)

            grove_oled.oled_clearDisplay()
            grove_oled.oled_setTextXY(0, 0)
            grove_oled.oled_putString(message)
import time
import grove_oled
import pyowm
APIKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
placeName = 'Toronto,CA'  #change this to your city name

owm = pyowm.OWM(APIKey)

grove_oled.oled_init()
grove_oled.oled_setNormalDisplay()
grove_oled.oled_clearDisplay()

while True:
    observation = owm.weather_at_place(placeName)
    weatherData = observation.get_weather()
    temperature = weatherData.get_temperature(unit='celsius')['temp']
    humidity = weatherData.get_humidity()
    weatherCondition = weatherData.get_status()
    #printing weather on the OLED
    grove_oled.oled_setTextXY(0, 0)
    grove_oled.oled_putString(placeName)
    grove_oled.oled_setTextXY(2, 0)
    grove_oled.oled_putString('Temp :' + str(temperature) + 'C')
    grove_oled.oled_setTextXY(4, 0)
    grove_oled.oled_putString('Humid:' + str(humidity) + '%')
    grove_oled.oled_setTextXY(6, 0)
    grove_oled.oled_putString("- Weather -")
    grove_oled.oled_setTextXY(8, 0)
    grove_oled.oled_putString(weatherCondition)
    time.sleep(1800)  #check weather after every 30 mins
if __name__=="__main__":
    
    grove_oled.oled_init()
    grove_oled.oled_setNormalDisplay()
    grove_oled.oled_clearDisplay()
    while True:
        # GPIO.output(led,GPIO.HIGH)
        # time.sleep(1)
        # GPIO.output(led,GPIO.LOW)
        # time.sleep(1)
        # print 'led'
        temperature = grove_temperature_sensor.read_temperature()

        
        grove_oled.oled_setTextXY(0,0)
        grove_oled.oled_putString('Temp:{0:0.1f} *C'.format(temperature))
        grove_oled.oled_setTextXY(5,0)
        grove_oled.oled_putString("SeeedStudio")

        print 'Temp \n {0:0.2f} *C'.format(temperature)

        rqsString = dweetIO + myName + '?' + myKey + '=' + '{0:0.1f} '.format(temperature)
        # +'/' +  myKey + '=' + '{0:0.1f} *C'.format(sensor.read_temperature())
        # rqsString = dweetIO + myName + '?' + "{'Temperatuer':'23C','ADC':'123'}"
        print rqsString
        rqs = requests.get(rqsString)
        print rqs.status_code
        print rqs.headers
        print rqs.content
        if temperature >= THRESHOLD_TEMPERATURE :
            GPIO.output(Buzzer,GPIO.HIGH)