The easiest way to install go-ethereum on Ubuntu-based distributions is with the built-in launchpad PPAs (Personal Package Archives). We provide a single PPA repository that contains both our stable and development releases for Ubuntu versions trusty, xenial, zesty and artful.
import sys
#Calculate the exponential
def iterPower(base, exp):
'''
base: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
index=0
resultado=base
if base==1 or exp==0:
return 1
if base ==0:
return 0
for index in (range(exp-1)):
resultado=resultado*base
return resultado
def main():
try:
print(iterPower(int(sys.argv[1]),int(sys.argv[2])))
except:
print ("Faltan argumentos\nUsar como base_exp.py [base] [exponente] ")
if __name__ == '__main__':
main()
Below are listed a few example requests combining several query parameters:
Requesting the daily balance widget for January (default geo_limit; Spanish): https://apidatos.ree.es/es/datos/balance/balance-electrico?start_date=2019-01-01T00:00&end_date=2019-01-31T22:00&time_trunc=day Requesting the monthly general IRE widget for the year 2018 (peninsular geo_limit; English): https://apidatos.ree.es/en/datos/demanda/ire-general?start_date=2018-01-01T00:00&end_date=2018-12-31T23:59&time_trunc=month&geo_trunc=electric_system&geo_limit=peninsular&geo_ids=8741 Requesting the yearly generation structure widget between 2014 and 2018 (ccaa geo_limit; Castilla la Mancha; Spanish): https://apidatos.ree.es/es/datos/generacion/estructura-generacion?start_date=2014-01-01T00:00&end_date=2018-12-31T23:59&time_trunc=year&geo_trunc=electric_system&geo_limit=ccaa&geo_ids=7
Lectura Corriente
Luego ya sería adquirir tantos sensores no intrusivos como necesitemos: SCT-013-000.
On your Pi, edit the file /etc/rc.local using the editor of your choice. You must edit it with root permissions:
sudo nano /etc/rc.local
Add commands to execute the python program, preferably using absolute referencing of the file location (complete file path are preferred). Be sure to leave the line exit 0 at the end, then save the file and exit. In nano, to exit, type Ctrl-x, and then Y.
If your program runs continuously (runs an infinite loop) or is likely not to exit, you must be sure to fork the process by adding an ampersand (“&”) to the end of the command, like:
The Pi will run this program at bootup, and before other services are started. If you don’t include the ampersand and if your program runs continuously, the Pi will not complete its boot process. The ampersand allows the command to run in a separate process and continue booting with the main process running.
The below example guides you through how to plot your CPU temp as a graph to an image file, the code is in my github repository where I’ll hopefully add further functionality in the future.
#!/usr/bin/env python
import sys, os, logging, urllib, datetime
def fetchtemp():
cmd = '/opt/vc/bin/vcgencmd measure_temp'
line = os.popen(cmd).readline().strip()
output = line.split('=')[1].split("'")[0]#+' C'
return output
format = "%Y-%m-%d,%H:%M:%S"
today = datetime.datetime.today()
s = today.strftime(format)
output = s+' '+fetchtemp()+'\n'
print(output)
with open('/home/pi/plottemp/tempdata.dat', 'a') as f:
f.write(output)
Create this also
nano plottemp.sh
and paste the following:
#!/bin/bash
echo "set terminal png size 900, 300
set xdata time
set xrange [ time(0) - 86400 : time(0) ] # 86400 sec = 1 day
set timefmt '%Y-%m-%d,%H:%M:%S'
set format x '%H:%M'
set output '/home/pi/plottemp/tempplot.png'
plot '/home/pi/plottemp/tempdata.dat' using 1:2 with lines" | gnuplot
make it executable
chmod +x plottemp.sh
next all we have to do is to run the script every 5 minutes (or whatever interval you choose) with cron:
and there we have it, it will generate a file called:
plottemp.png
The result
If you have successfully implemented the instructions you should get something like this:
How it works
I’ll very briefly walk you through how it works – there’s a cron job running every five minutes which firstly runs a command line function which reports the CPU temp and saves it to a log file. Upon completion it then runs a GNUPlot command to generate a graph of the last 24 hours logging.
Having researched trackers there are lots of sites that provide handy APIs to get the current latitude and longitude of the space station. I settled on using wheretheissis.at as this provided the most comprehensive information I could find in an API.
All the coded needed to do was pull down the JSON provided by the API then parse the data for the values it needed. Below is an extract to show you how this is done
#!/usr/bin/env python3
from urllib.request import urlopen
import json
import time
feed_url="https://api.wheretheiss.at/v1/satellites/25544"
def informacion():
try:
jsonFeed = urlopen(feed_url)
feedData = jsonFeed.read()
#print feedData
jsonFeed.close()
data = json.loads(feedData)
return data
except Exception:
import traceback
print ("generic exception: " + traceback.format_exc())
return []
#use this method to retrieve from web API
def parseISSDataFeed():
data = informacion()
if len(data) == 0:
return []
name = data['name']
lat = data['latitude']
lng = data['longitude']
alt = data['altitude']
return [name, lng, lat, alt]
def main():
print (parseISSDataFeed())
if __name__ == "__main__":
while(1):
time.sleep(1)
main()
Now to display the ISS. The visible globe is essentially half of a sphere and so represents 180º in both the latitude (top/bottom or North/South) and longitude (left/right or East/West). With only 8 pixels that means each LED represents 22.5º of the Earths’ surface.
To display the location of the ISS we take the current lat/long of its position over the Earth and map that to the pixel/LED it falls into. That’s all well and good when it’s on the “visible” side of the globe in the overlay, but what to do when it goes “behind” our overlay?
Rather than make the ISS “disappear” I opted to still display it but in a different colour so it can be tracked as it reappears on the visible side of our globe. So now the LED lights up yellow for the visible side of the globe and blue when the ISS passes over the horizon to the rear of the planet.