Welcome to Pidas’s documentation!¶
Raspberry Pi configuration¶
Power with USB to TTL serial cable connection¶
- Pin 2: 5V(red)
- Pin 6: Gnd (Black)
- Pin 8 : Tx (White)
- Pin 10: Rx (Green)
Change keyboard layout¶
Install required packages:
sudo apt-get install console-data keyboard-configuration
Reconfigure and choose from the list:
dpkg-reconfigure console-data
dpkg-reconfigure keyboard-configuration
service keyboard-setup restart
Create user¶
useradd username -m -p password
usermod -aG dialout,sudo username
Static ip¶
Edit /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address X.X.X.X
netmask 255.255.255.0
gateway X.X.X.1
Change computer name¶
Edit /etc/hosts:
127.0.0.1 localhost
127.0.1.1 COMPUTER_NAME
Edit /etc/hostname:
COMPUTER_NAME
Add 1-Wire support¶
Start by adding the following line to /boot/config.txt
You can edit that file with nano by running sudo nano /boot/config.txt and then scrolling to the bottom and typing it there
dtoverlay=w1-gpio
Add the required modules at the bottom of /etc/modules
w1-gpio
w1-therm
reboot with sudo reboot
Test
cd /sys/bus/w1/devices
ls
cd 28-xxxx (change this to match what serial number pops up)
cat w1_slave
Script to add Arduino vendor info¶
This is useful to upload Arduino code from the Pi to the Arduino board
Create a file get_arduino_id.sh, and copy this content:
echo "Getting usb ids for Arduino…"
# Search for the keyword Arduino and print the sixth column of that line
vendorInfo=$(lsusb | awk '/Arduino/ {print $6}')
idVendor=${vendorInfo:0:4}
idProduct=${vendorInfo:5:4}
symlink="USBT001"
echo "Writting vendor info..."
echo "SUBSYSTE M=='tty', ATTRS{idVendor}==$idVendor, ATTRS{idProduct}==$idProduct, SYMLINK=$symlink" > /etc/udev/rules.d/99-usb_serial.rules
Make it executable:
chmod +x get_arduino_id.sh
Connect your arduino board and launch the script:
sh get_arduino_id.sh
Getting started¶
Get the code:
git clone https://github.com/UMONS-GFA/pidas.git
Create a settings.py file in the pidas/pidas directory. Your can now configure your custom settings.
DATABASE
¶
InfluxDB is used. This can be configured using the following:
DATABASE = {
'HOST': '127.0.0.1',
'PORT': 8086,
'USER': 'mydatabaseuser',
'PASSWORD': 'mypassword',
'NAME': 'mydatabase'
}
Automatization¶
Edit your cron file:
crontab -e
Add your PYTHONPATH at the beginning of the file
PYTHONPATH=/home/USERNAME/pidas
And add a command to launch the script at boot:
@reboot /usr/bin/python3 /home/USERNAME/pidas/pidas/save_sensor_data.py >> /home/USERNAME/pidas/pidas/cronlog 2>&1
How to use minicom¶
Installation¶
apt-get install minicom
Configure¶
sudo minicom -s
Serial port configuration¶
Press A to edit Serial port to : /dev/ttyUSB0 then press Enter
Press E to edit baud speed to 9600 then press Enter
Press F to disable hardware flow control
To get out, press Enter Save the config as dfl
Press Esc to use minicom
Utilisation
Press Ctrl+A then Z to enter the menu Press E to activate echo
Press Esc to return to minicom
To quit minicom, press Ctrl+A then Q to quit