Skip to content

Commit

Permalink
added onboarding docs!
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakota Chang authored and Dakota Chang committed Jan 26, 2024
1 parent 97400a8 commit 17562d5
Show file tree
Hide file tree
Showing 13 changed files with 843 additions and 131 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified docs/.DS_Store
Binary file not shown.
49 changes: 49 additions & 0 deletions docs/analogy_io.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Understanding I/O Pins as Communication Channels: An Office Analogy

## Overview

In microcontrollers like the Adafruit ESP32 Feather Board, I/O (Input/Output) pins serve as vital communication channels. To understand their role, let's consider an analogy with an office intercom system.

### The Office Scenario

- **The Office:** Represents the microcontroller (Adafruit ESP32 Feather Board).
- **Employees:** Analogous to sensors or devices connected to the microcontroller.
- **Office Intercom System:** Symbolizes the I/O pins.

## Analogous Functions

### Input Pins (Receiving Information)

- **Analogy:** Like an employee receiving instructions via the intercom.
- **Microcontroller Context:** Input pins receive signals or data from sensors or external devices, similar to receiving a message.

### Output Pins (Sending Information)

- **Analogy:** Comparable to an employee sending out a message or report.
- **Microcontroller Context:** Output pins send signals or commands to other devices, much like broadcasting a message.

### Bidirectional Communication

- **Analogy:** Some employees both receive and send out information.
- **Microcontroller Context:** Certain pins can function as both input and output, allowing dynamic interactions.

## Key Points

### Controlled and Specific

- **Analogy:** Each employee has a specific intercom number.
- **Microcontroller Context:** Each I/O pin is designated for specific tasks, handling different types of signals.

### Limited Number

- **Analogy:** Limited lines in an intercom system.
- **Microcontroller Context:** A finite number of I/O pins necessitates efficient use and sometimes additional components like expanders.

### Programming Determines Function

- **Analogy:** The role of each employee is determined by their job description.
- **Microcontroller Context:** The role of each pin is set by how the microcontroller is programmed.

## Conclusion

