Commit 7c7b07ee authored by coliss86's avatar coliss86
Browse files

Doc updated

parent 86097752
Arduino-controller
Copyright (C) 2015-2016 Guillaume Membré
Copyright (C) 2015-2019 Guillaume Membré
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......
# Arduino controller
Set of programs to control easily from a perl script an Arduino to switch on or off a relay card, retrieve temperature
from DS18B20 sensors and even display the load average on vumeter.
Set of programs to control easily from a perl script an Arduino to switch on or off a relay card, retrieve temperature from DS18B20 sensors and even display the load average on vumeter.
Find out more info (in french) at [my homepage](https://www.geekeries.fun/realisations_arduino_start.html)
......@@ -21,12 +20,12 @@ Install the following for the perl script :
- `libfilesys-df-perl` : to read file system space remaining
- `libsys-cpuload-perl` : to read cpu load
1. On a debian based distribution,
1. On a Debian based distribution,
```
$ sudo apt install libdir-self-perl libdevice-serialport-perl libconfig-simple-perl libfilesys-df-perl libsys-cpuload-perl
```
1. Create the configuration file `/etc/arduino.cfg`
2. Create the configuration file `/etc/arduino.cfg`
```ini
# device path
tty=/dev/ttyArduino
......@@ -63,17 +62,19 @@ sensor6=pressure : pressure
fs_to_monitor=/mnt/media
```
Optionnaly, add a `udev` rule the fix the name of the `/dev/` device. Create a file `/etc/udev/rules.d/77-arduino.rules` :
3. Optionnaly, add a `udev` rule to fix the name of the `/dev/` device created when pluging in the usb cable from the Arduino.
Create a file `/etc/udev/rules.d/77-arduino.rules` with :
```text
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0001", SYMLINK+="ttyArduino"
```
Reload the rules :
Next, reload the rules :
```
sudo udevadm control --reload-rules
```
Unplug and plug in the Arduino.
If you have trouble with device busy or lock, you can add another udev rule to disable ModemManager for the Arduino (it thinks is a modem).
Create or edit the file `/etc/udev/rules.d/77-arduino.rules` :
If you have trouble with device busy or lock, add another `udev` rule to disable `ModemManager` for the Arduino (it thinks it is a modem).
Add the following to the file `/etc/udev/rules.d/77-arduino.rules` :
```text
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0001", ENV{ID_MM_DEVICE_IGNORE}="1"
```
......@@ -81,6 +82,7 @@ Reload the rules :
```
sudo udevadm control --reload-rules
```
Unplug and plug in the Arduino.
### Arduino sketch
......@@ -103,23 +105,22 @@ The sketch is also able to handle thermal sensors DS18B20 connected to pin numbe
### Software
A perl script communicate through the emulated serial port with the Arduino with a simple text protocol to retrieve
state, temperature and switch on or off outputs. The Arduino listens for order and executes them.
The perl script communicates through the emulated serial port with the Arduino with a simple text protocol to execute command in order to retrieve state, temperature and to switch on or off outputs. The Arduino waits for commands and executes them.
#### Arduino
Just load the sketch with the Arduino IDE and upload it.
Just load the sketch with the Arduino IDE, compile it and upload it.
Next, open a serial console.
On linux, you can use `picocom` :
```shell
```sh
picocom /dev/ttyACM0 -b 9600
```
##### Welcome message
Like a shell, a prompt listen for inputs. To display the help, just type **h**.
```
Like a shell, a prompt listens for inputs. To display the list of available commands, type `h` :
```sh
> h
___ _ _
/ _ \ | | (_)
......@@ -128,20 +129,21 @@ Like a shell, a prompt listen for inputs. To display the help, just type **h**.
| | | | | | (_| | |_| | | | | | (_) |
\_| |_/_| \__,_|\__,_|_|_| |_|\___/
Build Feb 7 2015 : 14:10:41
Help
Command available :
<pin number [2-9]>=<0,1>
h - help
s - i/o status
t - temperature
Commands available :
pin <pin number [4-8]> <0,1> - set pin value
h|help - help
s|io|status - i/o status
t|temp - temperature
p|pressure - pressure
load1 <val> - set load (1 min) value (log scaled)
load5 <val> - set load (5 min) value (log scaled)
disk <val> - set disk value
```
##### Output controller
To display the state of outputs, type **s**
```shell
```sh
> s
I/O Status :
2 => 0
......@@ -156,15 +158,15 @@ I/O Status :
The output 2 to 9 are listed and they are all in low (0) state.
For my needs, outputs connected to relay are inverted. The are identified with the `(R)` symbol.
In order to switch an output on or off, the command is composed from the output number followed by the sign = and with `1` (high) or `0` (low).
In order to switch an output on or off, the command is composed from the output number followed by the sign `=` and with `1` (high) or `0` (low).
eg : switch on the output n°2 :
```shell
```sh
> 2=1
OK
```
Check the state :
```shell
```sh
> s
I/O Status :
2 => 1
......@@ -177,7 +179,7 @@ I/O Status :
9 => 0 (R)
```
To setup pins output for relay, you'll need to edit sketch.ino to change the array accordingly.
To setup pins output for relay, you'll need to edit `sketch.ino` to change the array accordingly.
* `0` is normal output
* `1` is for inverted output
......@@ -189,7 +191,7 @@ const int relays[NB_OUTPUT] = {0,0,0,0,0,0,1,1,1,1};
##### Temperature
In order to display the temperature, type **t**. The program look for any thermal sensors DS18B20 connected to it, for each found, it request the temperature and displays it in Celsius.
```shell
```sh
> t
Temperature :
ROM = [ 28 A 4C 3B 4 0 0 5B ] - Temperature : 12.69 °C
......@@ -203,7 +205,7 @@ The perl script handles the communication described above and offer a cli usage.
#### Usage
Usage :
```shell
```sh
> ./pin.pl
./pin.pl [-p dev] (<pin> <state> | status)
<dev> - device [/dev/ttyACM0]
......@@ -213,7 +215,7 @@ Usage :
```
Display the state of output, like above :
```shell
```sh
> ./pin.pl status
Status
2 => 1
......@@ -227,12 +229,12 @@ Status
```
Switch on the output number 2
```shell
```sh
> ./pin.pl 2 on
```
toggle an output
```shell
```sh
> ./pin.pl 2 toggle
```
......@@ -253,8 +255,12 @@ and then the line added to the file is :
```
Usage :
```shell
```sh
> ./temperature.pl
./temperature.pl usage:
-d : debug output
```
## License
Arduino-controller is distributed under [GPL v3 License](LICENSE).
```
Scan 1-Wire bus
@ : 28 65 DC 33 04 00 00 17 = DS18B20
......@@ -43,3 +44,4 @@ ROM [ 28 65 DC 33 04 00 00 17 ] = 25.63 °C
>
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment