Showing posts with label INTERNET OF THINGS. Show all posts
Showing posts with label INTERNET OF THINGS. Show all posts

IOT RECIPE 03: Pellet / Wood chips level sensors

In this post i'll cover actual sensor setup for pellet and wood chips bulk level monitoring.

Pellet bulk level sensors

How to monitor pellet bulk level if you can't access to warehouse?
My warehouse is a room covered by wood, with sloped floor and a moving reclaimer on the center. The total volume is approximately 12 cubic meters and once filled i've no access to the room.



Obviously i need to know residual pellet level, so a pellet bulk sensor is needed. While googling i've found few examples, all of them related to water level in tank and using ultrasonic distance sensor approach.

The room is more or less 2 by 3 meters: in this configuration, pellet or wood chips forms non uniform piles in the room, with lower point just above the reclaimer area, so is needed to use an array of sensors averaged to find the level: 9 ultrasonic sensors are arranged in a matrix configuration.

Ultrasonic sensors

For the project i've selected HC-SR04: the sensor is a low cost complete ultrasonic measurement device. The sensors are housed in waterproof electrical box.

Once activated a signal burst is emitted from the emitter, then the signal is captured from the receiver, mirrored by a surface. Using simple timing formula based on sound speed, the library output distance in cm. Simple. 3 cm to 2 meters is the real distance range, while effective usage suggests the sensor is not so accurate over time: in my experience temperature compensation is needed to give at least not wrong measurements (15% of fluctuation is possible).

Most libraries provides averaging for each reading, with 10 to 25 signal bursts before measurement average.

From distance to weight

Pellet weight in bulk storage is more or less 650 kg/mc.
To provide weight measurement the equation is simple:

Estimated weight = Average(empty distance - measured distance)*(area)*(bulk weight)


Data acquisition

To acquire 9 sensors outside warehouse a lot of cables are routed outside warehouse to an external waterproof electrical box.

The little circular window in the front of electrical box is PMMA window sealed with hot glue (my new electronic projects best friend). 

In the box i've installed an Arduino Mega with three additional sensors:
  • A remote DHT22 inside pellet warehouse to provide internal reading of temperature and humidity;
  • DHT22 to provide same readings of external conditions;
  • A three-in one sensor: light, pressure/altitude and temperature

Measurement routing

Distance between Arduino Mega and Raspberry PI is more or less 4 meters. After a bit of googling, i've found a 5 meters USB cable is reliable. I can confirm is true.
The USB cable connect Arduino to RPi inside the boiler room (gray cable coming from the top of the electrical box).


Inside the box a Raspberry PI with Node-Red with MQTT client (more details in the future).
Another Arduino is installed and connected to read out energy monitor.
RPi communicates with a central server (another RPi) using ethernet.


IOT RECIPE: 02 Energy Monitor

In this post i'll cover actual sensor setup for energy monitor.

Energy monitor

To evaluate power consumption i've routed main cable coming from utility energy monitor in a new electrical panel. In this panel i've installed:
  • 3 three-phase energy meter (16 kW of maximum power)
  • 1 single-phase energy meter
This is an internal view of my setup inside an ABB electrical panel (upper part, with two of these energy monitor) after thermal-magnetic circuit breaker and surge protector.

For this duty i preferred to go with an industrial solution, because i was not confident with DIY solutions on main power side.
My solution is a products from Italian manufacturer LOVATO:
LOVATO DMED300T2 is a compact (four modules) energy meter. The main advantage is the presence of two programmable pulse output (up to 1000 pulses/1kWh or programmable threshold).
The output is an open collector, in which each pulse has a duration of 60ms: an open collector is a transistor based output that can be read by an external PLC (like arduino).

The electrical connection requires only to route an input pin of the arduino to open collector and connect the two IC grounds to have the same reference level and let current from arduino to flow once open collector is open.

There are two methods to read these output, with interrupts or with pooling.
Because i had only one external interrupt, i had to go with pooling: loop forever and check if digital input is high or low. If is high, and previous one was low, than increment a counter and go on to next input. 

First of all, in my system maximum power is 16 kW: this means each hour i can have a maximum number of pulses of 16 * 1000 = 16.000 pulses/hour equal to 4.45 pulses/second, each one of 60 ms.
If entire loop timing is less than 60ms, no pulse is missed.

Because open collector is transistor based, i found no debounce routine is needed (situation like button press may need a stabilisation in input reading).

My piece of code for pooling is:

//INPUT SETUP
pinMode(LOVATO1, INPUT);           // set pin to input

digitalWrite(LOVATO1, HIGH);       // turn on pullup resistors

//INPUT LOOP
READ1 = digitalRead(LOVATO1);

if (READ1 != LASTSTATE1) {
    if (LASTSTATE1 == 1) {
      COUNTER1 ++;
    }
    LASTSTATE1 = READ1;
  }

Taking into account the time delta between reading A and reading B (60s in my case), is possible to average the energy consumption during this period, and to define average power consumption during the period.
Passing via serial milliseconds and pulse numbers between loops, i can reduce the time spent communicating with host, leaving calculation on other side.

Resulting chart of 1 day power consumption average (1 tick/30 minutes):



IOT RECIPE: 01 Introduction - Sensor web interface

I'll start a new series of posts on IOT matter from the end.
This is the web interface running on my local area network.



Running the site is a mini flask web server running on a Raspberry PI. In the screenshot, charts are provided by highcharts.com and Justgage javascript library.

In this series of posts i'll cover all the ingredients of my recipe:
- Sensors overview (DHT22, Energy, Light, Barometric pressure, Pellet height)
- Raspberry Pi data acquisition with Arduino
- Launchpad Tiva CC3200 with WiFi
- Node Red Engine
- MQTT, Mosquitto, Paho
- Rrdtool, circular timeseries database
- Flask server
- Charting with javascript
- Debian unit files
- Telegram Bot Api

Popular posts