Sample Python code to read from Weather-board

Moderators: mdrjr, odroid

Sample Python code to read from Weather-board

Unread postby glenno » Sat Apr 25, 2015 4:04 pm

Hi all,
Im a novice with Python 3, however I thought others might benefit from my snippet of code showing how to read the sensor feed on the USB port.

For those interested, im hoping to have multiple sensors around the office posting their sensor readings back via a RESTful API to a central Odroid-XU which is running Python 3 and Cherrypy and will have graphing and historical logging etc. All running ArchlinuxARM.

This code just shows how im reading the data every ~5secs. Hope it helps someone with their project.

Code: Select all
import serial
import time
while x<1:
    ser = serial.Serial('/dev/ttyUSB0', 500000, timeout=2)
    line = ser.readline(75)
    print('Decoded String=',tempreading)
    print('BMP Temp =      ',tempreading[2:7],'Deg C')
    print('Pressure =      ',tempreading[10:16],'Pa')
    print('Altitude =      ',tempreading[19:25],'Meters')
    print('Si7020 Temp =   ',tempreading[28:33],'Deg C')
    print('Humidity =      ',tempreading[36:42],' %')
    print('UV Index =      ',tempreading[44:49],)
    print('Visible Light = ',tempreading[51:54],'Lux')
    print('IR Light =      ',tempreading[56:59],'Lux')
    print('Difference between Temp sensors',str(deltatemp))
Posts: 3
Joined: Sun Nov 23, 2014 8:34 am
languages_spoken: english
ODROIDs: Odroid X, XU, SHOW2, Weather

Re: Sample Python code to read from Weather-board

Unread postby miller5083 » Wed Oct 25, 2017 8:47 pm

Looking forward to trying this out, have you run this with multiple weatherboards?
Posts: 3
Joined: Wed Oct 25, 2017 8:45 pm
languages_spoken: english

Return to SHOW

Who is online

Users browsing this forum: No registered users and 1 guest