domingo, fevereiro 11, 2018

Personal Weather Station with Raspberry Pi + Arduino


Since long time ago I have been looking for inexpensive ways to measure environment parameters such as temperature, humidity, pressure and wind speed. I found many projects to inspire me, so I upgraded mine ;-) . Click here to the old one.

Step 1 - Thinking...

Looking for a precise solution, we had chosen to use the BME280 sensor. It is a great sensor that can provide precise measurements of temperature (+-1C), humidity (+-1%) and pressure (+-1). The communication between sensor and micro controller occurs using I2C protocol allowing to get from sensors, the measurement values, compensated, in digital mode.

To measure the wind speed/position was choosed a analog anemometer, using a hall effect sensor to digitalize the output signal according the rpm. So, for each turn of the anemometer, a digital pulse will be emitted by sensor. To read these rpm pulse, configure a interrupt routine to read the pulses and time period. With these you can compute the wind speed.

Here, the main ideia is get the values from btoh sensors and provide it using serial port (UART) in string format. So, the choice has been Arduino Nano as a micro controller that will read the measurement from sensor, will format in a knowleged string and send to serial port connected on PC or Raspberry Pi. (click to zoom)

Here, the output expected:

After that, the Arduino has been connected to a Raspberry Pi using USB Port.

So, we developed a Python script to open the Raspberry serial port and read the data coming from arduino. Remember, the response is a text string with the measurement values.

Step 2 - Broadcasting...

To store these values, a ThingSpeak.com account has been created. The ThingSpeak.com is a IoT website that provide a RRD (round-robin database) to customers.  After stored our information, the ThingSpeak will show the graphics with mesuared values.

Thinking in Python scripts, the measured values has been cuted, isolated and sent to ThingSpeak.com using URL Post method + urllib . The entire script can be see bellow: (click to zoom)

After that, just run this script in your Linux, in background mode. Leave couple of minutes and you will can see your enviroment measurement at Thingspeak.com

With the Thingspeak populated/filled with our mesurament, the next step is develop another python script that will integrate our weather station with WundergroundWeather.com (WW.com). For that, the main ideia is: Get the same values  that has been sent to Thinkspeak.com and set these values in the attributes on WW.com website.  Remember: The WW.com has you proprietary protocol. Bellow you can see the second piece of python script getting and sending the environment measurement. (click to zoom)

Another feature that we implemented was the broadcast the measurement values over air, using FM. For that, we used PiStation, a application coded in Python that allow us to transmit any information using frequency modulation (FM Radio). The broadcast range is too short, like 100 meters. This range is enough to our purpose and don´t break any communications laws in some countries. Bellow, a example how to convert text to .wav files, using espeak (linux binary) and send to Pi Station.

More details about how to use PiStation and transmite FM signals:
https://github.com/CodyJHeiser/PiStation

One time that you understand how to use Fm PiStation, the main ideia is: get the measurement values, convert these values to .wav audio file and broadcast this audio file (with measurement values) over FM. In our case 107.5 Mhz.  So, every time that we have a new measurement, a new broadcast will play too, see example: (click to zoom)

Step 4 - Hardware assembly

For mechanical construction, it was necessary to protect the electronic components from rainwater. For the raspberry pi , was used a aluminium case (used in security cameras).



To protect the Arduino and BME280, we did a sensor shelter using 100mm PVC pipes (sewage pipe), 1 cap (100mm) and 1 ventilation terminal (100mm) built as bellow:






When, everything is done, attach them all to a photo tripod.

Step 5 - Operating

Localhost: To access the measurement data over local network, was developed a HTML + JavaScript page hosted on Raspberry Pi Apache Server. So, to see the data, just type http://Sation_IP_Addr/ in your webbrowser.


External Network/Internet: In anothers network, you can see the measurement data on Wunderweather.com or Thingspeak.com. If you want, you can redirect your TCP port 80 to your Raspberry Pi (WAN:80 --> Raspberry pi: 80) in your router and access it from anywhere with help of a dynamic dns (like noip.org)

And, of course,  if you have an old iphone that no longer works for nothing, use it as your screen. (Gauges powered by Google Gauges Java Script)


I hope you enjoyed, have a nice day ;-)

quinta-feira, novembro 12, 2015

Filtro Para Lagos - Balde/Vaso

Resolvemos fazer um filtro para um mini lago de aproximadamente 600 litros. A idéia é que tenhamos filtragem física, química e biológica com uma recirculação de 3 vezes do volume por hora (1800 l/H)

Depois de algum $$ e trabalho, temos a versão abaixo:




O filtro funciona por gravidade, ou seja, a bomba no interior do lago bombeia a água até a parte superior do filtro, que cai por gravidade passando pelas mídias filtrantes e saindo embaixo na lateral formando uma "cascata" no lago.




Para a montagem do filtro, foram utilizados os seguintes materiais:

  • 1 Cesto/Balde preto 30 Litros com tampa
  • 1.6 Kg de argila expandida para a base biológica do balde
  • Encanamentos:
    • 2 Flanges 1 Polegada 
    • 1 Flange 3/4 Polegada
    • 2 Adaptadores Soldável 3/4
    • 1 Espigão 3/4 para Mangueira de 1/2
    • 1 m Mangueira Cristal 1/2
    • 1 - Registro PVC 3/4
    • Pedaços cano PVC + Caps para chuveirinho
  • Mídias Filtrantes:
    • 1 Kg Carvão Ativado
    • 2 Bolsas Carvão
    • 860 Gramas Ceramica Biologica Ista
    • 1 m Perlon/Manta acrílica
    • 1 - Feltro Grosso Preto
    • 3 Kg Pedra Brita N 1
    • Seixos Brancos e Ardósia
  • Camuflagem:
    • Terra Plantar a tampa
    • 3 Mudas de Flor (1,50 cada)
  • 1 Bomba Sarlo 2000 l/H.

Custo total aproximado de R$ 300,00 em 12/11/2015

Modo de montar:
Fure o balde 4 dedos abaixo da borda superior do balde.
Instale a Flange de 3/4 com a rosca voltada para fora.

Fure o balde 4 dedos acima do fundo do balde.
Instale a Flange de 1" com a rosca voltada para fora.


 Note que a entrada então tem 3/4 e a saída 1", evitando acumulo de água desnecessário. O sistema anti transbordamento é com a outra flange de 1 polegada, porém em um ponto superior ao do chuveirinho.



Com as 3 flanges devidamente instaladas, todo trabalho de encanamento agora é feito na Flange Superior de 3/4.



Enrosque o adaptador 3/4 para cano na rosca da flange e solde um pequeno pedaço de cano pvc 3/4 permitindo assim soldar o joelho voltado para baixo, na sua extremidade.

No joelho, solde mais um pedaço de cano de PVC + Registro para controle da vazão. Na outra extremidade do registro solde mais um pedaço de cano com a luva azul 3/4. Na rosca da luva azul, insira o espigão e adapte a mangueira que vem da bomba.



Pegue um pedaço de cano de pvc menor que o diâmetro do balde, cole um cap em sua extremidade fechando. Faça vários furos neste cano visando formar um chuveiro. Nesta mesma flange de 3/4, do lado interior do balde, solde este cano chuveirinho, assim a água da entrada será espalhada de forma uniforme por todo o filtro.



O ciclo começa com a bomba dentro do lago, enviando a água pela mangueira, que entra no espigão, passando pelo registro, e caindo dentro do balde na parte superior através do cano chuveirinho.

Após a entrada da água, ela passará pelas seguintes mídias filtrantes, na seguinte ordem, de cima para baixo:

1 - Seixos brancos e ardósia:




2 - Pedra brita N1:



3 - Feltro:



4 - Perlon - Manta Acrílica:




5 - Carvão Ativado:




6 - Cerâmica Biológica Ista:




7 - Argila Expandida:



Note que os itens 6 e 7 sempre ficarão dentro de um saco permeável, submerso, mesmo no caso de falta de água no sistema, mantendo a biologia viva. A flange de 1" então deve ficar instalada logo acima do nível da cerâmica (6). Veja detalhe foto abaixo:



Posteriormente, a água, filtrada a qual passou por todas as mídias acima, volta para o lago via "cascata", completando o ciclo.



A tampa do cesto, usamos ela de forma invertida, assim além de tampar, teremos um "prato" de 4 dedos de profundidade. Este deve ser preenchido com terra e plantado com 3 mudas de sua flor/folhagem preferida, afim de camuflar o balde fechado no ambiente. Recomendo flores/folhagens com raízes curtas e não profundas. Ex. Musgos.



Durante a operação do filtro é necessário regular a vazão via registro ou tipos diferentes de canos chuveirinhos a fim de evitar transbordamentos (Neste momento a regulagem é feita por ambos os métodos). 

Caso queira, pode instalar um sistema anti vazamento (ladrão), pois neste caso a água excedente é eliminada por um furo na parte superior encima da linha de entrada da água.

domingo, janeiro 11, 2015

Simple Weather Monitor

