Things used in this project

Hardware components:
Sipy600x600 mxkaj0ajhe
Pycom SiPy
×1
Pycom Pytrack
×1

Code

main.pyPython
from pybytes import Pybytes

from onewire import OneWire, DS18X20
from pytrack import Pytrack
from L76GNSS import L76GNSS

from machine import Pin
from pycom import heartbeat,rgbled
from time import sleep

#INITIALISE PYBYTES
USERNAME = "example@email.io"                          
DEVICE_ID = "AABBCCDDEEFFGGHHIIJJKKLLMMNNOO"   
SERVER = "mqtt.pybytes.pycom.io"

pybytes = Pybytes(USERNAME, DEVICE_ID, SERVER)
pybytes.connect_wifi()

#INITIALISE LIBRARIES

py = Pytrack()
gps = L76GNSS(py, timeout=60)


py.setup_sleep(3600)

#INITIALISE VARIABLES

ow = OneWire(Pin('P9'))
temp_sensor = DS18X20(ow)

#FUNCTIONS

def get_temp():                         
    temp_value = None
    while temp_value == None:
        temp_sensor.start_convertion()  
        sleep(1)
        temp_value = temp_sensor.read_temp_async()
        sleep(1)

    return(temp_value)

def get_location():                     
    location = gps.coords()             
    return location

def read_battery():                     
    voltage = py.read_battery_voltage()
    return voltage

def main():
    temp = int(get_temp())
    location = get_location()
    if location != (None,None):
        latitude = location[0]
        longitude = location[1]
    else:
        latitude = 51.23
        longitude = -0.57

    voltPercent = int(((read_battery() - 3.3) / 1.7) * 100)

    pybytes.send_virtual_pin_value(False, 16, int(voltPercent))
    pybytes.send_virtual_pin_value(False, 15, int(temp))
    pybytes.send_custom_location(12, str(latitude), str(longitude))

    py.go_to_sleep()

main()

Credits

6ef5e79aacc826e3f48892b0a0c2d344
Sam Williams
1 project • 0 followers
Contact
3822918 g3bjj2yrjv
Alex Bucknall
1 project • 9 followers
Postgraduate Researcher @ University of Warwick
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog