Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Embedded and Microcontrollers blog "8th" - Embedded and more (part 1)
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • Raspberry Pi
  • Server Software
  • Embedded
  • Programming Languages
  • Sensors
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

"8th" - Embedded and more (part 1)

Ron Aaron
Ron Aaron
October 26, 2017

Overview

This is the first in a series of articles in which we'll explore using 8th with embedded as well as desktop and server systems, in an integrated project. It is not intended to be a tutorial on how to use 8th: for that, you can see the tutorials, the manual, or the forum.

If you would like an introduction to 8th, please view "8th - a Gentle Introduction to a Modern Forth", or "8th - Grokking the REPL", on the Arm Community.

The Project

What we want to accomplish in this project is to hook up some environmental sensors (temperature, etc) to a Raspberry Pi so we can take periodic readings. The readings will be periodically sent to a server, and the server will give web-access to the information via HTTPS.

All the code for the project will be done in 8th.

To be demonstrated:

  • I2C communication between the RPI and peripherals
  • debugging and ensuring proper functioning of code on a per-word basis
  • creation of standalone executables
  • network communications
  • writing server-side code
  • fail-safe techniques

Prerequisites

In order to follow along in this series, you'll need a copy of 8th. The minimum version which will work for this is the Hobbyist Edition (since it includes support for GPIO and I2C, which the Free version does not).

However, for a limited time you can purchase the current Professional Edition, and automatically receive the Embedded edition as soon as it's released. Details here.

In addition to 8th, you'll need the following hardware:

  • Raspberry Pi 2 (running Raspbian)
  • LM75A Temperature Sensor High-speed 12C Interface Development Board Module
  • Adafruit 0.56" 4-Digit 7-Segment Display w/I2C Backpack
  • GY-BME280-3.3 High Precision I2C SPI Breakout Barometric Pressure Temperature Humidity Digital Sensor Module Board

You'll also need wires, solder etc… some (hardware) assembly required!

For the server side, you'll need a laptop or a desktop computer (or a RPI) whose IP address is visible to the RPI on which the sensor code will be running. Any computer will do.

Raspberry Pi 2 board

First steps: program organization

We're going to have two distinct programs, one running on the RPI as a data-collector, and the other running on a server as the external (web) interface. So you'll start by creating a project folder with two sub-folders. I'm using Linux or macOS for development, so the commands I show will be different from what you would use on Windows; nevertheless, you can also use Windows for development purposes:

mkdir proj
mkdir proj/serv
mkdir proj/data

Create a single file proj/data/data.8th using whatever text-editor you like. I prefer vim, but anything which saves plain-text will work. The contents of the file should look like:


\ The data-collector

: collect-data
"collect" log ;

: save-data
"save" log ;

: send-data
"send" log ;

: app:main
repeat
collect-data
save-data
send-data
5 sleep
again ;


If you run this by typing 8th proj/data/data.8th you'll see this log output every five seconds:

collect
save
send

In subsequent posts, we'll expand the functionality by incremental improvement, testing as we go. That is, in my opinion, the preferred methodology when developing applications in general, and in 8th (and Forth) in particular.

Conclusion

In the next edition, we'll expand the data collector and start putting together the hardware, and testing the bits and pieces work together. Until then, make sure to get 8th

Get 8th: One Effort, Multiple Platforms

Anonymous
Embedded and Microcontrollers blog
  • Formally verifying a floating-point division routine with Gappa – part 2

    Simon Tatham
    Simon Tatham
    A method of testing whether a numerical error analysis using Gappa really matches the code it is intended to describe.
    • September 4, 2025
  • Formally verifying a floating-point division routine with Gappa – part 1

    Simon Tatham
    Simon Tatham
    Learn the basics of using Gappa for numerical error analysis, using floating-point division in Arm machine code as a case study.
    • September 4, 2025
  • Adapting Kubernetes for high-performance IoT Edge deployments

    Alexandre Peixoto Ferreira
    Alexandre Peixoto Ferreira
    In this blog post, we address heterogeneity in IoT edge deployments using Kubernetes.
    • August 21, 2024