Gathering analog data without hardware

If you don't have an ADC module available, there is a wealth of data available from within Raspberry Pi that you can use instead.

Create the data_local.py script as follows:

#!/usr/bin/env python3 #data_local.py import subprocess from random import randint import time MEM_TOTAL=0 MEM_USED=1 MEM_FREE=2 MEM_OFFSET=7 DRIVE_USED=0 DRIVE_FREE=1 DRIVE_OFFSET=9 DEBUG=False DATANAME=["CPU_Load","System_Temp","CPU_Frequency", "Random","RAM_Total","RAM_Used","RAM_Free", "Drive_Used","Drive_Free"] def read_loadavg(): # function to read 1 minute load average from system uptime value = subprocess.check_output( ["awk '{print $1}' /proc/loadavg"], shell=True) return float(value) def read_systemp(): # function to read ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.