Arduino distilling automation project. We make automation for a brewery on one board

Many people today dream of living in a "smart" home. But commercial solutions in our time repel their considerable cost. Fortunately, you can make your own home automation system using cheap and readily available components.



This article will show you how to control household appliances using an Android device and Arduino, in our case lamps. Moreover, even if you are new to programming and have no experience in writing programs for Android, you can complete this project without any problems.


The project will require a few elements: an Arduino board or any clone, a TTL-UART Bluetooth interface module with an operating voltage of 5 V, several relays and drivers (control circuits) for them, and, of course, an Android smartphone or tablet.


This project includes two separate parts: a hardware control scheme and an Android application. The communication between the control circuit and the Android app is done via a Bluetooth wireless interface. ASCII commands are sent from the phone to the Arduino, which are further deciphered and presented as commands to turn on or off a certain household appliance.


Most developers of applications for Android devices know the Java programming language, but in this case, knowledge of this language is not required, since there is a fairly simple and understandable App Inventor online development environment created at MIT. It is specially designed for people who are not versed in Java programming, and offers to assemble an application visually from blocks of operations. This is how our Android program looks like:



You can download the source code of the program, consisting of blocks in App Inventor, and the program itself with the apk extension.


Now you need to assemble the circuit, as shown in the figure below.



Note that the RX line on the Arduino must be connected to the TX line of the Bluetooth module, and the TX line on the Arduino must be connected to the RX line of the Bluetooth module.


To program the Arduino board, you must have the Arduino IDE installed. Below is a sketch for the Arduino.


const int led1 \u003d 2; const int led2 \u003d 3; const int led3 \u003d 4; const int led4 \u003d 5; byte serialA; void setup () (Serial.begin (9600); pinMode (led1, OUTPUT); pinMode (led2, OUTPUT); pinMode (led3, OUTPUT); pinMode (led4, OUTPUT);) void loop () (if (Serial. available ()\u003e 0) (serialA \u003d Serial.read (); Serial.println (serialA);) switch (serialA) (case 1: digitalWrite (led1, HIGH); break; case 11: digitalWrite (led1, LOW); break; case 2: digitalWrite (led2, HIGH); break; case 22: digitalWrite (led2, LOW); break; case 3: digitalWrite (led3, HIGH); break; case 33: digitalWrite (led3, LOW); break; case 4: digitalWrite (led4, HIGH); break; case 44: digitalWrite (led4, LOW); break;))

After you have written the sketch in Arduino and installed the application for Android, you need to connect from your phone to the Bluetooth module. To do this, turn on the power of the Arduino and the Bluetooth module and activate Bluetooth on your phone, making it visible to all devices as well. After that, in the search list for other Bluetooth devices, you can find this module. Enter the pairing code, which is usually "1234" or "0000".



The device with which you are pairing will be named in this case. After pairing, turn on the EG-HOME App and press the Bluetooth button to select the paired device in the program. After that, your phone will be connected to the control circuit, and by pressing the corresponding buttons, you will turn on or off the lamps.

In 2014, I came across a video of a guy making beer from beer wort concentrate. I fired up the idea of \u200b\u200bbrewing and then it started ...
Brewing beer from canned food became not interesting to me after the second time and I decided to switch to all-grain. Once I brewed beer on gas and realized that this was not my method. I decided to make an automation. The evenings became more interesting. I got so involved in programming that I was coding until 2-3 in the morning. Real-world tests were needed. In the bins I dug up a boiler and a faceted glass.

And this is what I ended up with

And now I'll tell you how to make such an automation.
First, we need the following details. I bought them in China.
ssd1289 or ili9341.
Solid-state relay for controlling heating elements (or circuit on)
Solid state relay for pump control, (for AC pump) or (DC)
Thermal sensor or or
Power supply 7.5-9V 1A. for instance
Connectors for connecting a temperature sensor and a pump and
(more )
(buzzer)
4.7k ohm resistor

Low voltage circuit

Power circuit. Be careful. Not sure - trust the professionals.

We take the cross-section of wires depending on the total power of the pump and heating element. For a solid-state heating element, a radiator is needed. it is not heated weakly. We stuff it all into boxes. Fill in the firmware, set up and brew beer.

