This is how you make your own pollen alarm

You can find excellent hay fever forecasters online that are based on factors such as temperature, wind and precipitation. However, these pollen radars do not take the plant species into account, while an allergy often occurs in specific species. We build a pollen alarm that only warns for pollen from your chosen plants in a certain amount.

Grocery list

For example at Martoparts.nl

1 NodeMCU module (€10)

For example at Conrad.nl

1 strain relief M10 (€ 1,-)

1 PCB 80 × 50 mm (€3.30)

1 Plastic housing 85 × 56 × 39 mm (€4.25)

1 screw terminal 2-pole (€0.20)

1 mains adapter 5 V, 1 A (€ 6,-)

1 Red LED (€ 0.10)

1 Green LED (€ 0.10)

2 resistors 100 ohms (€ 0.10)

Other supplies: soldering iron and soldering tin, side cutters, screwdriver, drill, file, superglue, single-pole cord (30 cm), multimeter (optional).

Total costs: approx. € 24.75

During the past 'winter' many hay fever patients already had complaints. Anyone who is allergic to pollen from alder or hazel has had it unprecedented early this year and it seems that we will have to get used to plants, trees and grasses that bloom all year round. Fortunately, most pollen allergy sufferers only take turns during the time a specific strain is blooming. A pollen alarm therefore only makes sense if it takes this into account.

It starts of course with reliable data obtained from pollen detection. Our source is the Leiden University Medical Center, whose Pulmonary Diseases department analyzes air samples on a weekly basis. That's traditional craftsmanship: the air samples consist of seven strips of adhesive tape (one for each day of the week) that are examined under the microscope! The results of the weekly count are published on the LUMC website.

Of course, this count is location-specific and the amount of pollen grains detected in Leiden can differ greatly from that in Limburg, just to name a few. Nevertheless, it gives a good indication and by experimenting with the quantities, the data can also be used for other places. We use the numbers from the table to determine whether a plant exceeds a certain standard. If so, a red LED lights up and a warning is sent by email. If the value falls below the standard again, the red LED goes out and an e-mail follows with the message that the warning has been withdrawn.

Hardware

In terms of hardware and housing, this project excels in simplicity. It takes a mains adapter, a compact housing and a strain relief, a NodeMCU module, two LEDs, two resistors and a circuit board to solder the whole thing on. This is therefore a very suitable circuit for those who are just starting to solder.

The green LED indicates that the system is operational and capable of retrieving the data from the source; the red LED lights up when the pollen standard set for the selected plants is exceeded. The circuit is powered by a simple power adapter of 5 volts, at least 1 amp. That can also be one with a USB connection, in that case you still need a suitable USB cable. The whole is housed in a compact plastic housing, for which you can of course also make or reuse something yourself. Finally, the strain relief prevents the power cable from being pulled out in the event of unintentional force being applied to it.

Install development environment

The ESP module is easiest to program using the Arduino development environment (IDE). You can download this here. Since this IDE is not primarily intended for this module, you will need to install some additional necessary components. Click on File / Preferences and enter on the tab Institutions Bee Additional Board Manage URLs the url //arduino.esp8266.com/stable/package_esp8266com_index.json in. Choose now Tools / Board: / Board Management… and type esp. Now pay attention: please install version 2.4.2 for the mail version of the program, due to incompatibility of the library sendemail.h with newer versions. For the version without mail, choose the latest version.

Select the module via Tools / Board / NodeMCU 1.0 (ESP-12E Module). Connect the ESP module via USB cable and select the correct port in Arduino IDE (Tools / Port, choose the com port with the highest number). If all went well, your setup is now ready to start programming.

Change code

You can download the ready-made program here. There are even two variants: for those who are satisfied with the warning LED and do not find it necessary to receive an email, there is a stripped-down version available. That makes a difference in the configuration and saves you the trouble of creating an account with a mail provider. Download the file pollen.zip and extract it to any folder. Open the file pollen.ino for the version without mail, or pollenmail.ino for the version with mail function (by double clicking on the file, it opens automatically in Arduino IDE, see also box 'Install development environment'). The explanation below is based on the mail variant, since that is logically the version that has the most to tell.