Well, a year ago, I started to thinking about how to monitoring the weather. Using the simple way, precise like as I need, and possible to access from anywhere using internet. The proposed is measure the temperature (celsius), humidity (%) and atmospheric pressure (ATM).
So for monitoring the environment, I choosed a Arduino Nano board and two others sensors, DHT-22 for temperature and humidity, and Bosch BMP085 for pressure and temperature again.
The integration and how to manipulate the sensors can be seen bellow:
DHT-22 and Arduino using DHT Library


BMP085 and Arduino using Adafruit Library


As the BMP085 read the pressure using Pascal unit, we need to convert this value to ATM, and decrease the precision, but for these propose is enough. You can choose the best precision as you need.
After the sensors were integrated with Arduino, the next step is send the arduino information to a host computer, and store in a database. I have a dedicated server (oldest laptop), running Ubuntu Linux in my home, so the easy way to integrate will be using the Arduino USB/Serial port, to get/send information, using a pre defined simple protocol. A return string can be like as bellow:

TempBMP085:32.65C_TempDHT22:33.30C_Humidity:46.50%_Press:91857.00_ATM:0.91

To do this, was developed a perl script to connect via serial port with the Arduino board, send a command (Ex: letter 'g' from get), and get the string values read from sensors. After obtained the string, a parser structure "cut" the specific values and populate a RRD Database on my host computer.

root@laptop:~/ ./get_data.pl
Connected !
Command Sent !
String received !
Parsing String...
The measure values are:
TEMPBMP: 32.65
TEMPDHT22: 33.30
Umidade: 46.50
Pressao: 91857.00
Pressao ATM: 0.91

When you have the exact values (float type) that you need, storaged in a perl variable, simple running a external command (rrd tool) to populate a database using this value, like bellow:

system("rrdtool update /root/LogTemp/rrd_db/temperature_bmp085.rrd N:$temp_BMP");

If you want, you can generate a rrdtool graphs from data storaged in database, using command:

######################################################
##  BMP085
######################################################
#hourly
#create a png named temp_hourly.png
rrdtool graph /var/www/pages/temp_bmp085_hourly.png --start -1h \--title "Temperature " \--vertical-label "Temperature C" \--alt-autoscale \--alt-y-grid \DEF:tempBMP085=/root/LogTemp/rrd_db/temperature_bmp085.rrd:temperatureBMP085:AVERAGE \LINE2:tempBMP08500FF00:"BMP085" \GPRINT:tempBMP085:MIN:"Min\: %4.2lf" \GPRINT:tempBMP085:MAX:"Max\: %4.2lf" \GPRINT:tempBMP085:AVERAGE:"Avg\: %4.2lf" \GPRINT:tempBMP085:LAST:"Current\: %4.2lf  C"

and get a result like this

or if you prefer, use a perl script to generate a dynamic html page with javascript, and you can do your dashboard. Bellow you can see a example using Google Developer API Gauges Chart.


So, when you have a graph (png file) or a dynamic page (html+js), just use the Apache server on Ubuntu Server to provide the information on the internet.

terça-feira, julho 15, 2014

Poor's Man Magnetic Stirrer

Magnetic Stirrers here in Brazil often have a very high price.
Based on various projects available on the internet, why not make your own?

We use this case:

1 Wooden box
1 80mm Fan @ 12Vdc
1 Circuit Speed ​​Controller
1 HD magnet
1 power source 12Vdc/500mA - Saved from a older router.
1 on / off switch
4 screws
8 nuts
Some wires, tools, Gorilla Glue.

For the speed controller, there are several options, from a simple potentiometer until to a PWM circuit using an 555 IC.

I chose the PWM method for speed control, because the accuracy of rotation required as the substances used.

Usually, the potentiometer is used for adjusting the speed of rotation and the value of this depends on the potentiometer control circuit chosen.

Example of "simple" circuit
http://www.instructables.com/id/Make-your-own-Magnetic-Stirrer-2S/?lang=pt

Example of PWM circuit
http://www.instructables.com/id/Very-simple-PWM-with-555Modulate-every-thing/
http://www.instructables.com/id/Yet-Another-Simple-Pot-controlled-555-PWM-generato/

First step, perform the necessary drilling in the box, taking care to keep the drilling of the fan, centralized.


Install the chosen circuit, as well as potentiometer and key in the holes made​​.

Glue magnets on the fan, as centered as possible, avoiding the propeller unbalance.

Connect the fan to the previously installed circuit. To position the fan to the desired height, adjust the screw nuts support.

The maximum speed achieved depends primarily used the magnet, and the viscosity of the substance.

We can test this circuit, using a magnetic stir bar and Erlenmeyer.

First Test: