Python sense_hat.SenseHat() Examples
The following are 7
code examples of sense_hat.SenseHat().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sense_hat
, or try the search function
.
Example #1
Source File: web_app.py From Pi_Weather_Station with MIT License | 8 votes |
def old(): sense = SenseHat() sense.clear() acceleration = sense.get_accelerometer_raw() celsius = round(sense.get_temperature(), 1) kwargs = dict( celsius = celsius, fahrenheit = round(1.8 * celsius + 32, 1), humidity = round(sense.get_humidity(), 1), pressure = round(sense.get_pressure(), 1), x = round(acceleration['x'], 2), y = round(acceleration['y'], 2), z = round(acceleration['z'], 2), ) aqi = get_gov_aqi() dark_sky = get_dark_sky() return render_template('weather_old.html', **kwargs, aqi=aqi, dark_sky=dark_sky)
Example #2
Source File: DisplayManager.py From pluralsight with MIT License | 5 votes |
def __init__(self): self.s = SenseHat() self.s.low_light = True self.__displayImage(self.__raspberry())#Flash the raspberry pi logo at initialization time.sleep(1) self.s.clear()
Example #3
Source File: DisplayManager.py From Custom-vision-service-iot-edge-raspberry-pi with MIT License | 5 votes |
def __init__(self): self.s = SenseHat() self.s.low_light = True # Flash the raspberry pi logo at initialization self.__displayImage(self.__raspberry()) time.sleep(1) self.s.clear()
Example #4
Source File: weather_logger.py From Pi_Weather_Station with MIT License | 5 votes |
def get_sensor_data(): """Get sensor data from SenseHAT""" sense = SenseHat() sense.clear() celsius = round(sense.get_temperature(), 1) fahrenheit = round(1.8 * celsius + 32, 1) humidity = round(sense.get_humidity(), 1) pressure = round(sense.get_pressure(), 1) try: dewpoint = (round(243.04 * (log(humidity / 100) + ((17.625 * celsius) / (243.04 + celsius))) / (17.625 - log(humidity / 100) - (17.625 * celsius) / (243.04 + celsius)), 1)) except: dewpoint = 'broken' return [celsius, fahrenheit, humidity, pressure, dewpoint]
Example #5
Source File: weather.py From Pi_Weather_Station with MIT License | 5 votes |
def get_sensor_data(): """Get sensor data from SenseHAT""" sense = SenseHat() sense.clear() celsius = round(sense.get_temperature(), 1) fahrenheit = round(1.8 * celsius + 32, 1) humidity = round(sense.get_humidity(), 1) pressure = round(sense.get_pressure(), 1) dewpoint = (round(243.04 * (log(humidity / 100) + ((17.625 * celsius) / (243.04 + celsius))) / (17.625 - log(humidity / 100) - (17.625 * celsius) / (243.04 + celsius)), 1)) return [celsius, fahrenheit, humidity, pressure, dewpoint]
Example #6
Source File: sensehat.py From calvin-base with Apache License 2.0 | 5 votes |
def get_sensehat(): global _sensehat if not _sensehat : _sensehat = sense_hat.SenseHat() return _sensehat
Example #7
Source File: weather_station.py From pi_weather_station with MIT License | 4 votes |
def main(): global sense, wu_station_id, wu_station_key # Setup the basic console logger format_str = '%(asctime)s %(levelname)s %(message)s' date_format = '%Y-%m-%d %H:%M:%S' logging.basicConfig(format=format_str, level=logging.INFO, datefmt=date_format) # When debugging, uncomment the following two lines # logger = logging.getLogger() # logger.setLevel(logging.DEBUG) print('\n' + HASHES) print(SINGLE_HASH, 'Pi Weather Station (Sense HAT) ', SINGLE_HASH) print(SINGLE_HASH, 'By John M. Wargo (https://johnwargo.com)', SINGLE_HASH) print(HASHES) # make sure we don't have a MEASUREMENT_INTERVAL > 60 if (MEASUREMENT_INTERVAL is None) or (MEASUREMENT_INTERVAL > 60): logging.info("The application's 'MEASUREMENT_INTERVAL' cannot be empty or greater than 60") sys.exit(1) # ============================================================================ # Read Weather Underground Configuration # ============================================================================ logging.info('Initializing Weather Underground configuration') wu_station_id = Config.STATION_ID wu_station_key = Config.STATION_KEY if (wu_station_id is None) or (wu_station_key is None): logging.info('Missing values from the Weather Underground configuration file') sys.exit(1) # we made it this far, so it must have worked... logging.info('Successfully read Weather Underground configuration') logging.info('Station ID: {}'.format(wu_station_id)) logging.debug('Station key: {}'.format(wu_station_key)) # ============================================================================ # initialize the Sense HAT object # ============================================================================ try: logging.info('Initializing the Sense HAT client') sense = SenseHat() # sense.set_rotation(180) # then write some text to the Sense HAT sense.show_message('Init', text_colour=[255, 255, 0], back_colour=[0, 0, 255]) # clear the screen sense.clear() except: logging.info('Unable to initialize the Sense HAT library') logging.error('Exception type: {}'.format(type(e))) logging.error('Error: {}'.format(sys.exc_info()[0])) traceback.print_exc(file=sys.stdout) sys.exit(1) logging.info('Initialization complete!') processing_loop() # Now see what we're supposed to do next