Links

Building your kit software from scratch

This page describes installing and building the AstroPlant software manually.

Software preparation and installation

First we will install Raspberry Pi OS Bullseye Lite and install all needed software. Before continuing make sure you have the LCD screen, water temperature sensor, CO2 sensor and relative humidity/ambient sensor hooked up.

Step 1. Raspberry Pi OS Bullseye Lite installation

Download the Raspberry Pi OS Bullseye Lite image from the following URL:
In order to flash the operating system image image to the SD card, use any tool suitable for flashing, such as Etcher:
To flash using Etcher, make sure an SD card is inserted in your computer and start Etcher. Select the downloaded Rasbian image and flash it to the SD card.

Step 2. Enable SSH and Wireless internet through the SD-card

Once you've flashed the operating system image onto the SD card, (re-)insert the card and you'll see one of the partitions on the card being mounted as "boot". Ensure it is the partition boot, and not the directory boot on the SD system partition. If on Linux the SD partition is not mounted automatically, mount it manually. In the root of the filesystem on the SD boot partition, you need to create two new files.
  • Step 2.1: Create an empty file called ssh in the root of the filesystem on the SD boot partition. For example, you can use Notepad on Windows or TextEdit on MacOS to create a new file named simply ssh, without any content. On Linux touch ssh from the command line inside the SD boot partition.
  • Step 2.2: Create a file named wpa_supplicant.conf. This time you need to write a few lines of text to this file, adjust the file below accordingly by changing country to your ISO 3166 alpha-2 country code, ssid to your network's name, and psk to your network's password:
country=NL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR NETWORK"
psk="YOUR NETWORK PASSWORD"
}

Step 3. Connect the Raspberry Pi to the extension board

Ensure the Raspberry Pi is connected to the extension board and the power supply is correctly connected. See the Electronics assembly guide.
The first boot of a fresh Raspberry Pi install will take some time. On a Raspberry Pi Zero W it may take a few minutes.

Step 4. Headless: Connecting to the Raspberry Pi via SSH

You may skip this section if you use a monitor and keyboard.
Once you have set up your internet connection and enabled SSH, you can connect to the Raspberry Pi over the network. The default username is pi and password is raspberry.
If your Raspberry Pi cannot be found, use a tool like Angry IP scanner to figure out the IP address of your Raspberry Pi. Alternatively, check your router's DHCP lease table. Then you can connect via ssh [email protected]<ip_address>.

Step 5. Enabling sensors and changing the password via `raspi-config`

Run raspi-config:
You'll see the following screen
Configure the Interfacing Options as follows:
  • Enable the camera
  • Enable the SPI interface
  • Enable I2C
  • Serial:
    • Disable the login shell
    • Enable serial port hardware
  • Enable 1-wire
Optionally change the password for the pi user. If you wish you can also change the timezone in the localization options to your country's timezone.

Step 6. Installing software packages

Update the package lists:
$ sudo apt-get update
Install the following packages:
$ sudo apt-get install git python3-pip libcapnp-dev pigpio python3-pigpio
$ sudo apt-get install libpng12-dev libatlas-base-dev libopenjp2-7-dev libtiff-dev
$ python3 -m pip install pyserial
$ sudo apt-get install python3-smbus
$ sudo apt-get install python3-w1thermsensor
$ sudo apt-get install python3-picamera
For completeness, reboot the Raspberry Pi:
$ sudo reboot now

Step 7. Test sensors

This step is optional, but recommended.
Clone the test repository in the home directory (/home/pi):
$ git clone https://github.com/AstroPlant/sensor-test-scripts
Change directory to the folder. Run the following commands one-by-one. Ensure you retrieve readings from each sensor.
$ python3 bh1750.py
$ python3 co2.py
$ python3 waterTemp.py
$ python3 lcdi2c.py
# if camera is attached
$ python3 RPI_camera.py
# for LCD screen, you may need to check your I2C address
# and adjust in script (default used in code: 0x3f)
$ python3 lcdi2c.py
For the humidity and temperature sensor, install the Adafruit_DHT library.
$ python3 -m pip install Adafruit_DHT
Run a test script provided in that library's repository:
$ git clone https://github.com/adafruit/Adafruit_Python_DHT
$ python3 Adafruit_Python_DHT/examples/AdafruitDHT.py 2302 17

Step 8. Install the AstroPlant Kit software

Install the Kit software:
$ python3 -m pip install git+https://github.com/AstroPlant/[email protected]
$ python3 -m pip install git+https://github.com/AstroPlant/[email protected]
Ensure the installation succeeded. The following command should output the kit software version:
$ astroplant-kit version
1.0.0b7

Step 9. Register and configure your kit

Follow these steps to register and configure a kit if you haven't already done so:
Take special note of the kit serial and the kit password. The kit password can be regenerated if needed (the password will be shown only once, and if lost, a new password needs to be generated).

Step 10. Set up the connection details on the kit

Create a file named kit_config.toml in the home directory (/home/pi):
[message_broker]
host = "mqtt.astroplant.io"
port = 1883
[message_broker.auth]
serial = "<<YOUR KIT SERIAL HERE>>"
secret = "<<YOUR KIT PASSWORD HERE>>"
[debug]
level = "INFO"
[debug.peripheral_display]
module_name = "astroplant_peripheral_device_library.lcd"
class_name = "LCD"
LCD not working? By default 0x27 is used as the I2C address. Most likely your LCD screen uses another address. There are two ways of finding the correct I2C address.
1) (recommended) Perform step 7 "ldci2c.py". By default this script uses the address 0x3f.
2) Use the RPi tool "i2cdetect" to find out the address. Detach the light and air/humidity sensor to make sure you find only the LCD address.
Add the following to the kit_config.toml in case you know you have an address other than 0x27.
[debug.peripheral_display.configuration]
i2cAddress = "<<0x27 OR 0x3f FOR MOST COMMON ADDRESSES>>"

Step 11. Run the kit

Run the kit, ensuring you are in the directory where you created kit_config.toml (or specify a path to the configuration file as argument).
$ sudo pigpiod
$ astroplant-kit run
To run the kit without an SSH connection, you can set up a system task to launch it on boot, or e.g. launch it in the program screen. Make sure pigpiod is activated.
Any issues? Please look at the FAQ or contact us