(instruction inside)

But the basic functions were not enough for me. And I decided to screw up wifi. I bought the ESP8266 module on aliexpress. At the same time I ordered the module. guys from the forum, well, very much asked to implement it in the project (it is possible without it). And connected according to the following scheme

To power the wifi module, we need a 5V power supply. You cannot use arduino. You can use a separate power supply or convert 9V to 5V. To do this, you can assemble a simple circuit with a voltage regulator or buy a ready-made one from the Chinese. For example (there are a bunch of other options).

The next step is to flash our module with NodeMCU firmware. Downloading. We launch. Press Start and wait for the end of the firmware upload. Have you asked for it? That is great. Now we load the script. For this we need. There are of course other programs like. But I couldn't get them to work with my module. In ESPlorer, create a new init.lua file with the following content:

We change the name of the wifi network and the password to our own. Set the speed to 9600. Press the "Open" button (if it doesn't connect, pressing the reset button on the module can help). And click "Save to ESP". After loading the script, the module should connect to your router. This can be checked by going into the router and looking at the DHCP clients. If your module is not visible there, then something went wrong.

The web interface contains the following functions.
1. Monitoring of processes. You can monitor temperature, pump status, mash and boil performance. The web interface is equipped with a sound signaling device.
2. Load recipes to the controller memory and to a USB flash drive.
3. Building a global schedule for the entire cooking.






Login to the web interface

Automation in modern society is a necessary measure, because in the digital age it is extremely important to exclude the human factor in various industries in order to standardize and improve product quality. There are also areas where humans are simply not able to do what robots are capable of, for example, the production of nano-materials and microboards.

However, automation helps not only in production, but it can also be useful to the average person. For example, arduino brewery automatics make the product production process much easier. Let's figure out how automatic rectification for arduino and other things can help, and consider examples.

The main advantages of automated systems based on the Arduino microcontroller

Nobody forbids you to solder your own board and program it yourself using low-level languages. However, automation on arduino and ready-made microcontrollers will greatly facilitate the whole process and save time. After all, it is much easier to buy a ready-made product with a set of libraries and adapt it to your needs. And the available automation on the Arduino mega 2560 can be useful in many areas of life, from voice switches for a smart home to electric latches with a motion detector. The main advantages that the Arduino automation is famous for are:

  1. Low threshold of entry. There is no need to get an engineering education, just watch a couple of training videos and have a base in programming.
  2. A large number of already prepared libraries. Arduino is used in the CIS by many robotics amateurs, to the extent that the production of various electronics becomes their hobby. Accordingly, the user community is extremely active on the network, posts a large number of templates and is ready to help you in solving any problems. The quality of libraries, due to the low threshold of entry, suffers, but no one forbids creating your own, it is enough to study the semantics of the C ++ language or use ready-made translators.
  3. A large number of peripherals. It doesn't matter if you need an Arduino greenhouse automation or a light sensor, you will find any modules, up to sound sensors and voice recognizers. Yes, some of the boards cost a lot of money, but you can always find cheap counterparts, for example, the wi-fi module from third-party manufacturers esp8269, which is 10 times cheaper than the official one.
  4. A lot of information. Any problem you encounter has already been experienced by someone, and you will surely find a solution on Google. There is also a full-fledged literature with which you can familiarize yourself.

However, do not think that Arduino has no flaws. The board is famous for its low performance. In especially complex tasks and with a large amount of code, the response time can reach 1 second, which is unacceptable for microcontrollers. The flash memory of most modules does not exceed 1 MB, which is not enough for creating neural networks or using media files. Of course, you can connect an auxiliary memory card, but this also increases the response time, takes additional resources for its power supply and is done in a semi-handicraft way.

However, simple automated systems, for example, for brewing beer or greenhouses, do not require even some of the resources that the payment can issue. Accordingly, most users will find these disadvantages meaningless. If you decide to assemble your own 3-D printer or a more complex design, you should take a closer look at analogs. But the threshold of entry for competitors of Arduino will be much higher.

An example of process automation based on MK Arduino

The simplest example of automation of the process can be a greenhouse on an arduino. To create any system, it is worthwhile to clearly outline the tasks that it must perform. Using a greenhouse as an example, this would be:

  1. Creation of a special climate.
  2. Timely switching on and off lighting.
  3. Timely watering of plants and keeping air humidity at the same level.

Based on these tasks, you can immediately notice what you need to buy for the main board:

  1. Temperature sensor. He will make sure that the air does not heat up or cool down, being within the limits prescribed by the program. In case of temperature change, the board will turn on the air conditioner or electronic batteries.
  2. Light sensor. Of course, you can limit yourself to a software solution and buy expensive lamps with imitation of daylight. But if you want to create a full-fledged greenhouse, then it will be much more convenient to install an automatic ceiling, which will be controlled by Arduino.
  3. Humidity sensor. Here everything is the same as with the temperature, according to the prescribed scenario, the board will include sprayers and air humidifiers, if necessary.

When you have purchased all the necessary modules, all that remains is to program them. Indeed, without a code, these are just pieces of iron, not capable of anything.

MK Arduino programming for process automation. Example

As in the previous paragraph, it is important for programming to divide the task into separate sub-points and perform it sequentially. Arduino programming takes place thanks to commands in the AT and AT + interface, using prepared libraries. Accordingly, all scripts are written in a special environment in the C ++ language and, before doing anything, devote time to studying its semantics. In addition to performing simple functions, the system is also capable of storing scripts in flash memory, which is what we need in this example.

Do not forget that information from each sensor comes in real time and as variables, however, you can limit the response time, since there is no need to spend resources and measure each parameter constantly. Accordingly, set the on and off times for each sensor, or set the response time for a certain period.

Why did I need automation?

Automation is needed to facilitate the process, because this controller itself will monitor the temperature, maintain it and raise it to the required temperature pause. Also signal with a sound signal about the necessary intervention, for example, you need to fill up the malt or make an iodine test.

I decided to make my own automation from a finished project. It works on arduino, a temperature sensor, two relays, a display and buttons are connected to it. The first relay controls the heating element, the second relay controls the pump. The mash pump is very convenient because there is no need to stir the mash for the entire mashing process (for more details on how to brew beer, I recommend reading in my earlier ones)

I assembled the first automation using modules:

- Arduino mini
- Block of two relays 15A
- Display 2004
- Temperature sensor
- 4 buttons
- 5 volt PSU
Convenience of modular assembly, only lies in the fact that it is not difficult to get all the parts and almost nothing is needed to solder. But the biggest drawback is the huge number of wires, and the cheap Chinese relay interfered with the display, so the mechanical relay had to be replaced with a solid-state one.

Over time, I came to the conclusion that I need to assemble my automation on a chip with 64kb of memory (arduino mini has only 32kb) on one board. I did not find a ready-made solution, so I began to create a circuit myself and subsequently a board for my craft.

Scheme:

The scheme was developed and drew, so to speak, on my knee and for myself, for this there may be some shortcomings, but the scheme is completely working:

Pay:

I drew the diagram, then it remains to draw the board, first I drew using the program Sprint-Layout 6, very convenient, but not enough functionality in it, so I decided to leave it in the direction of the program DipTrace and this is what I got:

You can download the sources.
As you can see, I named my brewery QRBeer and this is version 0.5 ...

The board is ready, it remains to be made somehow. For this I decided to use. Why exactly them, and not LUT? I just decided to try this new technology for myself, I have already tried LUT, I felt it, so to speak, I will not say that I liked it ...

Photoresist:

To manufacture printed circuit boards using a photoresist, you will need:
- Film for printer
-
- Ultraviolet lamp
- Soda ash

ultraviolet lamp

To begin with, I will share information on how I did my UV lamp... At first I wanted to use a ready-made lamp, and then I decided to assemble it on six 3W LEDs:
and bought the same on Tao:


I glued the LEDs to the radiator, although it was possible to assemble them on a PCB, I doubt that they would overheat.
That's what I did:


Board manufacturing

1. So, I prepared the template, it remains only to print it on film. As I wrote above, you need film for a printer, I tried film for both a laser printer and an inkjet printer, the best option is obtained only on inkjet film. You need to print in negative and in mirror image:

I immediately laminated the template so that fingerprints and debris could be easily washed off.
2. Next, you need to sand our future board (falsified fiberglass). A slightly dampened regular sponge or melamine sponge is suitable for this:


3. After this procedure, copper still needs to be degreased with acetone:


As you can see in my photo, I degreased with an ordinary napkin, and I poured acetone into a bottle of peroxide, so it's more convenient to take ...
4. The next step is to cut the photoresist for your future board slightly with a margin and carefully remove the upper protective film so as not to damage it. If the photoresist is domestic, you need to peel off the matte side, if it is Chinese, then there is no difference ...
5. Next, glue the photoresist onto the textolite so that air bubbles do not appear under the photoresist, otherwise the paths will not appear in such places, cut off the excess ...
The process of gluing a photoresist is similar to gluing a screen protector to a phone.


6. When the photoresist is glued, the textolite with it must be passed through the laminator 2-3 times or use a warm iron and iron it through a sheet of paper folded twice:


The main thing is not to overheat the photoresist, otherwise it will turn out like this:


If you get a jamb when gluing the photoresist, then it's better to remove it (wash it off or scrape it off) and re-stick it, otherwise after etching the board it will be sad ... I won't remove this photoresist, I'll show you the final result.
7. We put a template on the textolite with a photoresist and press it with glass (I took it from an old photo frame), and put a load on the glass:


8. We illuminate the photoresist using a UV lamp. My lamp lasts about 2 minutes:


As you can see, the photoresist that was lit changed color from light blue to dark blue, and the exposed photoresist is very fragile.
9. Remove the glass and template. Excess photoresist can (optionally) be trimmed and carefully separated with tweezers:


10. The next step is to wash off the non-developed photoresist with alkali, for this we take 2 glasses of water and a tablespoon of soda ash, stir well. We peel off the top protective film from the photoresist and lower our textolite into an alkaline solution.


11. We take a brush and three of the photoresist in alkali, gradually the undeveloped photoresist is washed off:


Alkali can not be poured out, but left on the next board or to wash off the photoresist after etching, but more on that later ...
12. Etching board:
There are two most accessible methods: etching with ferric chloride or peroxide + citric acid and salt. I won't write about ferric chloride, but I'll probably describe it with peroxide:
- 100 ml. hydrogen peroxide 3% - it is sold in a pharmacy for 7-12 rubles
- 30 gr. citric acid (available at any grocery store)
- 1 tbsp. a spoonful of salt (both fine and stone are suitable)


All this is mixed in a container and the board with the finished photoresist is immersed there, after a while bubbles appear on the board:


And after a while, the "bare copper" is completely etched:


By the way, if etching at a higher temperature, for example, near an incandescent lamp or in a water bath, the etching will decrease by three, the main thing is not to overdo it, otherwise the excess will be etched ...
13. It is most convenient to remove the photoresist in the same alkali, in which the un-etched photoresist was washed off, after 20 minutes it will disappear by itself and you do not need to rub anything ...

And here are my "jambs":


Although not significant, but nevertheless, inattention is to blame for everything, did not notice air bubbles under the photoresist or overheated ...

The following board turned out to be "clean":


14. Next, we drill holes and tinker the board:


15. We solder all the details and wash off excess flux:


Soldered SMD components with a Chinese infrared soldering station, very convenient:

That's all, the most difficult is over, it remains to ring the tracks for a short circuit and start programming the chip.

Atmega644 programming

1. To start programming, you need to load the bootloader into it. This is not difficult with the Arduino UNO, but first you need to download and install the program.
2. The next step is to add or take a ready-made assembly to the installed program:
3. Fill the UNO sketch ArduinoISP:

4. And connect our board to UNO:


According to the sketch instructions:
// pin name // slave reset: 10: // MOSI: 11: // MISO: 12: // SCK: 13:
It turns out according to my scheme like this:

5. Next, install our board in the settings and load the bootloader:




If everything went well, we will see the message: "Bootloader recording completed"
This completes the bootloader "a loading, you can connect the display, buttons, temperature sensor and fill