This is a fork: First established at University of Freiburg, Environmental Meteorology by Andreas Christen
- The original documentation and code can be found here
A German version of the manual is also available here
- Raspberry Pi Zero W
- Temperature and Humidity Sensor (Adafruit DHT22 or better Sensirion SHT85)
- GPS Module - Adafruit Ultimate Breakout
- Nova PM Sensor (optional)
- UART to USB Adapter (5V) to connect the PM Sensor (optional)
- Micro-USB to USB adapter to connect the PM Sensor (optional)
- Cables (colored jumper wires) to connect all sensors
- Power bank to power the Raspberry Pi
- Case and bag for mounting on the bike
- Intake tube for PM Sensor (optional)
- Adapter board (only for SHT85)
- Laptop/computer with VNC Viewer (Download here)
- Raspberry Pi Imager to install the Operating System. Download here for:
- Wi-Fi network with Internet access
- Smartphone with VNC Viewer (Download for smartphone Android or iOS)
-
Download and extract the Operating System Image (Link provided on moodle)
-
Insert the MicroSD card (with adapter if necessary) into the computer.
-
Start Raspberry Pi Imager
-
Under
CHOOSE OS
→Use custom
, select the image you just downloaded. -
Under
CHOOSE SD CARD
, select the inserted SD card. Note: make sure to select the correct drive. The drive will be formatted, and all data will be erased! -
Click on the gear (settings) icon
-
Check the box for
Set hostname
and entercrowdbike13
(number of your Raspberry Pi) -
Check the box for
Enable SSH
and set the password for authentication -
Set the password to
Bike4Climate
, leave the user aspi
-
Start the writing process with
WRITE
. -
Once the write and verify process is completed, briefly remove and reinsert the SD card. Then, open the
boot
drive in the file explorer. -
Open the file
config.txt
and change the following entries as shown. This adjusts the screen resolution to portrait mode suitable for a smartphone screen (this can also be done after setup on the computer).# uncomment to force a console size. By default it will be display's size minus # overscan. framebuffer_width=720 framebuffer_height=1280
-
Save and close the file.
- Create a new file named
wpa_supplicant.conf
- Right-click → New → Text document → Enter
wpa_supplicant.conf
as the file name (make sure there's no.txt
at the end!) - You may need to enable file extensions in Windows first. Do this by going to the View tab and checking the box for file name extensions.
- Right-click → New → Text document → Enter
- When asked "If you change a file name extension, the file might become unusable. Are you sure you want to change it?", click
Yes
. - Now right-click → Open with and select Notepad
- Insert the following entries:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=DE network={ ssid="Name of your home Wi-Fi" priority=1 psk="Password of your home Wi-Fi" } network={ ssid="Name of your smartphone hotspot" priority=2 psk="Password of your smartphone hotspot" }
- Make sure that the name and password are enclosed in
""
! - There should be no spaces around the
=
! - Check 3 times to ensure the password and SSID are correct!
- Save and close the file.
- Connect the power bank to the Raspberry Pi via the
PWR IN
port. - The Raspberry Pi should now boot (green LED will flash).
- Wait for 2-3 minutes.
- Connect the laptop/computer to the same Wi-Fi network as the Raspberry Pi → Home Wi-Fi as previously configured.
- Launch VNC Viewer on the laptop/computer.
- File → New connection.
- VNC Server:
crowdbike13
(your number) (or local IP address if known). - Name: → Connection name, e.g.,
My Crowdbike
→OK
. - Double-click the new connection and confirm identity when prompted.
- The connection should now be established.
- Enter username
pi
and passwordBike4Climate
, optionally check the box to save the password →OK
.
- Auto-complete a command or path in the terminal with the TAB key.
- Confirm commands with Enter. If successful, there will be no output; otherwise, an error message will explain what went wrong.
- Change directories
cd <directory name>
(in the root directory/
withcd /<directory name>
). - List the contents of a directory
ls
orls -l
(for a detailed list). - Create a directory in the current directory
mkdir <directory name>
. - Move to the parent directory
cd ..
. - Use the up/down arrow keys to scroll through previously entered commands.
- Paste text from the clipboard with
Right-click
.
- Open the terminal (top bar, black icon):
-
If the font is too small, increase it in the terminal with ctrl++.
-
Enable the serial interface and I2C
- Enter
sudo raspi-config
. - Use the arrow keys to navigate to "3 Interface Options" and press Enter.
- Navigate to "P5 I2C" → Enter.
"Would you like the ARM I2C interface to be enabled?" Select
<YES>
. "ARM I2C interface is enabled" → Confirm with<OK>
. - Again, use the arrow keys to navigate to "3 Interface Options" and press Enter.
- Navigate to "P6 Serial" → Enter.
"Would you like a login shell to be accessible over serial?" Select
<No>
. - "Would you like the serial port hardware to be enabled?" Select
<Yes>
. - "The serial login shell is disabled."
- "The serial interface is enabled."
- Confirm with
<Ok>
. - Exit with
<Finish>
(use the arrow keys ←/→ or TAB to jump to<Finish>
). - "Would you like to reboot now?" Select
<yes>
. - Wait for about 1-2 minutes.
- Enter
-
Reconnect by double-clicking and confirming the identity warning with
Continue
, enter the password again if needed, and check the box to save the password.
- Open the terminal again, and if needed, increase the font size with ctrl++.
sudo pip3 install https://github.com/RUBclim/crowdbike/releases/download/0.10.0/crowdbike-0.10.0-py2.py3-none-any.whl
- This process will take a few minutes, as the Raspberry Pi Zero is not very fast.
- Now turn off the Raspberry Pi again to connect the sensors.
sudo shutdown -P now
- Wait until the green LED turns off, then disconnect the power supply (power bank).
- Connect the cables as follows:
Sensor | Pi | Cable Color |
---|---|---|
+ | PIN 1 (3.3 V+) | red |
- | PIN 9 (GND) | black |
out | PIN 7 (GPCLK0) | yellow |
- Connect the cables as follows:
Sensor | Pi | Cable Color |
---|---|---|
SCL | PIN 3 (SCL1I2C) | purple |
VDD | PIN 1 (3.3 V+) | white |
VSS | PIN 9 (Ground) | gray |
SDA | PIN 2 (SDA1I2C) | green |
- Connect the cables as follows:
Light | Pi | Cable Color |
---|---|---|
G | PIN 22 (GPIO25) | green |
Y | PIN 18 (GPIO24) | yellow |
R | PIN 16 (GPIO23) | red |
GRN | PIN 14 (Ground) | black |
- Connect the cables as follows:
GPS | Pi | Cable Color |
---|---|---|
VIN | PIN 4 (5V+) | black |
GND | PIN 6 (GND) | white |
TX | PIN 10 (RXD) | purple |
RX | PIN 8 (TXD) | gray |
- Connect a Micro-USB to USB adapter to the Micro-USB port labeled
USB
. - Plug the UART-USB adapter into the USB-A socket.
- Insert the white cable from the PM sensor into the UART adapter.
-
Reconnect the Raspberry Pi to the power bank and wait for it to boot up.
-
Re-establish the connection using VNC Viewer (see steps above).
-
Note: To receive data, the GPS must have reception. You can tell when it has reception if the LED marked
FIX
on the GPS module flashes approximately every 10-15 seconds. If it flashes at shorter intervals, there is no reception yet.
Some minor adjustments must be made to personalize and set up the software.
-
Reconnect via VNC and open the terminal again.
-
Initialize the software by entering
crowdbike init
. -
Open the configuration file by entering
nano ~/.config/crowdbike/config.json
and press Enter. -
In the text editor, navigation is only possible using the arrow keys, not the mouse.
{
"user": {
"studentname": "insert_username",
"bike_nr": "01",
"logfile_path": "/home/pi/crowdbike/logs/",
"pm_sensor": false,
"sampling_rate": 5,
"sensor_type": "SHT85",
"sensor_id": "1"
},
"cloud": {
"folder_token": "abcde1234",
"passwd": "my_password",
"base_url": "https://example.nextcloud.de"
}
}
- For
studentname =
enter your name. No spaces or special characters (umlauts). The name must be in double quotes, e.g.,"firstname_lastname"
. Pay attention to the comma at the end! - Adjust
bike_nr =
to assign your number (found on the sticker on the SD card slot, e.g.,06
). - For
pm_sensor
indicate whether you have one connected or not (onlytrue
orfalse
is allowed). - The
sampling_rate
controls how frequently a measurement is taken, in seconds. - The
sensor_id
is a unique identifier for the temperature and humidity sensor (sticker on the circuit board). - Enter the
folder_token
provided in the PPP. - Similarly, enter the data provided in the PPP for
passwd
andbase_url
. - Save with ctrl+s and close with ctrl+x.
- Sensor calibration must be entered in the file
~/.config/crowdbike/calibration.json
. - Open the file with
nano ~/.config/crowdbike/calibration.json
. - Make sure the factors are entered for the corresponding sensor number.
{
"temp_cal_a1": 1.0,
"temp_cal_a0": 0.0,
"hum_cal_a1": 1.0,
"hum_cal_a0": 0.0
}
- Save with ctrl+s and close with ctrl+x.
- The color scheme of the GUI can be customized in
~/.config/crowdbike/theme.json
. - These keys must be present.
- Colors can be hexadecimal values or standard names like
red
,green
, etc. b_*
= buttonbg_*
= backgroundfg_*
= foregroundf_*
= font
{
"font_size": 24,
"f_family": "Helvetica",
"bg_col": "#36393f",
"fg_col": "#ffffff",
"fg_header": "#AAB8E8",
"b_col": "#7289da",
"b_disabled": "#5B6DAE",
"b_hover": "#546cb2",
"b_hl_border": "#AAB8E8"
}
- Run the software by entering
crowdbike run
(It may take a moment to start). A window with a graphical user interface should appear.
- If no values are currently available, they will be displayed as
nan
, and the 'Counter' will be highlighted in red.- This may occur if:
- The GPS has not yet acquired a signal,
- The PM sensor is not connected or properly connected
- If everything is functioning correctly, the counter will be highlighted in green.
- This may occur if:
- Once the program is started, data will be recorded.
- The current values will be displayed and updated automatically.
- The 'PM-Sensor' switch toggles the query of the particulate matter sensor on or off and puts it into sleep mode if connected.
- If no PM sensor is connected, the switch should be off (red).
- Data recording can be stopped by pressing the 'Stop' button.
- A new recording can be started with Record.
- To exit the program and end the recording, use the 'Exit' button.
-
The LEDs on the status indicator are linked to the sensor threads, blinking once for each recorded measurement.
-
Keep an eye on these during measurement; if the LEDs stop blinking, check the cable connections and restart the program.
-
The GPS (green) will only start blinking when satellites are found.
LED Meaning Measurement Active Measurement Inactive red Temperature Sensor blinking off yellow PM Sensor blinking off green GPS blinking off
-
To make it easier to start the program on a smartphone, create a shortcut:
- Navigate to the Desktop with
cd ~/Desktop/
- Create a new file with
nano start_crowdbike.sh
- Write the following into the file:
crowdbike run
- Save with ctrl+s and close with ctrl+x
- The script needs to be made executable by entering
chmod +x start_crowdbike.sh
and confirming withEnter
.
- Navigate to the Desktop with
-
Turn on the hotspot on your smartphone; the Raspberry Pi should connect automatically if no other known, stronger Wi-Fi networks are present.
-
Open the VNC Viewer on the smartphone (no registration required!)
-
Add a connection by pressing +
-
Enter the hostname, e.g., (
crowdbike1
) underAddress
. If it does not work, check the connected devices under the hotspot settings on your smartphone. Clicking oncrowdbike1
will display the IP address. Note this and enter it instead of the hostname. If the connection created in VNC Viewer does not work the next time, the smartphone might have assigned a different IP address to the Raspberry Pi. Check this as described above and try again. -
Set the connection name, e.g.,
'crowdbike1'
-
The touchscreen of the smartphone will now function like a touchpad for the laptop.
-
The script we created should now be visible on the Desktop. Double-click and click on Run to start the program after a short delay.
- To install a new version if available, use the following command:
sudo pip3 install git+https://github.com/RUBclim/crowdbike.git@master --upgrade
- The current version can be checked via the terminal with
crowdbike --version
.
- Data can be uploaded using the Upload button in the GUI. The measurement must be stopped with the Stop button first.
- The upload may take a few seconds depending on the amount of data. During this time, the displayed measurements will not update because the upload process is not asynchronous (#13).
- A progress bar shows the upload progress and the files uploaded.
- The upload can also be started after closing the program with
crowdbike upload
.
- The program writes a system log to
~/crowdbike.log
, where errors are recorded depending on the log level. - The location of the log file can be changed with
crowdbike run --logfile /home/pi/Documents
. - The log level can also be adjusted with
crowdbike run --loglevel DEBUG
.
pi@crowdbike:~ $ crowdbike --help
usage: crowdbike [-h] [-V] [--logfile LOGFILE]
[--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
{init,run,upload}
positional arguments:
{init,run,upload}
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--logfile LOGFILE file to write the system logs to
--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Andreas Christen (2018): Meteobike - Mapping urban heat islands with bikes. GitHub. [19.01.2020].