Collecting sensor data in FarmOS using GrovePi and Node-RED

Tool Concept
Stage: 
DIY


Primary problem statement:
I am a farmer and I want a tool to remotely know what is happening in the environment because I can't be everywhere all the time.
Read more about this problem statement

 

License:
Description: 
A simple way to collect data from sensors, like temperature and humidity and store it in FarmOS.
Documentation
Video: 
Documentation Wiki: 

Parts

  1. Raspberry Pi
  2. GrovePi
  3. Grove Temperature&Humidity sensor
  4. SD card (8GB or larger)
  5. MicroUSB power supply (2 amp or more is best)
  6. Ethernet cable connected to router or your computer (just for initial setup)

Steps

  1. Download the Raspian for Robots image. It should start downloading the latest version automatically. Currently 2017.10.05-Raspbian_For_Robots_by_Dexter_Industries.zip
  2. Burn to an SD card with Etcher
  3. Connect GrovePi to Raspberry Pi and plug in a sensor
  4. Put the SD card you just burned into the RPi and plug in the power
  5. Connect to wifi. There are many ways to do this. I will outline 3...
    1. The default R4R way to do this is to temporarily plugging the RPi in via Ethernet and then navigate to http://dex.local from your computer. (Note: if you have an Ethernet port on your computer you should be able to connect the RPi directly to that but if that doesn't work then try connecting to your router) This gives you an options to log in using VNC. This opens the RPi desktop in your browser. Then open the "Wifi Setup" utility on the desktop.
    2. You can also just use a keyboard, mouse and monitor before you boot the RPi and use the same Wifi Setup utility on the desktop as before.
    3. Or by editing files on the sd card https://gitlab.com/fiot/raspbian-headless-networking-config (you would do this before step 4)
  6. Install latest Node-RED
    1. Open a terminal (username: pi password: robots1234) and enter this command from https://nodered.org/docs/hardware/raspberrypi
      1. bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/r...)
      2. Answer yes to both questions
    2. Then to make sure Node-RED auto starts run this command
      1. sudo systemctl enable nodered.service
  7. Test that is is all working
    1. Unplug all your wires (including the power)
    2. Plug the power back in and try connecting to http://dex.local:1880 again. Your Pi should now be connecting to wifi and booting Node-RED automatically when it turns on.
  8. Install and configure GrovePi sensor nodes
    1. Go to the menu > Manage Pallet > Install and search for "node-red-contrib-grovepi"
    2. Click install (twice) and wait for it to finish
    3. Add a "Grove digital sensor" node and edit to select the connected GrovePi board and sensor.
    4. Add a "debug" node to the flow, connect to the sensor and deploy
    5. Open the debug tab and confirm you are seeing readings coming through
  9. Create a new sensor asset in FarmOS
    1. Create a new sensor asset in FarmOS
    2. Select "Listener" under "Sensor configuration > Sensor type"
    3. Open "Developer Information" and copy the "URL"
    4. Click "Save" (The senor asset does not work until it is saved for the first time)
  10. Send sensor readings to FarmOS
    1. Drag an "http request" function node onto the flow (not the "http response" output node does not work in this case) and connect the "grove digital" node to it.
    2. Double click to edit, select POST for the method and paste in the FarmOS senor URL.
    3. You will probably want to change the "Interval" for the sensor. By default it reads every second. Once every 15 or 30 seconds might be ok for short term testing while you develop but 5 minutes is probably fine in most cases.
    4. Deploy again and visit FarmOS to see the data roll in!

Additional optional setup

Remote access

If you are installing the raspberry pi is not connected to the same wifi network you are normally connected to it can be helpful to be able to access it remotely for managing updates, changing settings, fixing problems, etc. Since Node-RED is a graphical program, I have found TeamViewer to be the simplest secure way to get remote desktop access to the Pi. It is not open source, but it is free for noncommercial use. If you just want to log in via ssh, then Pagekite is a good solution but it costs money unless you host it yourself.

TeamViewer

  1. Log in to the desktop using a keyboard/mouse/monitor directly connected to the Pi. Not sure why this is the only way it works to install, but after it is installed it will run headless.
  2. Download https://download.teamviewer.com/download/linux/teamviewer-host_armhf.deb
  3. Open the downloaded .deb file and it should ask if you want to install it.
  4. This video is a bit old but it walks you through the basic process of getting TeamViewer installed and connected to the Pi from your computer https://www.youtube.com/watch?v=vr3Gf8vnKAg

Pagekite

  1. Setup an account on https://pagekite.net/
  2. Follow https://pagekite.net/wiki/Howto/GNULinux/DebianPackage/ to install Pagekite
  3. Follow https://pagekite.net/wiki/Howto/GNULinux/ConfigureYourSystem/#sshbe to configure for ssh
  4. Configure your ssh client (openssh for most people) https://pagekite.net/wiki/Howto/SshOverPageKite/#openssh

The first 3 steps are contained in this Ansible script if that is helpful for anyone.

 

 

up
3 users have voted.
up
1 user has voted.