My first Azure IoT Project @home

It’s time for something new!

Today I start with my first project. I want to archive the following solution. I want to monitor the water level of my decorative fountain and stop the water pump if there isn’t enough water available. It’s also important to send the state to an IoT hub for long term analysis.

So my solution includes the following steps.

  • Create a water level sensor
  • Bind a relay to the sensor
  • Send the Information to my On-Prem Red Node Environment
  • Send the Information to my Azure IoT Hub

So first I will start with the hardware components. I will use the following:

IoT board: AZDelivery NodeMCU Lua Lolin V3

IoT water sensor: JSN-SR04T

Power supply: JZK

Relay: AZDelivery

Raspberry PI starter set

Teckin WLAN smart power supply

Start with flashing power supplies

Great, today I got my Raspberry and the Teckin power supplies. The first step, install Raspbian stretch lite on my PI.

After that I want to change the firmware from the Teckin power supplies because I want to integrate those into my node red and Azure IOT environment. I found a great article in C’T how I can archive that solution (Article). Great and really simple way.

Start installing NodeRed

Okay there is a good documentation available to install NodeRed.

Here are my steps

  1. Install Ubunto Server (LTE Version)
  2. Install nodejs (Version 10)
    1. connect to the NodeRed Server via ssh.
    2. execute the command: curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash –
    3. execute the command: sudo apt-get install -y nodejs
  3. Install NodeRed
    1. execute the command:  sudo npm install -g –unsafe-perm node-red
  4. Create NodeRed User
    1. sudo adduser nred
  5. Auto Startup Node-Red
    1. execute command:  sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service
    2. execute command:  sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start
    3. execute command:  sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop
    4. execute command:  sudo chmod +x /usr/bin/node-red-st*
    5. execute command:  sudo systemctl daemon-reload
  6. Change the nodered.service config
    1. execute command:  sudo vi /lib/systemd/system/nodered.service
    2. Change:
      • User=pi

        Group=pi

        WorkingDirectory=/home/pi

        to:

        User=nred

        Group=nred

        WorkingDirectory=/home/nred

    3. Save config (!wq)
  7. Test the service.
    1. execute command:  sudo systemctl daemon-reload
    2. execute command: node-red-start
    3. execute command: node-red-stop
  8. Enable NodeRed service.
    1. execute command:  sudo systemctl enable nodered.service

Cool, we have finished installed NodeRed. Now we can start to install mosquito (our IoT Broker)

  1. Connect to the NodeRed server via ssh
  2. execute the command: sudo apt-get update
  3. execute the command: sudo apt-get install mosquitto
  4. execute the command: sudo apt-get install mosquitto-clients

The last step is to set the right timezone.

  1. execute the command: sudo dpkg-reconfigure tzdata

Continue when everything is arrived…