Agricultural Monitor
7. Flash the Microcontroller
7 / 8

Now, find the Helium-Arduino integration code in our repo.

  • Open your Atom text editor and create a new project (if this is your first time, see here).

Helium also works with the Arduino IDE, but this project is untested through Arduino IDE.

Flash the Arduino Uno

  • Add the ‘main.cpp’ and ‘Board.h’ files to your project.
  • In ‘main.cpp’, change some globals to match your setup and requirements:
    • SECRET_API_KEY - Match the Twilio Function environment variable. See also the warning in the ‘Deploy’ step about safety in production.
    • CHANNEL_NAME - The exact channel name you used in the ‘Setup a Helium Channel’ step.
  • Optionally in ‘main.cpp’, change some preferences:
    • PAUSE_MS - Milliseconds to wait between readings
    • CYCLES_TO_AVERAGE - Number of readings to average together before sending to your Function (PAUSE_MS * CYCLES_TO_AVERAGE will be the rough delay between Function POSTs)
  • Select ‘Build’ in the ‘PlatformIO’ menu in Atom.
  • If your wiring is correct and the code compiles, plug the USB cable to your machine and the board and select ‘Upload’ from the PlatformIO menu.
  • Open a Serial Monitor at 115,200 baud to the serial port created (also in the PlatformIO menu)

Watch the Magic Happen

You should see readings start immediately in the serial console even if the sensor is dangling off your desk. After CYCLES_TO_AVERAGE readings, if your soil/desk is dry enough, you should see a message (or perhaps, messages, if you wait long enough) from your setup:

12 text message plant monitor 4