This analogy helps conceptualize I/O pins as distinct communication channels within a microcontroller system, each playing a unique and programmable role in the interaction between the controller and its connected components. If you still want to learn more, here is the official [explanation](https://learn.adafruit.com/mcus-how-do-they-work/digital-i-o)(more technical/application-based) and [lecture notes by Stanford](https://web.stanford.edu/class/archive/engr/engr40m.1178/slides/arduino.pdf)(more theoretical).
103 changes: 103 additions & 0 deletions docs/computational_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Computational Setup

For this computational setup, we’ll be using Ubuntu as our operating system. This requires dual booting on Windows 11 with Ubuntu 22.04 LTS

<aside>
📝 *This guide is mainly written for Ubuntu users so you may encounter issues otherwise*

</aside>

[Setup for Windows](https://www.notion.so/Setup-for-Windows-21768805f3174ebe9528ec47d72f819c?pvs=21)

### Installing Ubuntu

1. Make partition for installing the OS

- Go to your disk management tool on windows.
- Select your biggest partition (by default the C drive)
- Click “Shrink Volume”
- Shrink 50gb → go to IT if the shrink fails
- Create a new partition

1. Acquire a bootable USB that has the Ubuntu image
2. Restart the computer and enter BIOS settings (Press F2)

- Select the USB with Ubuntu image as the primary boot loader
- Disable Secure Boot if enabled
- Save and exit

1. When the computer starts again, select “Try/Install Ubuntu”

- Stick to the default settings EXCEPT the partition to install Ubuntu on
- Make sure that the selected partition matches the size of the partition you created earlier
- Continue until the installation finishes

## Install VSCode

- Download and install VSCode for respective OS

[](https://code.visualstudio.com/download)

## GitHub Setup

- First make an account if you haven’t already!
- Tell me (@dedeisnerd on discord) your GitHub username
- I’ll add you to the Olin-Hydro organization on GitHub

## GitHub SSH Setup

<aside>
📝 SSH lets you authenticate yourself without having to login to GitHub every single time with username and password. SSH key will be a unique key for your machine, which will be added to your GitHub account — GitHub will then recognize your machine to your user account.

</aside>

1. Create an SSH key on your local machine

`ssh-keygen -t ed25519 -C "[email protected]"`

2. Add that key to your local ssh key agent

`eval "$(ssh-agent -s)"`
`ssh-add ~/.ssh/id_ed25519`

3. Add that key to your GitHub account

`cat ~/.ssh/id_ed25519.pub`

→ Running the line above will return a long string of alphabets and numbers, followed by a space and the email that you entered. Copy the content of this key file by dragging the string and pressing `Ctrl+Shift+C` (`Ctrl+C` will not work on Ubuntu terminal).

- Now, go to your GitHub account settings. Click on the “SSH and GPG keys.”
- Click “New SSH key or Add SSH key”
- Paste the copied key
- Give it a descriptive name, like “Olin Laptop Ubuntu”
- Click “Add SSH key”

- Confirm the authentication
`ssh -T [email protected]`
→ Running this command should say something like “you have authenticated.”

_More information from GitHub:_ https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

## Git Setup

### Configuring Git for you

- Run the command `git config --global user.name "Alan Turing"`, substituting your name for `Alan Turing` (but leaving the quotes in place).
- To set your email, run `git config --global user.email "[email protected]"`, substituting your GitHub email address for `[email protected]`. It’s important that your email match the one that GitHub has, because a mismatch can make Git fail in unintuitive ways.
- To set Git to use VS Code, run `git config --global core.editor "code --wait"`. Again, leave the quotes in place.
- If you mistyped anything in quotes (your name, email, or `code --wait`) you can run that command again with the correct name/email to fix the typo. If you mistyped `user.name``user.email`, or `core.editor` in the commands, you can use `git config --unset user.name` (replacing `user.name` with whatever you mistyped earlier) to remove that setting, and try again.

_The information above was taken from Configuring Git section of Olin’s SoftDes website:_

[Computational Setup Instructions](https://softdes.olin.edu/docs/setup/setup-instructions/#configure-git)

## Install Anaconda

\*Anaconda is a package manager and it will save you from having dependency errors when working with complex packages. Rule of thumb is to always try to use the same package installer. [Installation link](https://docs.anaconda.com/free/anaconda/install/linux/)

If you’re using Ubuntu or MacOS, once you’ve downloaded the program, run:

```bash
# Change the directory to where the download is!
$ bash ~/Downloads/<Anaconda3-some-version-xx>.sh
```
39 changes: 3 additions & 36 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,16 @@ As a PInT subteam one of our primary goals is to help you learn and grow as indi

Automation’s goal is to create a living garden; that is, a garden that can give itself more water or nutrient substrate when it’s needed. We’re implementing this using a microcontroller that should check plant metrics (pH, water content, etc.) and deliver the nutrients a plan needs to survive. We plan to allow the community to interact with the hydro wall without needing to be there in person, so we have designed an API and are constantly improving our API and frontend dashboard so that we provide a good user experience.

### To Contribute:
### To Contribute

Visit our Computational Setup and Install Packages pages, which detail how you can install the software you need to succeed on Hydroponics.

[Computational Setup - General](https://www.notion.so/Computational-Setup-General-751cbe826a9f4a2fa62c351c19af5d31?pvs=21)
[Computational Setup - General](computational_setup.md)

[Install Packages](https://www.notion.so/Install-Packages-e498eccb0dc74e59ba2a6f249f6f7667?pvs=21)
[Install Packages](packages.md)

Our GitHub is organized into several subdirectories, each with a focus on one aspect of the Hydro automation workflow. You can view our GitHub here: https://github.com/Olin-Hydro.

![Untitled](https://prod-files-secure.s3.us-west-2.amazonaws.com/8469ebe1-5030-4ff4-9e93-da19dccf0706/dbbf3a3d-b1ef-4f4c-9f4c-4167e1eecc98/Untitled.png)

### Hydrangea

Hydrangea is a messenger between all the component. It’s an Application Programming Interface (API) written in Python, which is essentially a contract between anything application that has a distinct function. Here’s how [Amazon Web Services](https://aws.amazon.com/what-is/api/#:~:text=on%20your%20phone.-,What%20does%20API%20stand%20for%3F,of%20service%20between%20two%20applications.) describes it: API “defines how the two communicate with each other using requests and responses.”

We are constructing a path where the microcontrollers, database, and the frontend dashboard can all interact with each other and communicate. Currently, we are using a REST API architecture with routes built for `GET`ting, `POST`ing, and updating (`PUT`ting):

- Configuration settings (`Config`) for scheduling sensor readings (`SensorSchedule`) and actuators (`SASchedule`, `RASchedule`)
- Gardens (`Garden`), pods (`Pod`), sensors (`Sensor`), reactive actuators (`Reactive_Actuator`), and scheduled actuators (`Scheduled_Actuator`)
- Commands (`Command`) for a specific execution of an actuator
- Various logs for sensors (`Reading`), scheduled actions (`Scheduled_Action`), and reactive actions (`Reactive_Action`)

This API uses [FastAPI framework](https://fastapi.tiangolo.com/) and AWS Lambda function to host. We are using MongoDB as our database and `pymongo` library for Python interface.

You’ll need Python 3.10+ and [MongoDB Community Edition](https://www.mongodb.com/docs/manual/administration/install-community/#std-label-install-mdb-community-edition) to start contributing.

### Saffron

Saffron is the frontend page that graphically displays data and provides convenient controls for the hydroponic system. It’s a dashboard for viewing the gardens and pods registered in the database and their corresponding data collected from the microcontroller — such as sensor readings, actuator logs, and etc. The repository uses mainly Typescript and React (”a free and open-source front-end JavaScript library for building user interfaces based on components,” [Wikipedia page on React](<https://en.wikipedia.org/wiki/React_(software)>)). Additionally, we use `axios` library for concise API requests and error handling. The graphic designs and mockups (made by Jasper K. `23) are available on [this Figma page](https://www.figma.com/file/g259C0UL7i5YMckjOJcDcR/Hydro-Frontend-V0.2?type=design&node-id=0-1&mode=design).

You’ll need Node.js and `npm` to start contributing.

### Mother-nature

Mother Nature is a high level controller written in Golang and applied using AWS Lambda. It acts as a checker for plant condition and communicates with the Hydro API to ensure plant health. We’re trying to move away from Mother Nature as it is over-engineered for our purposes.

### Mini-Gardener

Mini-Gardener is an embedded application for ESP-8266 that controls sensors and actuators, and communicates relevant data to database and/or frontend dashboard via Hydrangea (API). It’s written in C++ and uses PlatfromIO for VSCode IDE integration. The purpose of Gardener is to provide control over physical electronic components and automate the process of nurturing plants by running on provided logic and schedules.

You’ll need PlatformIO to start contributing.

**Let a lead know what you would like to work on and we’ll invite you to collaborate!**

Questions from Documentation Review:
Expand Down
115 changes: 115 additions & 0 deletions docs/onboarding_electrical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Hydroponic System Onboarding Tutorial

Welcome to your onboarding! This document will guide you through the initial steps of setting up your hydroponic system. During the onboarding, you should be provided with the following items:

- 1x Adafruit ESP32 Feather Board
- 1x Breadboard
- 1x Sensor (various types)
- A bunch of cables
- A few LED bulbs

## Section 1: Overview of Electrical Parts and Sensors

### Peristaltic Water Pump

- **Function:** Delivers water, nutrients, or any liquid solution throughout the hydroponic system.
- **Operation:** Compresses and relaxes a tube to create a steady flow of liquid without contamination.
- **Use Case:** Controlled delivery of water and nutrients at scheduled intervals.

### Temperature Sensor

- **Function:** Monitors the temperature within the hydroponics system.
- **Operation:** Measures ambient temperature, maintaining optimal growth conditions.
- **Measurement Range:** 10 mV/°C scale factor, 500mV offset (0.5V @ 0°C).

### TDS Sensor (Analog)

- **Function:** Measures Total Dissolved Solids in water, indicating nutrient concentration.
- **Operation:** Monitors nutrient levels in water.
- **Measurement Range:** 0 ~ 1000ppm (±10% accuracy).

### Luminance Sensor (Analog)

- **Function:** Measures light intensity within the system.
- **Operation:** Regulates artificial lighting or assesses natural light levels.
- **Measurement Range:** 0 - 4095; lower values indicate brighter areas.

### pH Sensor (I2C)

- **Function:** Monitors pH level of the water.
- **Operation:** Ensures pH is within optimal range for nutrient absorption.
- **Measurement Range:** .001pH − 14.000pH.

### Humidity Sensor (I2C)

- **Function:** Measures humidity levels in the environment.
- **Operation:** Maintains ideal humidity for plant growth.
- **Notes:** Prevents excess moisture or dry conditions.

## Section 2: Adafruit ESP32 Feather Board

The Adafruit ESP32 Feather Board is a versatile and powerful microcontroller board, ideal for a variety of DIY projects, especially in hydroponics. It's the brain of your hydroponic system, seamlessly connecting and controlling various sensors and components.

### Understanding the Adafruit ESP32 Feather Board

Before diving into the connections, let's understand what makes the ESP32 Feather Board stand out:

- **Wi-Fi and Bluetooth Capabilities:** Allows for wireless communication and remote monitoring of your hydroponic system.
- **Rich Set of I/O Pins:** Ample digital and analog pins to connect a variety of sensors and actuators.
- **Low Power Consumption:** Ideal for battery-operated or energy-efficient hydroponic setups.
- **Compact Size:** Its small form factor makes it easy to integrate into your hydroponic system without taking up much space.

### Tutorial on Connecting Sensors to the Adafruit ESP32

#### Visual Guide:

![Adafruit ESP32 Feather Board Connection Diagram](https://cdn-learn.adafruit.com/assets/assets/000/111/179/large1024/wireless_Adafruit_HUZZAH32_ESP32_Feather_Pinout.png?1651089809)

#### Step-by-Step Guide:

1. **Identify the I/O Pins (input/output pin):** First, familiarize yourself with the I/O pins (the numbers on the board, as seen in the visual diagram as well) on the ESP32 board. Each sensor will connect to these pins for data communication. You don't really need to know what an I/O pin is, right now, just think of it as a communication channel. If you are interested, here is a [simple analogy](analogy_io.md).
2. **Start with your sensor (e.g., Temperature Sensor). Locate the VCC, GND, and DATA pins on the sensor.**
3. **Connect the VCC pin to the 3V3 (3.3V) output on the ESP32.**
4. **Connect the GND pin to one of the GND (Ground) pins on the ESP32.**
5. **Connect the DATA pin to a digital or analog input pin on the ESP32, depending on the sensor's output type.** All of your onboarding sensors should be analog. Search up the name and brand of your sensor, and the manufacturer should have a document on what pin the device should be connected to. Feel free to message the discord if you cannot find it, but we intentionally left it out so you can practice this process and use these skills on future sensors.
6. **Repeat for Additional Sensors:** Follow the same process for each sensor you have, ensuring that each sensor's DATA pin connects to a unique input pin on the ESP32.
7. **Powering the ESP32 Board:** You can power the ESP32 Feather Board via USB or through a battery if your setup is remote.
8. **Check Connections:** Once all sensors are connected, double-check each connection for correctness and security.

### Additional Resources:

- [Adafruit's Official Guide to ESP32 Feather Board](link-to-adafruit-guide)
- [Forum for Troubleshooting ESP32 Connections](link-to-forum)
- [Video Tutorial on Connecting Various Sensors to ESP32](link-to-video-tutorial)

By following these steps and utilizing the resources provided, you'll be able to successfully connect and configure the sensors with the Adafruit ESP32 Feather Board, laying a solid foundation for your hydroponic system's functionality.

- [Detailed connection tutorial](https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts)

## Section 3: Coding for the Sensors

The sensors provided have analog outputs and are labeled with their names and brands.

1. To find the test code, start by searching online using the specific brand and model of your sensor. For example, DFRobot provides excellent documentation for their products, such as this [documentation for the Gravity Analog TDS Sensor & Meter for Arduino (SKU: SEN0244)](https://wiki.dfrobot.com/Gravity__Analog_TDS_Sensor___Meter_For_Arduino_SKU__SEN0244). You can typically find this information by searching for terms like "tds sensor dfrobot code." This search should lead you to the correct documentation, usually within the first few search results. Remember, the code provided in this example is specific to the DFRobot sensor and SHOULD NOT BE DIRECTLY COPIED for use with a different sensor. Always use the code intended for your specific sensor model.

2. Review the code and highlight any confusing parts. I recommend printing out the code for easier annotation. Bring your annotated version to our next PInT meeting, where we'll go over it together. If you're up for a challenge, try creating documentation for the code and explaining it to the group. This exercise is designed to help us practice understanding and documenting code that has poor documentation (or none at all T_T). It's completely fine if you don't understand everything yet. Just do your best, and we'll discuss it together at the meeting!

3. If you're stuck, feel free to ask for help on our Discord channel.

## Section 4: Putting It All Together

1. Download PlatformIO from [PlatformIO Documentation](link-to-platformio).
2. Set up your breadboard as described in Section 2.
3. Import the sensor codes onto the Adafruit ESP32 board using PlatformIO.
4. Troubleshoot any issues by revisiting previous sections or asking on Discord.
5. Remember, it's common to encounter challenges at this stage. Keep trying, and don't hesitate to ask for help!

## Section 5: Celebrate Your Success

Congratulations on reaching this significant milestone! Once you have successfully configured the sensor to transmit data to your terminal (or any other preferred method), you're ready to integrate it into the larger network. At this point, your sensor is prepared to be connected to the internet through our central communication system.

This achievement marks not just a technical accomplishment but also your contribution to setting up a crucial part of the hydroponics system. Your efforts bring us a step closer to creating a more efficient and responsive growing environment.

Take a moment to appreciate your hard work and persistence. Remember, every successful connection and configuration you complete is an integral part of the hydroponics journey. Well done!

_Good luck, and welcome to the exciting world of hydroponics!_
Loading

0 comments on commit 17562d5

Please sign in to comment.