Top up ssid and password Enter your wireless network name and password respectively. Open //sec.lumc.nl/pollenwebextern in a browser and determine the line numbers of the plants you want to monitor. The first line of column names does not count, so the Hazel is line 1, the Alder is line 2 and so on. The sample code lists the values ​​for the most notorious plants. It is more convenient to replace them with the species you want to keep an eye on. Fill in the code Flora[] enter the corresponding line numbers of the table, separated by commas and at threshold[] the value for each plant. Determining this is a matter of experimentation: at 0 every pollen grain of a particular plant results in an alarm and at 100 there is a significant threshold. If you are very allergic to alder pollen and to a lesser extent to birch pollen, Flora[] the values {2, 8} and with threshold[] for example the values {0, 20}. Make sure the number of numbers in both rows is the same.

Download one of the two ready-made programs from pcmweb.nl

Set up mail account

You need a mail server to send mail. You could install it on the module, but you will almost certainly run into problems with it. Spam filters distrust mail from unknown sources and messages sent directly from the module will not reach most recipients. This problem can be circumvented by using a (free) provider, such as Mailjet.

Go to www.mailjet.com and create a new account by clicking Sign up for free. In order to use your new account, you must confirm your email address by clicking the button or the link in the confirmation email.

Log in to Mailjet and click at the top Transactional / SMTP. below Credentials you see username and password, both are needed in your program. Copy the string under User at server_login instead of USERNAME (between the double quotes). The string under password joins the line server_password instead of PASSWORD. The smtp server (in-v3.mailjet.com) and the port number (587) are already filled in. Fill in the place of [email protected] Enter the email address you use for your Mailjet account.

You can also send mail via Gmail. In order to use the smtp server, you will need to lower the account security. Click on your account icon and then Manage your Google account / Security and switch Access by less secure apps in. In the program you use your own sender address and corresponding password, smtp.gmail.com Bee server_host and gate 465 Bee server_port.

Explanation code

The code starts by embedding two libraries: ESP8266WiFi.h and sendemail.h. The first handles the connection to the wireless network and handles the web traffic. Thanks to this program, the module can be connected to the network with a few lines of code and used as a web client. The second library controls the connection to the mail server, allowing the program to send messages.

We declare some constants and variables, the most important of which have already been discussed in the paragraphs above. In Processing the data, the LEDs are turned off and the module connects to the WiFi. If successful, the green LED will turn on.

Processing the data

The function getinfo() is the heart of the program. This is where the web page containing the table is retrieved and analyzed. The variable pollen alarm gets the value false and i gets the value 0. As long as pollen alarm is false, the web page is read line by line, checking for string at a time pollen total occurs in it. That is the last column of the table, which lists all the pollen grains of a plant that have been counted in the past week. Variable i is incremented by one and now has the value 1. This loop traverses the rows of the table. Variable y is declared and gets value 0. This is part of a second loop that extracts all elements from Flora[] and threshold[] be ended.

Now the elements from the row Flora[] one by one compared to i to determine which plants are involved. In addition, flora[0] for the first element in the row, so if there 1 (Hazel in the table) all conditions are met in this example. Then the next line is read, which contains the numbers. The function toInt() serves to filter out spaces and other junk, leaving only an integer to be assigned to the pollen variable. If that number is greater than the corresponding value in the row threshold[] (in this case the first value in that row), pollen alarm becomes true and the function stops. If not, then j increased by one and the following elements are out Flora[] and threshold[] compared with i until there are no more elements. Then . becomes i incremented by one and the following rows are read from the table. Once the entire table has been processed, the variable data within will get the status true and the green LED will turn on.

Alert or not?

The features alarm() and noalarm() serve only to send mails, the first does this with a new alarm. The function email.send() gives a value true return if sending was successful and a value false if something went wrong. The construction used tests for this and returns the variable alarm sent the status true. When the alarm is cleared, the function noalarm() performed in the same way. If it is performed successfully, alarm sent the status false. As a result, an email will only be sent when the status changes, regardless of how often this function is run.

Have a look every hour

After running getinfo() this function looks at the variables pollen alarm, datain and alarm sent. If the first two are true, there is an alarm. The red LED will turn on and if not already done, an alarm mail will be sent. This is followed by a break of one hour. Has datain the value true and pollen alarm the value false, then there is no alarm and the red LED goes out. Has alarm sent the value true (an alarm e-mail has been sent), then an e-mail will follow about canceling the alarm and you will receive alarm sent the status false. There is also a one-hour break. Has datain the status false, then something went wrong while retrieving the data. The green LED goes out to indicate that the system is (temporarily) not functioning and there is a pause of one hour, after which walk() restart.

Upload and test software

If the file pollen_mail.ino customized in the Arduino development environment and the NodeMCU module connected, upload can begin. To test whether it works, you can temporarily add a plant (or tree) that certainly has pollen in the table at that moment. Open the serial monitor with Ctrl+Shift+M and upload the program with Ctrl+U.

After the upload is complete, you should see how the module first connects to the wireless network and then to the web server. Then follows the first plant, the applicable threshold value and the measured value. Then the values ​​for the following plants. If one of the measured values ​​exceeds the threshold set for that plant, the message appears Pollen alert!, followed by Mail with pollen alert sent. If all values ​​remain below the set thresholds, you will only see No pollen alarm. Is it all working so far? Then you can disconnect the module.

To test you can temporarily add a plant whose pollen is in the table

Preparation

First, drill three holes in the housing: two 5 millimeters for the LEDs and one 10 millimeters for the strain relief. Smaller is also possible, with a file you can make the hole to size. Install the strain relief and check whether the LEDs fit. Glue them into the housing with superglue. Also solder the wires to the LEDs, so that you can solder them to the printed circuit board later.

Building the circuit

As already noted, the hardware of this project is limited. The NodeMCU module, the two resistors and the screw terminal come on the PCB. Start by drilling 5 millimeters holes on the corners of the circuit board so that they fit over the screw holes of the housing.

By cleverly placing the components, they can be interconnected with solder. Keep in mind that (depending on the lanes on the circuit board) the module can sit crosswise in the housing and there is little margin! Therefore, first place the module on the circuit board and see if it will fit in the housing before continuing. Then fix the module by bending the pins on each corner a little outwards at the bottom, for example with the flat end of a screwdriver. Then place the resistors near the pins D5 and D6 and finally the screw terminal on the other side of the module. In the example, it has four connections, but only two are needed. The resistors and the screw terminal also stay in place best if you bend the legs a bit. Now cut all legs (including those of the module) to a length of about two millimeters with wire cutters and solder the parts and pins to be connected together. Also solder the four corner pins of the module, of which only one is connected to the screw terminal by the way. For tips on soldering, see this comprehensive guide.

Connect

The finishing is now easier than ever, because thanks to the ready-made housing, everything is already in place. All that remains is to connect the mains adapter and the LEDs. To start, cut the round plug from the cable. If you're using a USB power adapter, cut the micro-USB connector off the USB cable. Strip the individual wires over a length of about half a centimeter and tin the ends. If you have a multimeter, you can check the polarity (plus and minus) of the connections. If you don't have one, you can see if there is an imprint on (one of) the wires. Another possibility is to connect an LED with a 220 ohm resistor on one of the legs. Connect one of the adapter wires to the resistor and the other wire to the free leg of the LED. The wire that is connected to the long leg of the LED is the plus. Mark this thread. Insert the tin-plated ends through the strain relief from the outside and secure them in the screw terminal on the PCB, with the positive wire on FIN comes and the mind board GND.

Finally, connect the LEDs with pieces of wire, the ends of which you tint. Connect the cathodes (short legs) of both LEDs to GND, connect the anode (long leg) of the green LED to the resistor at pin D5 and the anode of the red led on the resistor at D6.

Commissioning

The circuit and the program have already been tested, so the adapter can be plugged into the wall socket. There's no serial monitor now, so you don't see anything happening initially. The green LED should light up within a few seconds. If it doesn't after a minute, there's probably a problem with the Wi-Fi and you'll need to move the circuit closer to an access point.

If the pollen standard specified in the code is exceeded, the red LED will also turn on and you will receive the warning email. Although the program retrieves the data every hour, it is good to realize that for the time being these are only refreshed once a week (on Tuesday afternoon) by the LUMC. The status remains unchanged on the other days, unfortunately this is no different. For that reason alone, it is certainly recommended not to make the threshold too high, so that you receive a warning in good time.

Let's hope for a pollen-free year with few emails!

Recent Posts

$config[zx-auto] not found$config[zx-overlay] not found