Please, proceed carefully following the tips published in this blog, specially when Main Power is involved. I'm not responsible for any damages caused by what is written in this blog.
Thank you

Saturday, 29 August 2015

Data Acquisition - Remote Gas Detector

Now, it's time to connect a remote sensor to my new receiver and begin a real data acquisition.

I think I'll go back to my sensor gas prototype...I already made some experiments with it:

First experiment: a simple gas detector

I'm going to use it as a remote gas sensor with MQ-4 [Datasheet].

and a wireless RF-433 transmitter.

with a lot of wire, led and a push button to reset sensor status.


This is the fritzling design:

As well as Wireless transmitter and gas sensor, we could see a red led, a green led and a RGB led. On the left side of the schema, there is also a push button. Led are powered by Arduino 5V power line, protected by resistors...Arduino is powered by a 12V transformer just like the wireless transmitter, to ensure the best transmission power.

PIN 11: push-button

PIN A1: analogue pin linked to GAS sensor

PIN 9: wireless data transmission

PIN 12: red led for wireless activity indication
PIN 8: green led for data acquisition activity
PIN 3, 5 and 6: RGB led for showing system status
 - off: normal values;
 - yellow: an out of tolerance value under the danger threshold;
 - rosso: an out of tolerance value over the danger threshold;

Here is it:


When the system is powered up, the gas sensor warm up stage starts; this is necessary to ensure better precision...during this time, RGB led blinks.

Then, data acquisition starts.

Every second the system gets 10 samples data from the sensor (the green led flashes every second) and calculates the average...Every 5 seconds the average of the collected values is sent to the receiver (the red led flashes every 5 seconds).

When the average is out of tolerance, RGB led lights up.

The push buttons reset the system status and turns off the RGB led. If a value is out of tolerance and then other samples return to normal values, the led still lights on...to get the attention...only through the push button, led could be turned off.

The wireless data sent every 5 seconds is a text string with the following format:


VALUE is the calculated average, STATUS is a numeric value indicating the system status according to the following schema:

 - 1: ok;
 - 2: warning
 - 3: danger


You can download the complete Arduino Sketch from here:


As for the receiver, I used RADIOHEAD libraries to manage wireless transmitter.


- wireless receiver setup;

- status led setup;

- MQ-4 sensor warm up;

Main loop:

- First, the system checks the push button status...If it was pressed, the variable which manages the system status will be set to OFF;

- Then, the system read 10 samples from the gas sensor and calculates their average; during this time the green led lights up (PIN 8);

- Every 5 seconds the system calculates the average and set the system status according to this value; then, this value is sent to the receiver;

- In case of out of tolerance value, RGB status led (PIN 3, 5 e 6) will light up;

- The average value is sent to the receiver; during this time the green led (PIN 12) will light up;

And finally, here is a short video:

Saturday, 8 August 2015

Data acquisition - The Receiver

Let's get started with the first component: The Receiver.

Here is it still as a prototype

It's made up by an Arduino Uno Board, with the ethernet shield to get network access and the wireless RF433 receiver

Functionality and communication protocols

The wireless receiver receives messages sent by sensors and then route them towards WEB/APP server, using http protocol. It acts as a simple router.

Communication protocols are very simple and currently not secure, so for now this system cannot be in a public network.

The message sent by sensors is a character string made up in the following way:


where SENSOR is the name of the sensor; VALUE is the current value of the sensor and STATUS is a particular condition for the sensor (DANGER, WARNING, and so on...)

The receiver gets this string and send it to the WEB/APP server, using the following HTTP GET request:


where SERVERNAME is the domain in which WEB App is installed, PASSWORD is a secret key known also by the WEB/APP server and STRING is the sensor's data.

As already said, communication protocol is very simple and without ACK...for now it's just a prototype and it aims only to debug system


Fritzling Schema (approx)

PIN 2 OUTPUT for RF status led (RED), reporting wireless activity;
PIN 3 OUTPUT for ETH status led (GREEN), reporting ethernet activity;
PIN 5V to power up wireless received and led;
PIN GND linked to wireless receiver GND pin;
PIN 7 INPUT to receive wireless data;

The Ethernet shield is linked to Arduino UNO; all the system is powered up by external 5V.



- wireless receiver setup using RadioHead library;

- ethernet shield setup using standard Ethernet library; it this case we use a static IP (but you can use DHCP if your network provides it);

- status led setup;

Main Loop

- the main thread wait for a wireless message;

- after received a new message, RF status led lights up and the message is sent to WEB/APP server using HTTP request;

- during the http request, ETH status led lights up and it turns off after the HTTP response;

Here you can find source code for the receiver: DOWNLOAD

And here is a video about the receiver doing its job...

Saturday, 1 August 2015

My first project - data acquisition system

I started design my first data-acquisition system with Raspberry PI and Arduino. The idea is to have a sensors network which send data to a receiver which, through ethernet, send these data to WEB/APP server.

The main components are:

- one or more sensors
- a receiver
- a DB Server for storage purpouse
- a WEB/APP server to acquire data and let remote user monitoring the system

Here is the design:

More details:


They can send data in different ways:

- wireless RF-433 towards receiver
- ethernet towards receiver
- USB directly towards server

They can be Arduino board or Raspberry PI or others...
Depending on the type of communication, there can be other interface boards or control led...


It receives data via wireless RF-433 or via Ethernet
Through ethernet, it transmits data to WEB/APP server, for storage and monitoring purpose

It's built over an Arduino boards with Ethernet Shield and wireless RF-433 receiver. There are also control led.


It receives data from receiver through ethernet or from sensor directly connected on its USB port
It stores data on DB server
It runs a web application for remote monitoring

The WEP/APP server software is the world famous Apache HTTPD, installed on Raspberry, running Fedora linux distro.

The monitoring web application is written in PHP / HTML5 using Bootstrap framework, which make it responsive.


It stores data received from WEB/APP server.

The RDBMS is Mysql Community Edition installed on the same Raspberry of WEB/APP server

Friday, 31 July 2015

Arduino Low Cost Wireless Link

It's been a while since my last post...but my job kept me busy and I was not able to continue with my experiments with Arduino e Raspberry.

But in the last few weeks I was able to get back to Arduino

If you remember, some month ago I bought two wireless RF-433 modules (transmitter and receiver)

So, I made some experiment, linking two Arduino boards, using RadioHead libraries.

Then I built a little home-made antenna over both modules...and I used a 12V adapter on the trasmitter, in order to get the best range.

This is the receiver:

...and this is the trasmitter:

My test was very simple...I tried to send some text string from one Arduino to the other...the receiver was connected to the PC just to verify through serial port console the received messages.

Test was OK...it's time to build something useful...

Saturday, 14 March 2015

Music Server on Raspberry PI

Now that I have a real linux PC always powered up with a very small power consumption and connected to my LAN, why don't use it for something less or more useful?

I read that there are lots of software which let a linux pc/server become a media center...I need the one which is able to run just in terminal mode, because I don't like graphical mode on linux server ... I always try to keep my system resources free as possible...

I found a wonderful software...MPD - Music Player Daemon (http://www.musicpd.org/)

It's a linux software which acts like a Daemon. It's able to play different music files, with the help of plugins and libraries. It can be controlled by compatible network clients and it can transmit http streaming music. It also permits to create and manage folders and playlists.

It was written for low level pc/server and so it's ok for Raspberry.

There are various client application which can manage MPD...they can be installed on Android and iOS devices too...

Installation is easy and for my OS Fedora Remix 21 it can be done using YUM (yum install mpd).

Configuration file is /etc/mpd.conf.

There are a lot of configuration parameters; only few of them are the most important: the path where MPD can find multimedia files, the ip address and port the service will listen on and the audio devices.

I used only one audio device which enable 3.5mm jack on the Raspberry PI...this jack was connected to an hifi system through a simple RCA cable

We are ready to start the service. Now all the clients can connect and control MPD Service.

We advise you to let the service automatically start on Raspberry Boot. The best thing to do is enable mpd.socket instead of mpd.service.

mpd.socket is a service which start mpd.service only after the first connected client.

If you use firewall on raspberry (ie iptables), you must configure it properly.

Now it's time to try a client. I will install it on tablet and smartphone...both with Android OS. The best Android client I found on Google Play is MPDroid, which is totally free.

Some screenshot



For iOS, on Apple Store there is MPoD; it's free too.

The last thing to do is power up the hifi and pump up the volume :)

Friday, 6 March 2015

My new Raspberry PI 2

In a few days, I received my new toy...Raspberry PI 2

It has very strong tecnical characteristics...it's a real PC...but with low power consumption and a very small size...

- A 900MHz quad-core ARM Cortex-A7 CPU
- 4 USB ports
- 40 GPIO pins
- Full HDMI port
- Ethernet port
- Combined 3.5mm audio jack and composite video
- Micro SD card slot

It has no internal storage and so it's necessary to use a micro SD card as "Hard Disk"...I chose a 16 GB Sandisk card, which is an adequate size for the OS and some other stuffs...as OS I will install Fedora 21 Remix...

Ok, it's time to play with it...

Friday, 23 January 2015

Ethernet Shield Test

It's time for the second experiment.
The Ethernet Shield test with Arduino Uno Rev 3.

We will put the shield on the local network and create a simple web server which will reply to http request and will drive two led.

There is a useful library which will help to develop the Ethernet Shield software. With some line of code the device will be on the LAN using DHCP protocol or by setting manual configuration (ip, dns, gateway ...)

The shield will be directly linked to Arduino. Pin 10, 11, 12, 13 are used by the shield and so they cannot be used by developers.

For our purpose, we will link digital output 2 and 8 to two led. Arduino will drive them, receiving http requests. A tablet will be used as client.

Our Arduino will listen on port 80 and will drive the led, managing http requests.

Here is the demo:

Sunday, 18 January 2015

First experiment: a simple gas detector

Let's begin assembling some stuff from starter kit...as first example we will try to build a simple "gas detector" using MQ-4 sensor.

Here is the datasheet

The sensor has 3 pins:

- Vcc: 5V supply voltage, Arduino friendly;
- GND: ground connection;
- AD: analog output; provides a value congruent with the gas concentration in the air;
- D0: triggered digital output; provides an HIGH signal when the gas concentration exceeds a limit; you can set this limit through the trigger;

We will use only the analog output, which will be linked to an Arduino's analog input pin.

The sensor needs a pre-heating time.

In our prototype, just for example, we will use also:

- a temp sensor: LM 35
- an LCD display 16X2 backlighted with Hitachi HD44780 driver
- a Buzzer
- a led
- a pot

On the display we will show datas provided by the sensors; led and buzzer will be used to signal warnings and alerts and the pot controls the LCD display dimmer.

Here is the demonstration video:

Friday, 16 January 2015

Arduino Uno Rev 3 Starter Kit

After many research over the internet, we decided to buy on ebay the Arduino Uno Starter Kit.

We got it in a few days.

It contains:

  • 1 Arduino UNO R3 Board, made in Italy
  • 1 USB Cable 50cm
  • 1 Breadboard 830 points
  • 1 Display LCD 16X2 backlighted, Hitachi HD44780 driver
  • 2 Linear Pots 10Kohm
  • 2 Knobs
  • 1 9V Battery connector
  • 65 Jumpers
  • 10 Buttons
  • 1 Buzzer
  • 1 relay 5V 10A 250VA
  • 1 Temp Sensor LM35
  • 2 Transistor BC547
  • 1 Light Sensor
  • 10 Red LED
  • 10 Yellow LED
  • 10 Blue LED
  • 10 Green LED
  • 10 White LED
  • 1 RGB LED
  • 2 capacitors 4,7uF 100V
  • 5 Diode 1N4007
  • 10 Resistor 1Kohm
  • 10 Resistor 10Kohm
  • 10 Resistor 4,7Kohm
  • 20 Resistor 470ohm

I think we have enough things to begin experiments...

In the same shipping we received also:

RF 433 Mhz Transmitter and receiver modules

Ethernet shield based on W5100 chip with an sd card reader on board

an MQ-4 gas sensor

some RGB LED

Ok, don't waste our time...we are ready to begin some real experiments...

Sunday, 11 January 2015

A new adventure...

Welcome everybody in this new adventure related to eletric / electronic and computer world...

Finally, after a lot of time spent on thoughts and searches over the internet, I decided to enter in the world of Arduino boards...

Electronic and computer things always involved me a lot...and thanks to Piero's suggestions, I filled my electronic gaps and so now I'm able to design and build something useful.

Who already follows me, knows that I'm involved, always with the help of Piero, in another ambitious and exciting project: the building of a flight simulator cockpit (details on www.mylearjet45.net)

Instead, in this blog, I would like to write about my attempts to design and build something related to domotics (home automation)...mainly using Arduino and Raspberry PI boards, with related extensions...

What are Arduino and Raspberry PI?


Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. There is a wide range of products, based on technical characteristics and dimensions...

The Starter Kits (Arduino board plus a good range of useful accessories) are very useful for the beginners.

Through input/output pins and software programming, you can interface sensors and actuators in the real world...

There are a lot of expansion cards (called shield) as Wifi/Ethernet connectivity, Infrared/Bluetooth transceiver, Sd Card Reader and so on...

The programming language is based on C language and you can find a lot of examples over the internet.

References and official website www.arduino.cc

Raspberry PI

Unlike Arduino, Raspberry PI is a real, small (credit card size) and low power consumption PC, and is able to run many Linux Distros. It has many USB ports, HDMI Output, 3.5mm A/V Jack, CPU and Ram...

Link Arduino it has many GPIO (General Purpouse Input Output) pins to interface real world sensors and actuators.

There is a wide range of models...the last one (February 2015) is Raspberry Pi 2 Model B. These are its technical characteristics:

  • A 900MHz quad-core ARM Cortex-A7 CPU
  • 1GB RAM
  • 4 USB ports
  • 40 GPIO pins
  • Full HDMI port
  • Ethernet port
  • Combined 3.5mm audio jack and composite video
  • Camera interface (CSI)
  • Display interface (DSI)
  • Micro SD card slot
  • VideoCore IV 3D graphics core

References and official website www.raspberrypi.org

Both boards, used together, could be used to design infinite projects...fantasy is the only limit...

Now it's time to begin...with Arduino...

...we are waiting for the Starter Kit Arduno Uno Rev 3...

Stay tuned