Garden monitoring system using m328p Arduino Uno boards. 100% Rust [no_std] using the avr hardware abstraction layer (avr-hal)

Overview

uno-revive-rs GitHub release (latest by date including pre-releases) Commit activity Lines of code GitHub file size in bytes GitHub issues

References

Arduino Garden Controller

Roadmap

uno-revive-rs: roadmap

Components & Controllers

  • 1-2 Uno R3 m328p
    • Soil moisture sensor: m328p-sensors
  • 2 Uno R3 m2560
    • OLED display shields for values on board near garden
    • Boards B & C (displays): m2560-oled-shields

Board: Arduino Uno R3 m328p (sensors)

Controls all sensors, captures soil moisture inputs.

Connections:

  • In: Soil sensors
  • Out-Channel 1: m2560 OLED displays
  • Out-Channel 2: <some datalogger module I haven't chosen yet>

Installation: m328p-sensors

dependencies

  • Rust
  • avr-gcc

To compile and install the code for m328p-sensors you'll first need to have Rust installed. If you don't already, see https://www.rust-lang.org/tools/install.

You will also need in installation of avr-gcc, a GNU cross compiler to the avr architecture. avr-gcc can be installed with homebrew

brew tap osx-cross/avr && brew install avr-gcc

cloning the repo along with its submodules

git clone https://github.com/ethgallucci/uno-revive-rs
cd uno-revive-rs
git submodule init
git submodule update

building from source

ensure Rust toolchain is set to nightly-1.51.0

Since we are cross compiling from Rust to AVR, we need to make sure our Rust compiler is on the right channel (e.g. one that supports the avr fork of Rust).

rustc --version

Ensure the rust-toolchain.toml file is correctly enforcing the correct nightly channel (1.51.0-nightly). If it's not, you can switch to the correct nightly version (since we use override here, the Rust toolchain version will only be affected in this directory).

rustup override set nightly-2021-01-07

compiling and flashing to m328p

From the root directory of uno-revive-rs

cargo build-328p

Move into m328p-sensors and flash the code (ensure board is plugged in and recognized)

cd m328p-sensors
cargo run

Dev

There are a few ways to compile the system.

With both boards plugged in (builds and flashes to board)

avr-garduino/m328-sensors $ cargo run
avr-garduino/m2560-oled-shields $ cargo run

From root with provided aliases:

avr-garduino $ cargo build-sensors && cargo build-i2c

From root manual:

avr-garduino $ cargo build --verbose --package m328p-sensors --target=m328p-sensors/spec/avr-atmega328p.json
avr-garduino $ cargo build --verbose --package m2560-oled-shields --target=m2560-oled-shields/spec/avr-atmega2560.json

From package:

avr-garduino/m328p-sensors $ cargo build --verbose
avr-garduino/m2560-oled-shields $ cargo build --verbose

Special Thanks

I want to extend my gratitude to the contributors of the avr-hal crate. This project couldn't have done it without them :)

You might also like...
How to use an Arduino library in a Rust project?

Example of an Arduino library usage in a Rust project The project tested with Arduino UNO on Fedora 35. It demonstrates the usage of LiquidCrystal_I2C

Arduino Nano frequency counter with atomic clock accuracy
Arduino Nano frequency counter with atomic clock accuracy

Arduino Nano frequency counter with atomic clock accuracy Project description and test setup With this project you can measure a frequency from less t

🖥 Simple Arduino Serial Monitor

Born out of the desire to connect to an Arduino without having to run the whole Arduino suite.

Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust
Proof of Concept / Experiment: Use IDF-HAL-LL from bare metal Rust

Proof of Concept / Experiment: Use IDF-HAL-LL from BM Rust idf-ll-compile pre-compiles a static library for ESP32C3 and ESP32 esp-ll a simple crate th

TI LDC1312/LDC1314/LDC1612/LDC1614 inductance-to-digital converter driver for Rust embedded-hal

ldc1x1x Rust embedded-hal 1.x driver for Texas Instruments (TI) I²C inductance-to-digital converters (LDC): LDC1312/LDC1314, LDC1612/LDC1614. Includes

esp-serial-dbg - debugging of esp-hal based applications via serial

esp-serial-dbg - debugging of esp-hal based applications via serial About This is still work in progress! At least the contained examples should work

An embedded-hal driver for the TT21100 multi-touch touchscreen controller

