How do I get started by setting up simple environmental monitoring and regulation?

Here is how I generally set up Mycodo to monitor and regulate:

  1. Determine what environmental condition you want to measure or regulate. Consider the devices that must be coupled to achieve this. For instance, temperature regulation would require a temperature sensor input and an electric heater (or cooler) output.
  2. Determine what relays you will need to control power to your electric devices. The Raspberry Pi is capable of directly switching relays (using a controllable 3.3-volt signal from the Pi’s GPIO pins). Remember to select a relay that can handle the electrical current load from your switched device and won’t exceed the maximum current draw from the Raspberry Pi GPIO pin the relay is connected to.
  3. See the Input Devices section for information about supported inputs. Acquire sensor(s) and relay(s) and connect them to the Raspberry Pi according to the manufacturer’s instructions. For instance, a sensor that communicates via the I2C bus will connect the SDA, SCL, Power, and Ground pins of the sensor to the SDA, SCL, 3.3 volt, and Ground pins of the Raspberry Pi. Make sure to enable the I2C interface under [Gear Icon] -> Configure -> Raspberry Pi . Additionally, the simplest way to connect a relay is to connect the controlling side of the relay to a GPIO pin and Ground of the Raspberry Pi (remember to select a relay that will not exceed the current limitation of the GPIO pin). Some relays require the proper polarity for the controlling voltage, so refer to the manufacturer’s datasheet to determine if this is the case.
  4. On the Setup -> input page, add a new input using the drop-down menu. Configure the input with the correct communication pins and other options. Activate the input to begin recording measurements to the Mycodo measurement database.
  5. Go to the Data -> Live page to ensure there are measurements being acquired from the input.
  6. On the Setup -> Output page, add an On/Off GPIO Output and configure the GPIO pin that’s connected to the relay, whether the relay switches On when the signal is HIGH or LOW, and what state (On or Off) to set the relay when Mycodo starts. There are a number of other Outputs to choose from, but this is the most basic to start with, that will simply switch the GPIO pin HIGH (3.3 volts) or LOW (0 volts) to switch the relay that’s connected to the pin.
  7. Connect your device to the relay. This can be dont a number of ways, and will depend on a number of factors, including whether you’re using DC or AC voltage, whether there are screw terminals or a connector/socket, etc. In the simplest scenario, AC mains voltage can be applied by cutting the live wire and connecting each of the newly-cut ends to each of the terminals on the switching side fo the relay. This enables the relay to short/connect or break/disconnect the connection, which will power and depower your device.
  8. Test the Output by switching it On and Off (or generating a PWM signal if it’s a PWM Output) from the Setup -> Output page and make sure the device connected to the relay turns On when you select “On”, and Off when you select “Off”.
  9. On the Setup -> Function page, create a PID controller with the appropriate input measurement, output, and other parameters. Activate the PID controller.
  10. On the Data -> Dashboard page, create a graph that includes the input measurement, the output, and the PID output and setpoint. This provides a good visualization for tuning the PID. See Quick Setup Examples for a greater detail of this process and tuning tips.