04 - 08 - 2020

Home Automation

Experiment: Home Automation.

AltonaLab diagram: KIT_HomeAutomation.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • Mini PIR motion sensor;
  • 5V multi connector power supply board;
  • One load relay board 8A
  • 220V to 12V, 2A power supply;

Home automation is very interesting area, because each of us wants something to be automated in his home. In the previous experiments, we learned how to control and monitoring some simple processes. In this experiment, we will learn how to build a complex system to automate our home. For this purpose we need a computer, which runs not stop and an AltonaLab software running on the same computer. The controlled devices at home will be - heather in bathroom, fan in bathroom, light in yard. Of course we will monitoring the temperature at a home and will have a security PIR sensor. Some of the devices will be controlled automatically from the computer, but if we want, we can control them in manual mode from the buttons located at the AltonaLab diagram or using our phone with android OS. So with this experiment, we will demonstrate a simple to use but very powerful block AndroidRemoteControl, which will allow you to control what you want by phone.

 

Warning!!! Before starting the AltonaLab diagram, you must to do the next:

  • You need to have a Static IP address at your home. This will allow an external TCP/IP client as an android application running on your phone to be connected to an opened TCP/IP port from AltonaLab software. At this case, AltonaLab software is a TCP/IP Server!
  • After or before the diagram is started, you need to start the TCP/IP Server too. Just press the button next to the button for Start the process. When the TCP/IP Server is started, it will receive a commands from Android application running on your phone, and you can control or monitoring your home by phone:

 

  • Set the CommPort property of a Numato block in the diagram;
  • In block SunInfo - set the properties Latitude and Longitude with GPS coordinates of your home;
  • For block AndroidRemoteControl - you have to do a few settings, which are described below at this article;
  • In block MailSender to set all the properties related to the used mail account: Server, Port, UserName, Password, SenderEMail, RecipientMail, RecipientName. A MailSender block is well described at the article with URL below:

https://scada.altonalab.com/index.php/en/descriptions-of-the-functional-blocks/internet-library

 

To be able to send commands from your Android phone to the running AltonaLab software, you need to follow a few simple steps described below:

1. At AltonaLab software, set which IP Port will be used for a TCP/IP Server. Usually it is 707. If the checkbox AutoStart TCP/IP Server is checked, when AltonaLab software is started, the TCP/IP Server will be started automatically too:

2. Open the used TCP/IP Port 707 in Windows FireWall. For Windows 10, the steps are shown below:

Navigate to Control Panel, System and Security and Windows Firewall.
Select Advanced settings and highlight Inbound Rules in the left pane.
Right click Inbound Rules and select New Rule.
Add the port you need to open and click Next.
Add the protocol (TCP or UDP) and the port number into the next window and click Next.
Select Allow the connection in the next window and hit Next.
Select the network type as you see fit and click Next.
Name the rule something meaningful and click Finish.

You have now opened a firewall port in Windows 10!
 

At the same Inbound Rules interface, click with right mouse button over the application AltonaLab, then select Properties, then select the radio button Allow the connection. The changes are shown below:

 

3. Usually, your computer has an local IP address, because it is connected to the internet by an internet router. But for this experiment, you need to find your external IP address. You can use a WEB site as the URL below, to find your external home IP address:

https://www.whatismyip.com/what-is-my-public-ip-address/

4. You need to know a local IP address of the computer, where an AltonaLab software runs. For this purpose, click over the icon of your internet connection and find your local IP address. It looks like: IPv4 address: 192.168.2.3. The other way is - run the Command prompt application and then execute the command: ipconfig. Then at the text result of the command, find your local IP address:

IPv4 Address. . . . . . . . . . . : 192.168.2.3

5. Because we will start a TCP/IP Server of an AltonaLab software and we will use a 707 TCP/IP Port, we have to set the Port forwarding at our internet router. You need to know the local IP address of your internet router and to open its WEB interface, where some settings can be made. If you don't know how to make this, please ask your internet provider. The WEB site of my DLink internet router looks like the image below. I will use it to redirect an external IP Port from my external IP address to an internal Port of my computer which a local address I found with the command above. So if the external IP Port 707 is the same as an internal IP Port 707 of my computer with a local IP address 192.168.2.3, then the Port forwarding settings are:

6. Now is a time to start the TCP/IP Server of the AltonaLab software. For this purpose press the button of AltonaLab shown below. This will allow AltonaLab to receive TCP/IP connections from other devices over the internet:

7. You need a Smart phone with an Android OS;

8. Open an internet browser on your Android phone and open the URL below:

https://scada.altonalab.com/index.php/en/samples

The click on the second image, which is: 2. Android application for remote control:

9. You need to allow an installation from an unauthorized source and to install the application.

10. When the android application is installed, run it and press the button Settings. On the image below is shown the Android's application interface. The settings interface is the right page. At the Server IP Address you have to set an external IP address of your home. Usually we use the port 707 for AltonaLab TCP/IP Server, but it is not problem, if it is other number. ObjectID and Password has to be same asthe properties ObjectID and Password at the block AndroidRemoteControl from the running AltonaLab diagram.

11. AltonaLab can receive TCP/IP commands only from registered android phones, so it is a time to register all the phones of your family. Please be sure, the TCP/IP Server of AltonaLab software is started, then navigate to Settings->Allowed android devices at AltonaLab software. Run the android application shown at the image above, click the button Settings and if the Server IP and Port are set with valid values, click the button Register to host, at this moment the uncial ID of your phone will appeared at the edit Android device ID. At the next edit set a Description and Add the device to the allowed devices. Now your phone is allowed to send TCP/IP commands to a running AltonaLab software.

12. The last step is to read the button configuration, which is set at the block AndroidRemoteControl. For this purpose be sure the TCP/IP Server of AltonaLab is started, then run the AltonaLab diagram too. At this moment press the button Get configuration from a Settings interface of an Android application. Then go back to the main interface of Android application and you will see control buttons of your home devices. When you press some of the buttons from the main interface of Android application, the corresponding TCP/IP command will be send to a AltonaLab TCP/IP Server and some of your devices will be turned ON.

 

 

The used hardware is shown below. GPIO 0 and GPIO 1 of a Numato board are used to read the values of a Temperature sensor and a PIR Sensor. The 2 relays controller has two digital inputs, connected to GPIO 4 and GPIO 5 of a Numato board. GPIO 4 is used to control the Yard Light, GPIO 5 controls a bathroom heater. The Yard light is simulated with a 12V lamp, the Bathroom heater is controlled by powerful 12V 8A relay, available in the KIT equipment. The wire between 2 relay controller and One load relay board 8A can be very long. AltonaLab diagram controls GPIO 6 of a Numato board, but in this hardware diagram it is not connected to a real hardware.

 

Please be very careful with PIR sensor! It is very small and it has not good readable texts on its board about its pins. Its board has two sides, one with electronic elements and other with soldering. The image below is with electronic elements on top side. The left pin is Positive power supply, the middle pin is signal output, then is GND. The pins of a PIR sensor are connected to the Connector board by cables Male to Female!!!

 

 

The used AltonaLab diagram is:


AltonaLab diagram has a few areas:

- A top area with controls - there is a text control, which shows the current temperature, Lamp for current state of a PIR sensor, three lamps for Heater in bathroom, Fan in bathroom, Yard light. There are three buttons, if one of them is pressed, the corresponding device will be Turned ON for 10 min. The diagram has two lamp, which show whenever the e-mail is send or not, when there is a security event generated from a PIR sensor.

- Read sensor data and control relays - the area includes Numato block, block AltonaSensorTemp, which converts the read RAW value from the ADC to degree centigrade, SchmittTrigger block, which convert ADC value to digital signal. The high value of this digital signal means there is a security event generated from a PIR Sensor. Because the diagram has to work non stop, Numato block is not in Fast mode and its parameters are CommunicatePerSec=1, FastMode - unchecked;

- Send e-mail - the area is well explained in the experiment Simple home security system. The purpose of the area is when there is a security event, generated from the PIR Sensor, the home owner to receive an e-mail with information of the temperature of the house too. If there is not a secure event, the owner will receive every day an e-mail at 20:00h. This e-mail is very important, if you receive the mail this means, the computer is still running and additional you will know what is your home temperature. The information is interesting is case you are at a holiday or at a business trip;

Control heater - if your bathroom is cold at a winter time, you can turn ON the heater for 10 min by pressing a button Heather in bath located on top of a running AltonaLab diagram or to press the button Heater of your Android application, running on your smart phone. The both events are connected to the inputs of a OR block, then the TimeOut block will be turned ON for a 10 min and GPIO 5 of a Numato block will become to a high level. The main purpose of this area is to demonstrate how simple is to control a device using a TCP/IP command, which is sent from a phone;

- Control Yard Light - the area has a similar logic as a Control heater area, additional is added a block SunInfo. At this block are set parameters Latitude and Longitude with GPS coordinates of your home. As is known, the sun set and sun rise are changing every day and are different on all the world locations. When outside is night or twilight, your Yard light will be turned ON. The time of Turn ON/OFF will be different every day. The Yard light can be turned ON for a 10 min by pressing the button Yard light of an android application;

- Control FAN - if you get a shower every working day around 8:30h and leave from home around 9:00h, it is a good idea the FAN of your bathroom to work at time period 9:05h..9:20h. But only in working days, because at a holiday it is not clear when you will get a shower. This logic can be easy achieved by a block TimeInterval, which parameter OnOffInterval is set to 9:05;9:20. This means at this interval of time every day, the output of the block will be in high level. The mentioned output is with AND logic with output WorkDay of a block DayOfWeek. The output WorkDay is in a high level from 00:00:00h of Monday to 23:59:59 of a Friday. The fan can be turned ON for a 10 min by pressing the button Fan of an android application;

- Remote control by phone - the area contains a block AndroidRemoteControl, which is well explained at the URL below:

https://scada.altonalab.com/index.php/en/descriptions-of-the-functional-blocks/android-library-blocks

 

The properties of the block AndroidRemoteControl are shown below.

The properties are:

  • Properties ObjectID and Password has to be the same as the settings ObjectID and Password in the android application. One AltonaLab diagram can has more than one blocks AndroidRemoteControl, but this blocks need to have different ObjectID properties, which means some phones can send some commands, other phones can send other commands;
  • PhoneSettings - using this property we add at the top grid the monitoring signals, which values can be visible at the phone. The names of this values have to be added to the text of property TextOut of the block. At the bottom grid we add the buttons, which will appeared at the android application, when the button Get configuration is pressed at the Settings page of the android application. The added monitoring values appeared as inputs of the block AndroidRemoteControl, the added Buttons appeared as digital block's outputs. When the corresponding button at the android application is pressed, the same block's output becomes at a high value;
  • TextOut - at this diagram, the property is set to a text:

Temp is: <InTemp;1> C
Heather bath: <InHeather>
Fan bath: <InFan>
Lamp yard: <InLampYard>

When the button Read of an android application is pressed, or some other button sending a command to AltonaLab software is pressed, the running diagram replaces the names of the input signals of the block AndroidRemoteControl with theirs values and sends the result to the phone. For example the text is replaced with:

Temp is: 23.5 C
Heather bath: Off
Fan bath: On
Lamp yard: Off

More information about how to format text can be read at the article Text formatting conception:

https://scada.altonalab.com/index.php/en/conceptions/text-formatting-strategy

 

 

Simple home security system

Experiment: Simple home security system.

AltonaLab diagram: KIT_SimpleHomeSecurity.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • Mini PIR motion sensor;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

The idea - Imagine you have a property 100km far from you and you do not know what is going on with it. A non stop running computer equipped with AltonaLab software and needful hardware will help you to monitoring your remote property:

  • PIR motion sensor - it is very cheap but it works more than perfect. If someone passes a few meters in front of it, the sensor's output will become at a high level for a few seconds. The sensor's output signal will be measured with an analog input of a Numato board and every security event will be caught. Let say we put the sensor in the living room;
  • Temperature sensor - some time the temperature in a remote object is very important to be monitored, for example, at the winter time the water pipes can froze, so if we know the temperature in an area close to the pipes, we can avoid the problems;
  • AltonaLab diagram has a block MailSender. You will receive an e-mail each time, when the PIR sensor catches a moving. You will receive an addition e-mail every day at 20:00h. With every e-mail you will receive an information about the temperature too. An additional e-mail at 20:00h is very important, because if there is not security event, you will receive at least one e-mail daily and you will know what happen with the house temperature. If you don't receive your daily e-mail, this is an important situation too - maybe your computer is crashed and stopped to work or someone stole your computer. If you rarely delete your emails, you'll have a history of what happened to your property in the last week or month.

Warning!!! Before starting the AltonaLab diagram, you must to do the next:

  • Set the CommPort property of Numato block in the diagram;
  • In the block MailSender to set all the properties related to the mail account, which you will use: Server, Port, UserName, Password, SenderEMail, RecipientMail, RecipientName. MailSender block is well described at the article with URL below:

https://scada.altonalab.com/index.php/en/descriptions-of-the-functional-blocks/internet-library

Because at this diagram, AltobaLab is a mail client, which is connected to the mail server, please read careful at the article above: How to send e-mail via GMail account - some special settings in the e-mail WEB site are needed, in other case, AltonaLab will be blocked to send mails from your e-mail server! If you use other mail server than GMail, similar settings are needed!

 

Please be very careful with PIR sensor! It is very small and it has not good readable texts on its board about its pins. Its board has two sides, one with electronic elements and other with soldering. The image below is with electronic elements on top side. The left pin is Positive power supply, the middle pin is signal output, then is GND. The pins of a PIR sensor are connected to the Connector board by cables Male to Female!!!

 

 The used AltonaLab diagram is:

  •  Because the diagram has to work on non stopped computer up to an infinity time, a Numato block is without fast optimization, so the parameter FastMode is unchecked and a parameter CommunicatePerSec is set to 1 sec. With this settings, when there is an event from the PIR sensor, it will be caught with 1..2 sec delay, but in this security system, the short delay is absolutely not a problem;
  • GPIO 0 from Numato board is used as analog input to measure the temperature and GPIO 1 is used as analog input too to catch the event from PIR sensor. When there is not a PIR sensor event, its output is measured as around 0 ADC value, when there is a moving in front of the sensor, its output is around 610  RAW ADC value. This is the reason because a HiHysteresists parameter of the block SchmittTrigger is set to 500 and LowHysteresists is set to 300. Using the block SchmittTrigger weconvert analog value from the PIR sensor to a digital signal;
  • A measured temperature and a PIR sensor condition are shown with a text control and a lamp controls on the top side of the diagram;
  • At the block MailSender, using the parameter Inputs are added three inputs: Date from datetime type, LivingRoom from digital data type and Temp from analog data type. Those three signals are appeared as inputs of the same block. Then at the block's parameter Body is set the text below, which will form after the formatting a body of the send e-mail:

 

Date: <Date;dd.MM.yyyy HH:mm:ss>

Living room: <LivingRoom>

Temperature: <Temp;1>

 

The article from the URL below explains how to use a Text formation conception:

https://scada.altonalab.com/index.php/en/conceptions/text-formatting-strategy

Into the text of the e-mail body are used names of the block's inputs. When the block's input DoSend becomes to a high level, the names of the block's inputs will be replaced with theirs values and the result text will looks like the text below:

 
Date: 12.04.2020 11:39:18
Living room: On
Temperature: 19.5

You can easy add more inputs of a MailSender block if you want to monitoring more PIR or other sensors. At the top of the diagram are located two more lamp controls, one of them Mail is sent: will Turn ON when the e-mail is successfully sent. If some of the parameters of a MailSender blocks related to an identification to a Mail server are not correct, the Lamp control Mail send error will Turn ON.

  • The block MailSender will send a mail in two reasons - if there is an event from a PIR Sensor or the output of the block TimeSchedule becomes to a high level. The block TimeSchedule is set to send a mail every day at 20:00h. This mail is very important, because if there is not a PIR event a long time - weeks or months, using the mail from 20:00h you will know the temperature of your remote house. The other purpose of this daily mail is to know the computer is still running and is not crashed;

 

Temperature control of 12V lamp

Experiment: Temperature control of a surface of 12V electrical lamp.

AltonaLab diagram: KIT_TempControl.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • 2 relay controller;
  • Lamp 12V;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

The experiment is very interesting, we will control a temperature of a surface of an electrical lamp. For this purpose we will touch the black sensitive element of an AltonaLab temperature sensor to the surface of an electrical lamp.

A view of the hardware diagram is shown below. GPIO 0 of a Numato board is used as analog input where the output of the temperature sensor is connected. One of the relays of a Relay board is controlled by a GPIO 4 of the Numato board. GPIO 4 is set as a Digital Output. The 12V power supply is connected to the first input connectors of a 5V power supply board. The second input connector, which is with the same voltage 12V is connected to the next board - 2 relay controller.

 

A real image of the connected boards. Please note how the black sensitive element of AltonaLab temperature sensor is touched the surface of a lamp!!!

An image of a running diagram:

 

The diagram consists of the following controls:

  • A Text contol in red color in the upper left corner of the diagram - shows the current temperature of the lamp surface;
  • A Lamp control in the upper right corner - indicates whether the lamp is ON. If the Lamp is Turn ON, its temperature increases;
  • A graphic control, where in a blue color is shown the desired temperature, which is set by the scroll bar below, in red color is the real current temperature of the surface of the lamp. The temperatures are shown in range 10..60[C];
  • Under the graphic control is located a blue text control, which shows the desired temperature of the lamp;
  • The bottom control is a scroll bar that sets the desired lamp temperature. It is set to work in range
    20..50[C], which means the desired temperature can be changed in this range;

Before starting the diagram, the ComPort of a Numato block has to be set. Move the temperature sensor by hand so that its black sensitive element to touch the glass of the lamp and then run the diagram. Then move the position of the scroll bar at right, which will increase the desired temperature of the lamp. For example, set the desired temperature to 30[C]. Because the desired temperature is over the temperature of the lamp, the lamp will Turn ON and its temperature will start to increase. When the temperature of the surface of the lamp increases over the desired temperature, the lamp will Turn OFF and the temperature will start to decrease. This loop will continue to infinity.

How the diagram works:

  • Numato block - the block works in the faster possible mode. The parameter CommunicatePerSec is set to Zero, which means that commands to the device are sent immediately one after the other. Additional the parameter FastMode is checked, which means all the software time delays are close to Zero. GPIO 0 is used as analog input, the measured value of the analog input is presented as block's analog output IO00. GPIO 4 is used as digital output and is presented as digital input IO04 of the block. This means, when the digital input of the block IO04 becomes to a high level, the digital output GPIO4 of the Numato device will become to a 5V level. After each reading of the value from the analog input, the OnRead output becomes to a high level for a short time and this event signals the next block to process its calculations.
  • AltonaSensorTemp - the block converts the measured RAW data of the analog input of the Numato board which is in range 0..1023 to temperature. The parameter QueueSize is set to 5, which means the block calculates the average value of the last 5 measurements. Output of the block is a Current temperature of the surface of the lamp and is shown with the red text control at the top left corner of the diagram. The block calculates its values each time when the input Process becomes to a high level.
  • Block ScrollBar is connected to the ScrollBar control. When the scrollbar control is scrolled, the output of the block also changes. The range of the scrollbar is set to 20..50. With right mouse button click over the scrollbar control can be changed its parameters Min and Max which inthis diagram are used for minimal/maximal values of the desired temperature;
  • At the block ExpressionUni, theexpression of the output Y1 is set to X1-X2, which means the block is used to subtract the current temperature from the desired temperature. The block will calculate the expression only when the input DoCalc becomes to a high level. This happens each time when the previous block is ready with its calculations. At this diagram, the calculations are a few times per second;
  • The difference between desired and current temperature is an input of the SchmittTrigger block. The block has two parameters HiHysteresis set to 3 and LowHysteresis set to 0. More about this trigger can be read at the URL below:

https://en.wikipedia.org/wiki/Schmitt_trigger

The block is very interesting and important in diagrams, which are used to control some processes as temperature. When the input value of the block becomes over the HiHysteresis value,the output of the block becomes to a high level. Then the output of the block will become back to a low level, when the input becomes under the LowHysteresis value. So it is important to know that - when the difference between LowHysteresis and HiHysteresis is small, the lamp will Turn ON and OFF very often and this will reduce the life of the lamp and relay, but the error between desired and real temperature of the lamp will be small. If the difference between  LowHysteresis and HiHysteresis is big, the lamp will Turn ON and OFF less often, this will safe the life of the Lamp and relay, but the error between desired and real temperature will be bigger.

  • Logger of desired and current temperatures is organized by blocks DataSetStorage and DataSetImage. DataSetStorage is similar as DBFStorage block, but saves the input values only in the computer's memory instead in DBF database, which is enough for the current experiment. At its parameter Settings are added three values: Temp from analog data type, DesTemp from analog data type and Date from date data type. Inputs with same names are appeared at the block. The block is set to save last 10 min of the values in the computer's memory. The block's parameter DataSet is shown below:

Each time, when the block's input Append becomes to a high level, a new record with current values of inputs Temp, DesTemp, Date is added to the computer's memory. Records oldest than 10 min are deleted automatically from the DataSet.

The next block DataSetImage shows the saved in memory values from the previous block to the Image control.

 

Simple weather station

Experiment: Simple weather station.

AltonaLab diagram: KIT_SimpleWeatherStation.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • AltonaLab humidity sensor;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

It is time to build your first simple weather station. At the end of this article is explained how to add some additional sensors and your weather station will become professional.

The idea of the weather station is: A non stop running computer with the hardware shown below is gathering data for temperature and humidity and save the sensors values to a DBF database. The computer has a WEB cam directed to some outside area, which is interested to be seen when we want to know more about real weather condition. The diagram has a Forecast block, which shows the forecast information for current Earth location. All this information is uploaded to the FTP server on every 10 min in order to support a weather WEB site.

 

Warning!!! Before starting the AltonaLab diagram, you must to do the next:

  • To set some properties in block FTPUploader:  FTP Server, FTP User, FTP Password, FTP Port, FTP Folder;
  • To create an account in WEB site: MyWeather2.com, to get an unique access code from this WEB site and then to set property UniqueAccessCode inblock ForecastMyWeather2. This process is explained below in this article.

 

The used hardware is:

 

The used AltonaLab diagram is:

A Demo WEB site of the weather station is published at the URL below:

http://altonalab.com/kit/SimpleWeatherStation/kit_simple_weather_station.php

The content of the WEB page of a weather station can be downloaded from the URL below:

https://scada.altonalab.com/images/KIT_WEBSimpleWeatherStation.zip

 

This experiment is very similar to the experiments - Logger of temperature and humidity and the next one - WEB publisher and mostof the blocks, theirs purpose and properties are already explained. The new in this experiment is:

  • This is very important!!! The real weather station has to work many years without stop. This is the reason, because every block in diagram has to be optimized for minimal load of computer's processor, memory, hard drive;
  • The parameter FastMode of a Numato block is unchecked and parameter CommunicatePerSec is set to 2 sec. In this mode, the communication with the device is slowly, but because we save one record in database per one min, this period of communication is fine;
  • The logger time period is one week, this means we store in DBF database records for a last week. The input Append of a DBFStorage block is connected to a PulseGenerator, which pulse is once per a minute - we store at the DBF database one record per minute. For one week, the DBF database will store 7(days)*24(hours)*60(min) = 10,080 records. The input DeleteOld of a DBFStorage block is connected to a PulseGenerator, which pulse is once per 24 hours., this means one time per 24 the old records in the DBF database, older than 7 days, will be deleted automatically and the database will not grow to a dangerous size. When the size of the database is too large, it can crash. The true is, DBF database will survive if the time period is one month or one year. For one month, the number of records will be: 30(days)*24(hours)*60(min) = 43,200 records, for one year: 365(days)*24(hours)*60(min) = 535,600 records.
  • The upload period to the FTP Server is 10 min. If we upload on every 5 min or least, every uploaded picture will increase a lot the internet traffic to the FTP server. If the weather station will work months and years, we have to save the communication resource, so communication session per 10 or 15 min is fine. In this experiment, temperature and humidity values are uploaded only with text in info.xml file, instead of converting the text controls to JPG files and upload the JPG files to the FTP Server. This way saves a lot of internet traffic too;
  • The diagram contains a block ForecastMyWeather2. The block is well explained at the Weather library documentation of AltonaLab, please read the article in URL below:

https://scada.altonalab.com/index.php/en/descriptions-of-the-functional-blocks/weather-library

The Forecast block is easy for use, just set its properties Latitude and Longitude with a GPS location of your living place. Then you have to create your account to a WEB site: MyWeather2.com.  The created from account - unique Access Code has to be entered in block's property UniqueAccessCode. Finally just set the property Connect to image control - a name of an existing image control ImageForecast, which is located at a top right angle of the diagram. When the input DoForecast becomes to a high level, the block will draw the forecast information for today and tomorrow at the image control. When is time for a FTP session, to the FTP Server will be uploaded the contents of an ImageForecast control converted to a JPG file.

 

Some tips about weather station equipment:

  • The both sensors for temperature and humidity can work without problems with 20 meters long cables between sensors and a connector board. So the 24h running computer, Numato board and other hardware can be placed inside the house and the sensors to be mounted outside with up to 20 meters long cable;
  • The outside mounted sensors have to placed inside the weather shelter. The purpose of the shelter is to protect the sensors from a direct sun light and against a rain and a dust. The sensors have to placed at 2 meter distance over the ground, for USA at 1.6m over the ground. The low cost plastic shelter is shown below:

 

The shelter can be made from a wood. At this case the measured temperature will be professional and will have very small error. Below is a picture of a professional shelter:

 

 

Some ideas for improvement of a weather station:

  • Numato 8 channel USB GPIO module used in this experiment is not the best choice for a weather station. A better choice is a SNMP device shown below:

https://altonalab.com/shop/snmp_controllers/smnp-controller/

The SNMP board is an ethernet device, which can work up to 50meters distance from a computer and can be placed inside the outside weather shelter, very close to temperature and other sensors. The device works well in 20 degrees centigrade under zero. It has 8 analog inputs 0..3.3V, so the connector board has to be:

https://altonalab.com/shop/connector-boards/connector-for-adc-3-3v/

  • An Air pressure sensor can be added to the weather station. An air pressure information is very interesting. The sensor is easy to use and has a block in AltonaLab software designed to it. The name of the block is AltonaSensorAirPress.

https://altonalab.com/shop/sensors-analog-out/altonalab-air-pressure-sensor/

  • From AliExpress can be bought a Wind speed and Wind direction sensors with voltage output in range 0..2.5V or range 0..5V. AltonaLab software has a block AverageValAngle from a library Mathematical, whichcan calculates an average value of input signal, which is in degrees or radians:

  • To the AltonaLab diagram can be added a block WindRose and then the Wind speed and direction can be shown as Wind Rose in Image control:

The idea of Wind Rose control is to show the wind speed and direction for last 12h in 6 roses, every rose is for 2h. Then we will know how the wind speed and direction are changed in last 12h. Of course a number of roses and theirs periods can be changed.

  • From AliExpress can be bought a rain sensor. The more it rains, the more often it switches the normally closed contact of the sensor.

 

The contact of the sensor can be connected to a Contact sensor board:

https://altonalab.com/shop/sensors-analog-out/contact-sensor-board/

The output of a Contact sensor board can be connected to analog input of a SNMP board. Then we will have an information about the rain and to show this information together with other sensors.

 

An Image control with a weekly complex information from sensors for temperature(red), humidity(light blue), air pressure(black), wind speed(red) and rain (dark blue) is shown below, It is from a real running weather station working with AltonaLab software:

 

 

 

WEB publisher of the logger data

Experiment: WEB Publisher of logged data with temperature and humidity.

AltonaLab diagram: KIT_TempHumWEB.nsm

Used hardware:

  • Numato 8 channel USB GPIO Module;
  • Connector board for ADC 5V;
  • AltonaLab temperature sensor;
  • AltonaLab humidity sensor;
  • 5V multi connector power supply board;
  • 220V to 12V, 2A power supply;

WEB Publisher is a very powerful tool for many areas. For example, if we want to monitoring the temperature and humidity conditions of our home and how the flowers feel when we are away in holiday, then we can use the described below Publisher. The non stop running computer in our home will upload to FTP Server an information for temperature, humidity and image from WEB cam, directed to our flower. It looks difficult, but using AltonaLab is very easy.

The experiment demonstrate two type of WEB site publishing:

  • Saving as JPG images some of controls available on AltonaLab diagram, then uploading the saved JPG files to the FTP Server;
  • Saving some signals as tags in XML file, then uploading the XML file to the FTP Server;

The main idea of WEB publisher is - using the parameter For upload of block FTPUpload, we can choose the names of which of the existing controls of the AltonaLab diagram to be uploaded to the FTP Server. In the current diagram, are selected: the two Text controls for Temperature toTemp and for Humidity toHum, ImageControl and WebCam controls. When the input DoSend of a block FTPUpload becomes to a high level, all the selected controls are saved as image files with jpg extension and Name of the file is same as Name of the control, then this files are uploaded to FTP Server. Then we just have to refresh the Internet browser and new images will be shown on the WEB page. This very easy to use way has one serious disadvantage - an internet traffic. If our non stop running computer uploads to the FTP Server four images on every 5 or 15 minutes, for 24h it will rise a lot of internet traffic. So we have to find a way to reduce the traffic. This is the reason because the current Date and current state of a Temperature and a Humidity to be saved to TAGs in XML file and then to upload the XML file to the FTP Server.

Before starting of the diagram, please read all the article, because many additional activities are needed.

The used hardware diagram is same, as in the previous experiments for measurement of temperature, humidity and logger.

The used AltonaLab diagram:

The demo WEB Page can be seen at the URL below:

http://altonalab.com/kit/kit_demo.php

The features of the WEB page are:

  • Some of the information on the Page is gotten from a file info.xml, which is prepared and saved from AltnaLab diagram and then is uploaded to the FTP Server;
  • Date at the top of the WEB page is gotten from tag Date in XML file;
  • Temperature and Humidity are show in two columns, the left values are gotten from the TAGs in XML file, the right columns are small JPG image files, which are uploaded to the FTP Server;
  • WEB cam image is presented with WebCam.jpg;
  • The bottom sensors history graphic is ImageControl.jpg;

 

AltonaLab diagram consists of six parts:

- Controls - two text controls for showing the current state of temperature and humidity, an Image control to show the history of the sensor's signals, a button Upload to FTP, when we press the button, all the information will be uploaded to FTP server, FTP Result - a text control which shows the result of FTP operation, WEBCam control - directed to the monitoring object;

- Measure of temperature and humidity - is same as previous experiments. The Numato functional block reads the voltage values of the sensors for Temperature and Humidity. Then voltage values are converted to Temperature and Humidity by the blocks AltonaSensorTemp, AltonaSensorHumidity;

- Logger - this part is well explained in experiment Logger for temperature and humidity. The block DBFStorage saves the measured values of Temperature and Humidity in DBF database, the block DataSetImage shows the contains of a DBFStorage block on an Image control;

 - Preparation of info.xml - there are three blocks StrFormat. They are used to convert theirs inputs Date, Temp and Hum to string outputs. StrFormat block uses a Text formatting conception, which is described below:

https://scada.altonalab.com/index.php/en/conceptions/text-formatting-strategy

For example, the Temperature is converted to a string with one digits after the dot, because in the block's parameter Text of block StrFormat is set the formatting string <Temp;1>, where Temp is a name of the block's input. The Date is converted to a string with formatting text set in parameter Text of the block StrFormat: <Date;dd.MM.yyyy HH:mm>, where Date is a name of the block's input. The result of the block is 22.03.2020 16:15. The outputs of the three StrFormat blocks are inputs of block FileStoreConditions, which has abilities to be added unlimited number of inputs from different data types. In our case are added Date, Temp, Hum using the block'sparameter FileIO. This action adds inputs and outputs of the block with same names and prefix in names in inputs In_: In_Date, In_Temp, In_Hum.The mentioned inputs are from string data type. The property FileName of the block is set to: c:\AltonaLab\info.xml. When the input Write of the block becomes to a high level, the values of the all inputs will be saved as TAGs in XML file. The saved XML file in our case looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Results>
<Header>
<ExpDate>20200322 16:15:43</ExpDate>
</Header>
<Data>
   <Date>22.03.2020 16:15</Date>
   <Temp>26.0</Temp>
   <Hum>44.2</Hum>
</Data>
</Results>

- Upload to FTP - this part of the diagram is responsible to upload the JPG and XML files to the FTP Server. The block's parameter For upload of block FTPUploader opens the interface below, where all the existing controls on the current AltonaLab diagram are shown in the top grid. Selected controls are ImageControl, toHum, toTemp, WebCam. This means, when the block's input DoSend becomes to a high level, the selected controls will be saved as JPG image files with same names as the control's names. For example, the control toTemp will be saved as toTemp.jpg. Then all the saved JPG files will be uploaded to the FTP Server. At the same interface, at the next grid is added a local file for upload: c:\AltonaLab\info.xml. Together with the mentioned JPG files, the added xml file will be uploaded too:

FTPUploader block has a few parameters, important for a FTP communication: FTP Server, FTP User, FTP Password, FTP Folder. All they have to be entered before to start some tests of the AltonaLab diagram.

- The last part of the diagram is FTP sequence synchronization. The files can be uploaded of the button is pressed or on every 10 min - this is a time set in block Blk11, which is a PulseGenerator with 10 min time period. If one of these events happens, the sequence of FTP upload will be started. At first all the inputs DoFormat of StrFormat blocks will become to a high level and blocks will convert theirs inputs values to strings. At the same time a TimeOut for a 1 sec will be started - block Blk15 which is a TimeOut. One second later the input Write of the block FileStoreConditions will become to a high value and a file info.xml will be saved. At the same time a new TimeOut for a 1 sec will be started - block Blk17. And after one second, the input DoSend of the block FTPUploader will become to a high level, this will start the upload process and all the JPG and XML files will be uploaded. A few seconds later, the result of the FTP attempt will be reported to the SendResult output of the FTPUploader block. This string output will be shown on the Text control at the top of the diagram, located over the WebCam.

 

The content of the Demo WEB page can be downloaded from the URL below:

http://altonalab.com/kit/KITWebPublisher.zip

With someone FTP client, we can deploy the Demo WEB page to a FTP folder, the files are:

The main WEB page file is a kit_demo.php. If only JPG files are uploaded, the WEB page can be with file extension htm, but in out casea XML file is uploaded and its contents can be shown only with php code. Date is shown with the php code below:

$xml = simplexml_load_file("info.xml");
echo $xml->Data->Date;

The PHP code for Temperature is:

$xml = simplexml_load_file("info.xml");
echo $xml->Data->Temp;

 

And for humidity:

$xml = simplexml_load_file("info.xml");
echo $xml->Data->Hum;

Warning!!! Before starting the diagram, some settings have to be set:

  • Set all the parameters of FTPUploader block for FTP Server: FTP Server, FTP User, FTP Password, FTP Folder;
  • Click with right mouse button over the WebCam control and then at the parameter WebCam, choose an existing WEB cam on the computer (the parameter is a combobox);
  • Of course a Communication port of Numato functional block has to be set too - as all the previous experiments;

 

Subcategories