Diana Khalipina
Published © GPL3+

Solar weather station

This kit get charged from solat battery and provides information about temperature, light level, CO2 level and moisture level of the soil.

BeginnerFull instructions provided1 hour2,529
Solar weather station

Things used in this project

Story

Read more

Schematics

Schematics for micro:bit board

Code

Code for micro:bit board

MicroPython
Code to program solar weather station
from microbit import *
import time
import math
from sgp30 import SGP30

# Temperature Sensor on pin1
# Light Sensor on pin0
sgp30 = SGP30()
# Moisture Sensor on pin2

def getGroveTemperature(pin, unit='celsius'):
  R = 1023.0/(pin.read_analog()+1e-3) - 1
  t = 1/(math.log(R)/4250+1/298.15) - 273.15 # celsius
  if unit == 'fahrenheit':
    t = t * 9/5 + 32
  elif unit == 'kelvin':
    t += 273.15
  return t

while True:
  led_image = Image('99999:00900:00909:00900:00909')
  display.show(led_image)
  time.sleep(1)
  display.show(getGroveTemperature(pin1))
  time.sleep(1)
  if getGroveTemperature(pin1) > 24:
    display.show('! HOT !')
  if getGroveTemperature(pin1) < 18:
    display.show('! COLD !')
  time.sleep(1)
  led_image = Image('90000:90000:90009:90000:99909')
  display.show(led_image)
  time.sleep(1)
  display.show(pin0.read_analog())
  time.sleep(1)
  if pin0.read_analog() < 50:
    display.show('! DARK !')
  time.sleep(1)
  led_image = Image('99900:90000:90009:90000:99909')
  display.show(led_image)
  time.sleep(1)
  display.show(sgp30.eCO2())
  time.sleep(1)
  if sgp30.eCO2() > 700:
    display.show('! POLLUTED !')
  time.sleep(1)
  led_image = Image('90009:99099:90909:90909:90909')
  display.show(led_image)
  time.sleep(1)
  display.show(pin2.read_analog())
  time.sleep(1)
  if pin2.read_analog() > 300:
    display.show('! HUMID !')
  time.sleep(1)

Credits

Diana Khalipina

Diana Khalipina

22 projects • 93 followers
Integrating Web Accessibility in Healthcare Tech | Web Developer & Bioengineering Specialist in Paris | MSc in Biomedical Engineering

Comments