tt21100 An embedded-hal driver for the TT21100 multi-touch touchscreen controller. If there is a feature which has not yet been implemented and which

Embedded-hal simulator.

hal-sim - embedded-hal Simulator (WIP - UNFINISHED) This crate simulates a small portion of the embedded-hal traits. Namely: GPIO ADC Additionally, it

HAL for the CH58x family of microcontrollers. BLE 5.3, RISC-V Qingke V4.

ch58x-hal HAL for the CH58x RISC-V BLE microcotrollers from WCH. This crate is under random and active development. DO NOT USE in production. This sho

Comments
  • Write tests and configure them to run with stdlib

    Write tests and configure them to run with stdlib

    Testing in no_std seems clunky. It would be optimal to write and build tests with the stdlib so we can use macros like 'dbg!' and 'assert_eq!'.

    For this to work we need to tell rustc to compile our tests with a different target than our main programs (since tests will run on the host and not the target boards, we can compile with target: 'x86_64-unknown-linux-gnu')

    enhancement help wanted wontfix tests 
    opened by ethgallucci 0
Releases(v0.1.3)
  • v0.1.3(Apr 8, 2022)

  • v0.1.0(Apr 8, 2022)

    This release marks the successful flashing/running of m328p-sensors on our Uno R3 atmega328p.

    While there is much to still be done, this is an important milestone! Now that we know our code is flashing and running successfully on our board, we can pivot our focus to refactoring and improving the logic.

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Apr 6, 2022)

    v0.0.1 pre-release notes:

    • Prototypes for ADC communication via m328p soil sensors
    • Fork avr-hal in case we need to patch something later, add it as a submodule
    • Setup package and workspace configurations, build scripts, etc.
    Source code(tar.gz)
    Source code(zip)
Owner
Ethan Gallucci
Ethan Gallucci
Hardware Abstraction Layer for AVR microcontrollers and common boards

avr-hal Hardware Abstraction Layer for AVR microcontrollers and common boards (for example Arduino). Based on the avr-device crate. This is a new vers

Rahix 776 Jan 1, 2023
Rust Hardware Abstraction Layer (HAL) crate for the Vorago VA108xx family of MCUs

HAL for the Vorago VA108xx MCU family This repository contains the Hardware Abstraction Layer (HAL), which is an additional hardware abstraction on to

Institute of Space Systems 0 Dec 22, 2021
An asynchronous Hardware Abstraction Layer (HAL) for embedded systems

embedded-hal-async An asynchronous Hardware Abstraction Layer (HAL) for embedded systems. This crate contains asynchronous versions of the embedded-ha

Diego Barrios Romero 3 Jan 22, 2022
Hardware Abstraction Layer for ATmega32U4

Deprecation Note: This crate will soon be deprecated in favor of avr-hal. avr-hal is a new approach to writing the HAL crate, that was designed with s

Rahix 3 May 16, 2021
Arduino Uno 9 axis acceleration sensor (BMX055) reader implemented in Rust.

Arduino Uno Accelaration reader in Rust Components Arduino Uno (Probably possible with other AVR microcontrollers) BMX055 (Japanese website) Datasheet

Katsu Uchiyama 3 Dec 15, 2022
Freebsd-embedded-hal - Like linux-embedded-hal but FreeBSD

freebsd-embedded-hal Implementation of embedded-hal traits for FreeBSD devices: gpio: using libgpio, with stateful and toggleable support, with suppor

null 2 Oct 1, 2022
A compatibility layer to smooth the transition between different versions of embedded-hal

Embedded HAL Compatibility Layer A compatibility layer to smooth the transition between different versions of embedded-hal (specifically 0.2.x and 1.0

Ryan 7 Sep 11, 2022
⚙️ Crate to discover embedded programming with uno r3 project

⚙️ Crate to discover embedded programming with uno r3 project

null 0 Feb 3, 2022
1️⃣ el lisp number uno - one lisp to rule them all 🏆

luno el lisp number uno luno is the one lisp to rule them all. Still experimental, do not use it in production yet. goals embeddable small size simple

Eva Pace 3 Apr 25, 2022
Board Support Crate for Arduino Leonardo in Rust

Deprecation Note: This crate will soon be deprecated in favor of avr-hal. avr-hal is a new approach to writing the HAL crate, that was designed with s

Rahix 5 May 6, 2021