The $35 Computer is All Grown Up
I woke up this morning to a delightful surprise – the Raspberry Pi 4 has launched, nearly a year ahead of schedule! It’s a massive upgrade on previous versions of the Pi, with a much beefier ARM processor – from the relatively simple in-order A53 on 40nm silicon, to the superscalar A72 at 28nm, giving 2x-4x speedups, depending on the benchmark. Raspberry Pi are claiming “desktop-like” performance, so I had to find out – is it fast enough to use as a web development platform?
These days, a lot of popular development tools are built on web technology. Anvil is no exception – it’s an environment for developing full-stack web apps with nothing but Python, and it’s all in the browser. It’s got a drag-and-drop UI designer, a Python code editor with code completion… it’s a great test for whether the Pi is ready to use as a dev platform.
We’re based in Cambridge, home of Raspberry Pi, so I cycled by their shop on my way to work and tried it out. I am pleased to report that the Anvil code editor runs delightfully on the Pi, even with only 1GB of RAM. I, um, may have got a bit excited…
Haha "look how fast it goes!" pic.twitter.com/sbzGwmcFHx
— Ben Nuttall (@ben_nuttall) June 24, 2019
Building a live data logger and viewer
Of course, I had to buy onetwo, and see what I could do with them. It’s a pretty muggy day for England, so I bought a SenseHAT and decided to graph the humidity in our office.
Here’s my app, developed entirely on the Pi. I built the UI in Python with Anvil, and the data is being recorded into Anvil’s Data Tables by an Uplink script. Take a look:
I <3 my new @Raspberry_Pi 4! Turns out it's powerful enough to build web apps. I just built and published a web app entirely on my Pi, with nothing but Python (no JS!), using @anvil_works: pic.twitter.com/1NDdwBTCCC
— Meredydd Luff (@meredydd) June 24, 2019
Here’s the source code for that web app:
And here’s the script I’m running on the Pi to record the data:
import anvil.server
from anvil.tables import app_tables
from sense_hat import SenseHat
from datetime import datetime
import time
sense = SenseHat()
anvil.server.connect("[INSERT UPLINK KEY HERE]")
while True:
app_tables.light_levels.add_row(
when=datetime.now(),
pressure=sense.get_pressure(),
humidity=sense.get_humidity()
)
time.sleep(1)
Want your own? Of course you do! Go buy a Raspberry Pi 4!