diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c41356a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +serial2mqtt.ini diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0f36323 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: master + hooks: + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: double-quote-string-fixer + - id: end-of-file-fixer + - id: fix-encoding-pragma + args: ['--remove'] + - id: requirements-txt-fixer + - id: trailing-whitespace + - repo: https://gitlab.com/pycqa/flake8 + rev: master + hooks: + - id: flake8 + args: ['--max-line-length=120'] + - repo: https://github.com/FalconSocial/pre-commit-python-sorter + rev: master + hooks: + - id: python-import-sorter + args: ['--silent-overwrite'] + - repo: https://github.com/chewse/pre-commit-mirrors-pydocstyle + rev: master + hooks: + - id: pydocstyle + args: ['--config=.pydocstyle', '--match="(?!test_).*\.py"'] + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: master + hooks: + - id: shfmt diff --git a/.pydocstyle b/.pydocstyle new file mode 100644 index 0000000..aef2483 --- /dev/null +++ b/.pydocstyle @@ -0,0 +1,2 @@ +[pydocstyle] +ignore = D100,D104,D400,D203,D204,D101,D213,D202 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1b9d60 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# arduino-sensors-toolkit + +This toolkit has been designed to be used with a DHT22 (humidity, temperature) and KY-037 (sound) sensors connected to +an Arduino microcontroller. It is part of a self hosting project with specific needs. Feel free to fork this repository +and update code for your needs. + +## sensors2serial + +Arduino circuit: + +![Circuit](static/circuit.svg) + +## serial2mqtt + +### Requirements + +- serial interface using sensors2serial code (ex: /dev/cuaU0 for FreeBSD, /dev/ttyACM0 for Debian) +- MQTT broker (ex: [Mosquitto](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-debian-10)) + +### Installation + +- Installation on [Debian](debian/README.md) +- Installation on [FreeBSD](freebsd/README.md) + +### Configuration + +An optional configuration file can be used with `--config `. See [serial2mqtt.ini.example](serial2mqtt.ini.example). + +### Usage + +``` +python3 serial2mqtt.py --help +``` diff --git a/debian/README.md b/debian/README.md new file mode 100644 index 0000000..917bb88 --- /dev/null +++ b/debian/README.md @@ -0,0 +1,22 @@ +# Installation on Debian + +Install the following packages: +- python3-serial +- python3-paho-mqtt + +Then git clone this repository to **/opt/arduino-sensors-toolkit**. + +Create the *serial2mqtt* system user and add it to the *dialout* group to read the serial interface: +``` +# adduser --system --disabled-password --disabled-login --home /var/lib/serial2mqtt \ + --no-create-home --quiet --force-badname --group serial2mqtt +# usermod -a -G dialout serial2mqtt +``` + +Copy the [serial2mqtt.service](serial2mqtt.service) file to **/etc/systemd/system/serial2mqtt.service**. + +Copy the [serial2mqtt.default](serial2mqtt.default) file to **/etc/default/serial2mqtt**. + +Reload systemd configuration with `systemctl daemon-reload`. + +Enable service with `systemctl enable serial2mqtt.service`. diff --git a/debian/serial2mqtt.default b/debian/serial2mqtt.default new file mode 100644 index 0000000..de54855 --- /dev/null +++ b/debian/serial2mqtt.default @@ -0,0 +1,2 @@ +# Options passed as daemon argument +#DAEMON_OPTS="-c /etc/serial2mqtt.ini -v" diff --git a/debian/serial2mqtt.service b/debian/serial2mqtt.service new file mode 100644 index 0000000..caf42a6 --- /dev/null +++ b/debian/serial2mqtt.service @@ -0,0 +1,16 @@ +[Unit] +Description=Read serial port and send sensors measurements to MQTT broker +After=syslog.target network.target + +[Service] +Type=simple +User=serial2mqtt +Group=serial2mqtt +EnvironmentFile=-/etc/default/serial2mqtt +ExecStart=/opt/arduino-sensors-toolkit/serial2mqtt.py $DAEMON_OPTS +KillMode=process +TimeoutSec=30 +Restart=no + +[Install] +WantedBy=multi-user.target diff --git a/freebsd/README.md b/freebsd/README.md new file mode 100644 index 0000000..a386998 --- /dev/null +++ b/freebsd/README.md @@ -0,0 +1,20 @@ +# Installation on FreeBSD + +Install the following packages: +- py37-pyserial +- py37-paho-mqtt + +Then git clone this repository to **/usr/local/share/arduino-sensors-toolkit**. + +Create the system user: + +``` +pw user add -n serial2mqtt -s /usr/sbin/nologin -G dialer +``` + +Copy [serial2mqtt.rc](serial2mqtt.rc) script to **/usr/local/etc/rc.d/serial2mqtt**. + +Enable service: +``` +echo 'serial2mqtt_enable="YES"' >> /etc/rc.conf +``` diff --git a/freebsd/serial2mqtt.rc b/freebsd/serial2mqtt.rc new file mode 100755 index 0000000..c6b6db2 --- /dev/null +++ b/freebsd/serial2mqtt.rc @@ -0,0 +1,65 @@ +#!/bin/sh +# PROVIDE: serial2mqtt +# REQUIRE: DAEMON NETWORKING +# BEFORE: LOGIN +# KEYWORD: shutdown + +# serial2mqtt_enable (bool): Set to YES to enable serial2mqtt +# Default: NO +# serial2mqtt_conf (str): serial2mqtt configuration file +# Default: ${PREFIX}/etc/serial2mqtt.ini +# serial2mqtt_user (str): serial2mqtt daemon user +# Default: serial2mqtt +# serial2mqtt_group (str): serial2mqtt daemon group +# Default: serial2mqtt +# serial2mqtt_flags (str): Extra flags passed to serial2mqtt +# Default: none + +. /etc/rc.subr + +PATH=${PATH}:/usr/local/sbin:/usr/local/bin + +name="serial2mqtt" +rcvar=serial2mqtt_enable +load_rc_config $name + +: ${serial2mqtt_enable:="NO"} +: ${serial2mqtt_user:="serial2mqtt"} +: ${serial2mqtt_group:="serial2mqtt"} +: ${serial2mqtt_flags:=""} +: ${serial2mqtt_conf:="/usr/local/etc/${name}.ini"} +: ${serial2mqtt_options:="${serial2mqtt_flags}"} + +if [ -f ${serial2mqtt_conf} ]; then + serial2mqtt_options="${serial2mqtt_options} --config ${serial2mqtt_conf}" +fi + +logfile="/var/log/serial2mqtt/${name}.log" +pidfile="/var/run/${name}.pid" +command=/usr/sbin/daemon +start_precmd="serial2mqtt_prestart" +start_cmd="serial2mqtt_start" +stop_cmd="serial2mqtt_stop" + +serial2mqtt_prestart() { + install -d -o ${serial2mqtt_user} -g ${serial2mqtt_group} -m750 /var/log/serial2mqtt +} + +serial2mqtt_start() { + echo "Starting ${name}" + /usr/sbin/daemon -fcr -P ${pidfile} -u ${serial2mqtt_user} -o ${logfile} \ + /usr/local/bin/python3.7 /usr/local/share/arduino-sensors-toolkit/${name}.py ${serial2mqtt_options} +} + +serial2mqtt_stop() { + pid=$(check_pidfile $pidfile $command) + if [ -n "${pid}" ]; then + echo "Stopping ${name} (pid=${pid})" + kill -- -${pid} + wait_for_pids ${pid} + else + echo "${name} isn't running" + fi +} + +run_rc_command "$1" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..df8423a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +paho-mqtt==1.5.0 +pyserial==3.4 diff --git a/sensors2serial.ino b/sensors2serial.ino new file mode 100644 index 0000000..32befeb --- /dev/null +++ b/sensors2serial.ino @@ -0,0 +1,37 @@ +#include + +#define KYPIN A0 // analog pin where KY-037 sensor is connected +#define DHTPIN 2 // digital pin where DHT22 sensor is connected + +DHT dht(DHTPIN, DHT22); // initialize DHT22 object + +float h; // humidity +float t; // temperature +int s; // sound + +void setup() +{ + Serial.begin(9600); + dht.begin(); +} + +void loop() +{ + // sensors need some time to produce valid values + delay(2000); + + // read values from sensors + h = dht.readHumidity(); + t = dht.readTemperature(); + s = analogRead(KYPIN); + + // print ",," (CSV-like) + // all values are numbers + if (!isnan(h) && !isnan(t) && !isnan(s)) { + Serial.print(h); + Serial.print(","); + Serial.print(t); + Serial.print(","); + Serial.println(s); + } +} diff --git a/serial2mqtt.ini.example b/serial2mqtt.ini.example new file mode 100644 index 0000000..cc50fb2 --- /dev/null +++ b/serial2mqtt.ini.example @@ -0,0 +1,10 @@ +[mqtt] +host = localhost +port = 1883 +#client_id = serial2mqtt +#topic_prefix = sensors +#username = *** +#password = *** + +[serial] +interface = /dev/cuaU0 diff --git a/serial2mqtt.py b/serial2mqtt.py new file mode 100755 index 0000000..2a19e6e --- /dev/null +++ b/serial2mqtt.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +import argparse +import configparser +import logging +import os +import sys +import time + +import paho.mqtt.client as paho +import serial + +logger = logging.getLogger(__name__) + + +def read_serial(interface): + try: + logger.debug('reading serial interface {}'.format(interface)) + s = serial.Serial(interface) + s.flushInput() + for i in range(2): + data = s.readline() + if i > 0: + return data + except Exception as err: + logger.warning(str(err)) + time.sleep(2) + + +def parse_sensor_values(data): + """ + Input line: ,, + Output structure: + data = { + 'humidity': , + 'temperature': , + 'sound': + } + """ + humidity, temperature, sound = data.decode('utf-8').strip().split(',') + return {'humidity': humidity, 'temperature': temperature, 'sound': sound} + + +def connect_mqtt(config): + """Connect to MQTT broken from MQTT config and return client""" + mqtt_host = config.get('host', 'localhost') + mqtt_port = int(config.get('port', 1883)) + mqtt_username = config.get('username') + mqtt_password = config.get('password') + mqtt_client_id = config.get('client_id', 'serial2mqtt') + + client = paho.Client(client_id=mqtt_client_id) + client.on_connect = on_connect + if mqtt_username: + client.username_pw_set(username=mqtt_username, password=mqtt_password) + logging.debug('connecting to MQTT broker at {}:{}'.format(mqtt_host, mqtt_port)) + client.connect(mqtt_host, mqtt_port) + return client + + +def publish(client, topic, value): + logger.debug('publishing to topic "{}" with value "{}"'.format(topic, value)) + client.publish(topic, value) + + +def on_connect(client, userdata, flags, rc): + if rc > 0: + logger.error(paho.connack_string(rc)) + else: + logger.info('connected to MQTT broker') + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-c', '--config', help='path to configuration file', default='serial2mqtt.ini') + parser.add_argument('-v', '--verbose', dest='loglevel', action='store_const', const=logging.INFO, + help='print more output') + parser.add_argument('-d', '--debug', dest='loglevel', action='store_const', const=logging.DEBUG, + default=logging.WARNING, help='print even more output') + args = parser.parse_args() + + logging.basicConfig(format='%(levelname)s: %(message)s', level=args.loglevel) + + config = configparser.ConfigParser() + if os.path.isfile(args.config): + config.read(args.config) + + mqtt_config = config['mqtt'] if 'mqtt' in config else {} + mqtt_topic_prefix = mqtt_config.get('topic_prefix', 'sensors') + serial_config = config['serial'] if 'serial' in config else {} + + try: + client = connect_mqtt(mqtt_config) + except Exception as err: + logger.error('connection to MQTT broker failed: {}'.format(str(err))) + sys.exit(1) + + try: + client.loop_start() + + while True: + data = read_serial(serial_config.get('interface', '/dev/cuaU0')) + if data: + data = parse_sensor_values(data) + for sensor_name, value in data.items(): + topic = '/'.join([mqtt_topic_prefix, sensor_name]) + publish(client, topic, value) + except KeyboardInterrupt: + pass + + +if __name__ == '__main__': + main() diff --git a/static/circuit.svg b/static/circuit.svg new file mode 100644 index 0000000..eda7705 --- /dev/null +++ b/static/circuit.svg @@ -0,0 +1,8717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 1 + + + 5 + + + 5 + + + 10 + + + 10 + + + 15 + + + 15 + + + 20 + + + 20 + + + 25 + + + 25 + + + 30 + + + 30 + + + 35 + + + 35 + + + 40 + + + 40 + + + 45 + + + 45 + + + 50 + + + 50 + + + 55 + + + 55 + + + 60 + + + 60 + + + A + + + A + + + B + + + B + + + C + + + C + + + D + + + D + + + E + + + E + + + F + + + F + + + G + + + G + + + H + + + H + + + I + + + I + + + J + + + J + + + + + + + + layer 21 + + + text:MADE IN + + + text:ITALY + + + text:Prototype + + + text:Limited + + + text:Edition + + + + + + + + + + + + + + + + + + + + + + + + + 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:L + + text:L + + + + + + + + + + L + + + + + + + + + + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + + layer 25 + + + + + + + + 5V + + + + + + + + + text:A0 + + + + + + + + + + A0 + + + + + + + + + + + + + + + + + + + + + + ANALOG IN + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AREF + + + + + + + + + + + + + + + + + + + + + + + + + text:1 + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + + + + + text:M.Banzi + + + text:D.Cuartielles + + + text:D.Mellis + + + text:TX + + + + + + + + + + TX + + + + + + + + + + + + text:RX + + + + + + + + + + RX + + + + + + + + + + + + text:G.Martino + + + text:T.Igoe + + + + + + + + + + + + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3V3 + + + + + + + + + + + + + + + + + + + + + + + + + text:A1 + + + + + + A1 + + + + + + + + text:A2 + + + + + + + + + + A2 + + + + + + + + + + + + text:A3 + + + + + + + + + + A3 + + + + + + + + + + + + text:A4 + + + + + + + + + + A4 + + + + + + + + + + + + text:A5 + + + + + + + + + + A5 + + + + + + + + + + + + + + + + + + + + + + VIN + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + + + + + + + + + + + GND + + + + + + + + + + + + + text:[#=PWM] + + + + + + + + + + DIGITAL (PWM= + + + + + + + + + + + + + + + + + + + + + + + + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:Arduino + + + + + + + + + + Arduino + + + + + + + + + + + + text:TM + + + + + + + + + + TM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IOREF + + + + + + + + + + + + + + + + + + + + + + + + + text:SDA + + + text:SCL + + + element:AD + + package:1X06 + + + + element:C1 + + package:C0603-ROUND + + + + element:C2 + + package:C0603-ROUND + + + + element:C3 + + package:C0603-ROUND + + + + element:C4 + + package:C0603-ROUND + + + + element:C5 + + package:C0603-ROUND + + + + element:C6 + + package:C0603-ROUND + + + + element:C7 + + package:C0603-ROUND + + + + element:C8 + + package:C0603-ROUND + + + + element:C9 + + package:C0603-ROUND + + + + element:C11 + + package:C0603-ROUND + + + + element:D1 + + package:SMB + + + + element:D2 + + package:MINIMELF + + + + element:D3 + + package:MINIMELF + + + + element:F1 + + package:L1812 + + + + element:FD1 + + package:FIDUCIA-MOUNT + + + + element:FD2 + + package:FIDUCIA-MOUNT + + + + element:FD3 + + package:FIDUCIA-MOUNT + + + + element:GROUND + + package:SJ + + + + element:ICSP + + text:ICSP + + + + + + + + + + + + + + + + + + + + + + ICSP + + + + + + + + + + + + + + + + + + + + + + + + package:2X03 + + + + element:ICSP + + text:ICSP + + + + + + + + + + + + + + + + + + + + + + ICSP2 + + + + + + + + + + + + + + + + + + + + + + + + package:2X03 + + + + element:ICSP1 + + package:2X03 + + + + element:IOH + + package:1X10@1 + + + + element:IOL + + package:1X08 + + + + element:JP2 + + package:2X02 + + + + element:L + + package:CHIP-LED0805 + + + + element:L1 + + package:0805 + + + + element:ON + + text:ON + + + + + + ON + + + + + + + + package:CHIP-LED0805 + + + + element:PC1 + + package:PANASONIC_D + + + + element:PC2 + + package:PANASONIC_D + + + + element:R1 + + package:R0603-ROUND + + + + element:R2 + + package:R0603-ROUND + + + + element:RESET + + package:TS42 + + + + element:RESET-EN + + package:SJ + + + + element:RN1 + + package:CAY16 + + + + element:RN2 + + package:CAY16 + + + + element:RN3 + + package:CAY16 + + + + element:RN4 + + package:CAY16 + + + + element:RX + + package:CHIP-LED0805 + + + + element:T1 + + package:SOT-23 + + + + element:TX + + package:CHIP-LED0805 + + + + element:U1 + + package:SOT223 + + + + element:U2 + + package:SOT23-DBV + + + + element:U3 + + package:MLF32 + + + + element:U5 + + package:MSOP08 + + + + element:X1 + + package:POWERSUPPLY_DC-21MM + + + + element:X2 + + package:PN61729 + + + + element:Y1 + + package:QS + + + + element:Y2 + + package:RESONATOR + + + + element:Z1 + + package:CT/CN0603 + + + + element:Z2 + + package:CT/CN0603 + + + + element:ZU4 + + package:DIL28-3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + POWER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TX0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RX0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text:RESET + + + + + + + + + + RESET + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + layer 21 + + element:C1 + + package:0402-CAP + + + + + element:C2 + + package:0402-CAP + + + + + element:C3 + + package:0402-CAP + + + + + element:C4 + + package:0402-CAP + + + + + element:JP1 + + package:1X03 + + + + + + + + + + + + + + + + + + + + + + + + element:JP2 + + package:FIDUCIAL-1X2 + + + + element:JP3 + + package:FIDUCIAL-1X2 + + + + element:M1 + + package:MIC-9.7MM + + + + element:R1 + + package:0402-RES + + + + element:R2 + + package:0402-RES + + + + element:R3 + + package:0402-RES + + + + element:R4 + + package:0402-RES + + + + element:R5 + + package:0402-RES + + + + element:U$1 + + package:SFE-LOGO-FLAME + + polygon + + + + + + element:U1 + + package:SOT23-5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +