=======Phototubridostat V1======= {{:57650866_1718420958304485_5536679600114892800_n.jpg?600 |}} ======Introduction====== This guide explain how to build from scratch the BotaBotLab's Phototubridostat V1. This device integrate autonomous sub-modules that can be used for different applications. The following module are described in this guide but more detailed information can be found on their specific guides: * [[:Wi-Fi Persitaltic pumps V1]] * [[:Wi-Fi Level sensor (pump calibrator) V1]] * [[:Wi-Fi Turbidimeter V1]] * [[:Wi-Fi Neopixel light V1]] * [[:How to operate]] ======Material====== =====Microcontrollers===== * Arduino Mega * Arduino Nano * Arduino Pro Mini * [[https://wiki.wemos.cc/products:d1:d1_mini|Wemos D1 Mini]] * [[https://www.instructables.com/id/Getting-Started-With-the-ESP8266-ESP-01/|ESP-O1]] * [[https://www.instructables.com/id/Getting-Started-With-ESP8266LiLon-NodeMCU-V3Flashi/|Wemos D1 Node MCU V3]] You can use cheaper Arduino and Wemos clones =====Electronic===== * [[https://pi.gate.ac.uk/pages/airpi-files/PD0001.pdf|GL5528 Photoresistor]] * 10KOhm resistor * 470µF 5V capacitor =====Single Board Computer===== We used an [[http://www.orangepi.org/OrangePiWinPlus/|Orange Pi Win Plus]] but any SBC would work as long as it is able to run Node-Red. =====Tools and Consumables===== * 3D Printer * Soldering iron * Screwdriver, plier, ... * 1.75mm Plastic (ABS, PLA, PETG, ...) * Solder wire * Expoxy resin ======Softwares====== * [[https://www.arduino.cc/en/Main/Software |Arduino IDE]] or any IDE compatible with Arduino and ESP boards * [[https://www.repetier.com/download-software/ |Repetier]] or any software to slices 3D models and control your 3D printer * [[https://nodered.org/ |Node-Red]] * [[https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html/ | Putty]] * [[https://www.balena.io/etcher/|Etcher]] ---- ======1. Prepare your SBC====== =====1.1 Install the operating system===== By default, the Arduino IDE is compatible only with the Arduino Boards. As we also wanted to use ESP8266 board to being able to communicate with the Node-Red server via MQTT, it is mandatory to add ESP support to the Arduino IDE. Further infromation can be found on [[https://www.instructables.com/id/Programming-the-WeMos-Using-Arduino-SoftwareIDE/ |The following instructable]] [[https://www.raspberrypi.org/documentation/installation/installing-images/|How to install Raspbian on a Raspberry Pi ?]] [[https://docs.armbian.com/User-Guide_Getting-Started/| How to install Armbian ?]] All the terminal commands can be type directly on the SBC (it will require and monitor and a keyboard) but also from an other computer (Windows/Linux/Mac) via [[https://www.wikiwand.com/en/Secure_Shell|SSH]] (much more convenient). [[https://www.raspberrypi.org/documentation/remote-access/ssh/| How to activate SSH on Raspbian ?]] On Armbian SSH ins enabled by default. For Windows user : Putty allow to easily control your device by SSH. [[https://www.ssh.com/ssh/putty/windows/| How to use Putty on Windows ?]] =====1.2 Setup Node-Red===== Some Single Board Computer distributions such as [[https://www.raspberrypi.org/downloads/raspbian/|Raspbian]] for the Raspberry Pi have Node-Red preinstalled. It was not the case for the Armbian distro for the Orange Pi. The following commands allows to install and setup Node-Red on almost any SBC (et least thoses running on Ubuntu/Debian). First of all, update your board by typing the following commands on the terminal : sudo apt update sudo apt upgrade Then you can install Node-Red curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - sudo apt install -y nodejs sudo npm install -g --unsafe-perm node-red To automatically start Node-Red on boot you can use the following command (for Raspberry Pi) sudo systemctl enable nodered.service The previous command will not work for SBC that do not have Node-Red pre-installed because the nodered service does not exist. It is therefore necessary to create it as follows: sudo nano /etc/systemd/system/node-red.service This command will create an empty node-red.service, which must be completed by this (don't forget to place the specific name of your device) : [Unit] Description=Node-RED After=syslog.target network.target [Service] ExecStart=/usr/bin/node-red --max-old-space-size=128 -v Restart=on-failure KillSignal=SIGINT SyslogIdentifier=node-red StandardOutput=syslog WorkingDirectory=/home/PLACE USER NAME HERE/ User=root Group=root [Install] WantedBy=multi-user.target Finally, you should be able to enable the service node-red as for the Raspberry Pi sudo systemctl enable node-red.service To manually start Node-Red, type the following command in the terminal : node-red The Grapical User interface should be accessible by any computer/smartphone connected to the same network as your server. To know the local IP of your server type this command in the terminal : ifconfig The local IP should appear here. {{:ip_opi.png?600|}} This command also allows you to obtain your IP address : hostnname -I On your Web-Browser type **yourserverip:1880** in this example **192.168.8.10:1880**. The following windows will appear : {{ :clean_node-red.png?800 |}} [[https://nodered.org/docs/|Node-Red Documentation]] Now that Node-Red is installed, you will need to add some libraries (**Manage palette** on the top right corner) to be able to run our program correctly. The required libraries are : * node-red-contrib-modbus * node-red-contrib-multipart-stream-decoder * node-red-contrib-nora * node-red-contrib-opi-gpio * node-red-contrib-stoptimer * node-red-dashboard * node-red-node-base64 * node-red-node-serialport You can finally [[http://www.steves-internet-guide.com/copy-nodes-flows-node-red/|import]] our flow __**LINK**__ =====1.3 Setup the MQTT Broker===== Type the following commands on the terminal (directly from the SBC or by SSH) sudo apt install -y mosquitto mosquitto-clients sudo systemctl enable mosquitto.service The MQTT broker is now installed. All the MQTT nodes should work properly. If the Node-Red server is running on the same device as the Mosquitto broker, it is nos necessary to modify the broker IP.\\ To modify the broker IP, double clic on the MQTT node (the Pink/Purple ones) and replace **localhost:1883** by **brokerIP:1883**\\ The broker IP can be obtained by **ifconfig** or **hostname -I** commands.\\ {{ :mqtt_broker_ip.png?600 |}} ======2. Setup your computer====== __**Work in progress**__ ======3. 3D Files====== __**Work in progress**__ ======4. Arduino Programming====== __**Work in progress**__ ======5. Wemos Programming====== __**Work in progress**__ ======6. Turbidimeter====== __**Work in progress**__ ======7. Lighting system====== __**Work in progress**__ ======8. Pumps ====== __**Work in progress**__ ======9. Pumps Calibrator ====== __**Work in progress**__ ======10. Power Supply====== __**Work in progress**__