Promotion and Offer

Environmental monitoring with uChip – Open Electronics


Outfitted with an SD card and RTC, it detects and shops temperature, humidity and barometric strain utilizing a mixed sensor, displaying the information graphically on a contact show.


These days, additionally and above all in environmental monitoring, we’re transferring in direction of linked options and an increasing number of built-in into the IoT idea, however not in all functions it’s doable or handy to have the required Web connection. In such circumstances, it’s doable to avoid wasting the information obtained from the sensors and the relative measurements on non-volatile assist equivalent to an SD card, after which learn and course of them on a Private Pc. The undertaking proposed right here responds to this utility want, however it’s not merely a knowledge logger of environmental knowledge, however a whole native monitoring system with graphical outputs that may make us perceive the development of the noticed variables, which, on this case, are temperature, atmospheric strain and relative humidity. The graphical illustration is typical of the screens utilized in a medical setting, scrolling from proper to left in order to all the time show the most recent measurements.

For our undertaking, we use a {hardware} configuration described within the block diagram proven in Fig. 1. The core of the system is uChip, a module little bigger than a 16-pin DIP IC, geared up with a 32-bit microcontroller. The TFT show, contact controller, and SD card are linked by way of SPI bus, whereas the sensor makes use of the I²C-Bus interface. A serial interface, two digital I/Os or three analogue inputs or one analogue output can also be accessible for future functions. Thus, this technique lends itself to creating quite a few different functions.

On the SD card constructed into the show, the samples of the three variables are saved along with the timestamp, or timestamp, which permits the information to be simply processed on the pc. The system {hardware}, with modest software program modifications, additionally lends itself to monitoring analogue alerts.


Fig. 1


The uChip system

This tiny board, seen in Fig. 2, with dimensions of solely 28.5×10.16 mm, together with the USB connector, is produced in Italy and marketed by Open Electronics.

It’s primarily based on the Cortex M0 SAMD21-E18A MCU, 32 bit with 256 kB Flash reminiscence (248 kB helpful, the remainder occupied by the built-in bootloader) and 32 kB static RAM and is suitable with Arduino Zero. It has two 8-pin strip connectors with an equivalent pitch to a DIL16 chip. Either side of the board are seen in Fig. 2.


Fig. 2


Uchip will be powered from 3.3V to 5V on pin 16 (VEXT) or 5V from the micro USB socket and has a really subtle energy system, as seen within the practical diagram in Fig. 3.


Fig. 3


There’s a 500 mA switching Enhance (Step-Up: converts 3.3V from VEXT to 5V on USB) and a 1 A Buck converter (Step-Down: from 5V USB to three.3V on VEXT), it additionally has a linear regulator LDO (Low Drop-Out: low voltage input-output).

The latter regulator, a 3.3V NCP114 with a dropout voltage of 135 mV at 300 mA, powers the MCU and makes 3.3V 100 mA accessible on pin 15 by way of a solder jumper.

The VEXT voltage should not exceed 5.5V, which is the restrict worth of the LDO regulator.

You possibly can energy the board from the USB port at 5V, utilizing a traditional cellular phone energy provide, or apply a voltage from 3.3V to 5V on pin 16 (VEXT). Within the first case, enabling the Buck regulator by setting VEXT_SELECT (PA15), uChip provides different exterior gadgets at 3.3V as much as 1A from pin 16 which turns into an influence output. Within the second case, you possibly can join a 3.3V to 5V energy provide on VEXT or a lithium battery of acceptable capability to pin 16 which now turns into an enter. An excellent diode, fabricated from a MOSFET P with low conduction resistance, isolates the output of the Buck. In case the USB port is used as a number, it’s powered by the Enhance, which is robotically activated by the pin ID of the OTG connector. The Enhance can also be activated or deactivated with the BOOST_ENABLE (PA14).

In case you wish to cut back the noise generated by switching energy provides, you need to disable each Enhance and Buck converters on this case, the MPU is now not powered by USB however by pin 16 (VEXT), the voltage that should not exceed +5,5V. Throughout software program growth, the Buck is enabled by the presence of the USB voltage. The 2 switching energy provides are managed by software program utilizing the precise library or by intervening on the management pins. Fig. 4 exhibits the pin-out of the board.


Fig. 4


Desk 1 exhibits the accessible pins of uChip and people utilized by the undertaking.


The show 2.4 inch 320×240 pixel

The show is a 2.4 inch 320×240 pixel TFT contact with 18-bit by 262k colors with 6-bit per color encoding. The management chip used for this show is an ILI9341 whereas the Contact Display Controller is an XPT2046. The photographs in Fig. 5 present the show board used; as you possibly can see, on one facet it has a 14 pin connector for the show and the contact controller, on the other facet a 4 pin one for the SD-Card. Fig. 6 exhibits the schematic of this board, whereas Desk 2 exhibits the connections with uChip made on this undertaking. The alerts on the board are TTL at 3.3V and this isn’t an issue for uChip working at this voltage. The show can nonetheless be powered at 5V because of an LDO regulator that gives the precise voltage to energy the TFT and SD. To cut back the I/O pins and to optimize the interface, the show graphics controller, the SD, and the contact controller had been merged right into a single SPI bus.  To save lots of pins, the MCU-driven reset was additionally allotted with by connecting it to an RC (47kΩ and 100nF) on pin 4 of the TFT.


Fig. 5

Fig. 6


To be taught extra in regards to the contact show used you possibly can seek the advice of the doc “a-Si TFT LCD Single Chip Driver 240RGBx320 Decision and 262K color Specification” of ILI TECHNOLOGY CORP, accessible on the Internet on varied websites and probably on

Desk 2


The BME280 sensor

The BME280 is a mixed temperature, barometric strain and relative humidity sensor from Bosch, encapsulated in a tiny metallic case measuring simply 2.5×2.5×0.93mm. It additionally consumes little or no energy, so it’s significantly appropriate for cell telephones, GPS receivers or watches.

It has a strain accuracy of ±0.12 hPa which is equal to about ±1 m altitude distinction, with a temperature drift of solely 12.6 cm/°C. The temperature sensor has a decision of 0.01 °C and an accuracy of ±0.5 °C at 25 °C; as for the relative humidity sensor, accuracy of ±3 %RH at 25 °C is claimed.

The sensor has the identical pinout as the favored BMP280 however lacks the humidity sensor.

It may be powered with a DC voltage between 1.7 and three.6V; in our case, it’s powered at 3.3V by the LDO (low drop-out) regulator contained in the module (to the breakout board on which the sensor is commercially accessible). Fig. 7 exhibits the practical diagram of the sensor. All particulars on the Bosch sensor will be discovered within the technical doc BME280 “Mixed humidity and strain sensor” accessible on the Internet.


Fig. 7


The part has two distinct energy provide pins: Vdd, the principle energy provide for the analogue and digital circuits, and Vdd the facility provide for the digital I/O interface. Typically, they’re linked collectively, as within the case of the breadboard we used within the undertaking, seen in Fig. 8.


Fig. 8


A schematic of this board has been derived in Fig. 9. It incorporates a 3.3V LDO regulator and a degree adapter, essential to attach it to an Arduino Uno or different microcontrollers powered at 5V, within the case of uChip the alerts have to be at 3.3V and these parts are fully pointless. This board, having solely 4 pins, offers solely the I²C interface (CSB=1).

SDO pin permits altering the deal with (LSB) that by default is SDO=0 (jumper to floor) so the deal with is 1110110 (0x76). If SDO =1, an operation that requires slicing the jumper and connecting to Vdd, the deal with turns into 0x77, an operation that’s not essential on this case.

The Adafruit BME280 library with software program I²C interface requires the project of the pins used for the bus with the Wire.start (SDA, SCL) operate.


Fig. 9


The schematic

Nicely, now that we now have analyzed the person modules that make up the system, let’s see the wiring diagram of the complicated, that’s the board we deliberate to host the show board, the sensor breakout board and the uChip board. There’s additionally a serial interface and an analogue I/O on pin A6.

To show off the show is used a PNP transistor with low saturation VCE, the board already has a limiting resistor R6= 3.9Ω (see Fig. 6) for the 4 backlight LEDs and, to additional cut back energy consumption, we added one other resistor in sequence. So the backlight is managed by an I/O sign (ON = LOW).

You possibly can allow the Buck energy provide utilizing the operate within the uChipPowerManagement.h library:


For this technique, we advocate the facility provide from a micro USB connector, with the intention to cut back the consumption: utilizing the uChip Buck switching you get a decrease consumption, additional lowered by turning off the backlight of the show in regular operation to show it on solely when it should work together with the operator.

On pin 4 of connector J1 of the serial interface, it’s doable to energy the system additionally with a VEXT voltage from 3,3V to 5V. For voltages larger than 3.3V the show will seem brighter. You may also use a lithium-ion battery (3.7V typical). The facility consumption will increase considerably as a result of the Buck regulator isn’t used and the show consumes extra energy, so the resistance of R3 needs to be elevated. Powering from USB, the typical consumption of the system may be very low: about 12 mA with out a backlight and 38 mA when it’s turned on, i.e. whenever you intervene on the contact show to enter parameters or learn measurements. The show is robotically turned off at every sampling and after 5 seconds of inactivity.

For future functions there’s the J1 connector to make use of Serial1 to hook up with different gadgets, equivalent to a GPS receiver or different; and in addition the J2 connector, that2 permits to make use of of the 12-bit analogue enter A6 or the ten bit DAC output. These two connectors, with correct I/O initialization and subsequent program adjustments, additionally will let you monitor three analogue alerts A6 (J2), A3 and A5 (J1).


The RTC (Actual Time Clock)

The MCU SAMD21 has included a sound RTC (Actual Time Clock) and uChip makes use of a really exact 32.768 Hz quartz (FK135EIHM0.032768) with a tolerance of ±20 ppm and frequency stability of -0.04 ppm/∆°C. The one disadvantage is that eradicating the facility will trigger the set time to be misplaced, however this may be overcome with some artifice, as shall be seen later.


System energy provide

To energy all of it you possibly can flip to a battery or a mains energy provide; the only technique and skill to supply operational autonomy to the system is using a 12V lead-acid battery with a automotive charger that accommodates a 12/24V to 5V step-down switching with micro USB connector for uChip.

By utilizing a switching energy provide, which has excessive effectivity, the already low consumption will be additional lowered and the autonomy will be drastically elevated.

Alternatively, a lithium-ion battery (3.7V) might be used on the VEXT pin, accessible on connectors J1 and J2. On this case, as already talked about, consumption will increase.

The place mains voltage is obtainable, a traditional 5V energy provide for cell telephones with a micro USB connector can be utilized; nevertheless, this has the drawback of shedding the clock in case of even transient blackouts. The system will be improved utilizing two easy 1.5V batteries linked with a diode in sequence on the VEXT. Within the case of an influence failure, the batteries keep a voltage of about 2.4V, low for the show however enough to function the MCU.

A extra complicated energy provide system might be to carry the lead-acid battery in a buffer, with a stabilized 13.5V energy provide. The battery is also of modest capability (1.2 Ah) making certain continuity of operation even for a number of days of blackouts.


The libraries used to handle the uchip

Let’s transfer now on the firmware facets, ranging from the outline of the libraries used and, particularly, from the one for the show, whose controller is an ILI9341; for it can be found a number of Arduino libraries and we now have used the Adafruit_GFX, along with Adafruit_ILI9341  written by the gifted Limor Fried (Woman Ada). The primary one accommodates all of the graphics primitives and the second the specs of the controller utilized by the show. Additionally very helpful is the GFX guide (adafruit-gfx-graphics-library.pdf).

For the xpt2046 contact controller, we used the xpt2046touchscreen library by Pual Stoffregen exploiting the {hardware} SPI bus.

Adafruit libraries had been additionally used for the BME280 sensor.: Adafruit_Sensor.h  and Adafruit_BME280.h.

As for the uChip, it’s essential to obtain the library from the producer of the board (, to load the library on the Arduino IDE simply comply with the directions (in English) of the guide. For Home windows 10 it’s not essential to obtain the motive force, which is critical for earlier variations.

For set up directions see the information “uChip fast begin guide”, Itaca Innovation (the most recent model accessible on the time of this writing is uChip1.0.11).


System operation

Let’s now have a look at the general operation of the environmental monitoring system, with which we’re going to file temperature, strain and relative humidity on the SD card. The RTC clock is essential not solely to point the precise time at every measurement but in addition to scan the sampling interval.


The indication of time: the timestamp

So as to have an accurate temporal location, it’s essential to accompany the occasions with a mark that takes the title of the timestamp.

We, people, are accustomed to marking time as date and time, expressed in a non-decimal means and in addition in a different way expressed in lots of areas of the world.

This time-stamping is troublesome to handle if we have to consider time variations between occasions or create graphs of pattern time sequence.

In Unix and Unix-like working programs, time is represented as seconds elapsed from zero hours on January 1, 1970, and is named an epoch.

The Unix epoch is a 32-bit quantity with an indication, and on January 19, 2038, the counter overflow shall be reached with issues for a lot of computer systems utilizing a 32-bit counter.

The RTClib library has the getEpoch() operate that returns the epoch as unsigned lengthy, whose overflow is as an alternative 07 Feb 2106 06:28:15.

Additionally for simpler readability, on this undertaking, we most well-liked to point the timestamp with two integers (lengthy) of a most of 5 digits. The primary quantity represents the times elapsed since January 1, 1900, after all, it takes into consideration the leap years, and the second quantity signifies the seconds from midnight. This makes it simple to plot the time sequence of environmental measurements.

This technique can also be utilized by spreadsheets equivalent to Excel, which has as preliminary reference the first January 1900 and never 1970 whereas Matlab has the first January of 12 months zero, to change from one system to a different simply add the times of distinction.

With the library RTClib, the serial day is well calculated from the epoch, dividing it by the seconds within the day (86400) and taking the integer half. To have as reference 1 January 1900 it’s essential to add the times comparable to the years 1900 to 1970:


days1900= lengthy(epoch/86400)+ 25569;//days elapsed since 1/1/1900


As for the seconds of the day, simply remodel hours, minutes and seconds into seconds representing the fraction of the day:


secondspd= ho*3600 + mi*60 + se;//seconds elapsed within the day


This system transfers these two integers (lengthy) to the SD together with the temperature in [°C], the barometric strain in hectopascals [1 hP = 1 millibar] and the relative humidity in [%].

These 5 numbers are separated by commas. The file has a hard and fast title and the measurements are step by step appended to the queue.

That is what the ASCII file seems to be like:






Within the PC processing program, the seconds had been expressed as a fraction of a day = seconds/86400 then added to the times.

The information was processed in Matlab, however it will also be processed with a spreadsheet. In Excel the operate DATA.VALUE(“11/09/2020”) returns the serial quantity 44085, the date is handed as a string. Given the serial quantity, the inverse operate DAY(44085) returns the quantity 11, MONTH(44085) the quantity 9 and YEAR(44085) the quantity 2020. In case you additionally enter the fraction of a day, you may also get the hour, minutes, and seconds. Desk 3 is an instance of this:

Desk 3


Simply import them as a textual content file with the comma as separator, then calculate the serial quantity and from that derive day, month, 12 months, hour, minutes and seconds with the Exel features which have the identical title.


Producing the file for sd card

The epoch was used to generate knowledge file names with a decision of solely 10 seconds. Beginning with a really shut reference, i.e. the primary of November 2020, with 4 digits one can point out the times for an additional 27 years and with one other 4 digits, one can determine the ten seconds of the day (8640/day), assuming no file is created for instances lower than ten seconds.

So an 8-character lengthy file title is generated. It’s generated at every acquisition begin and printed on the “MEASUREMENTS” window.

Beneath is the technology program:


  // days since 01 Nov 2020 00:00:00 

  ng= int((epoch-1604188800)/86400); 

  // seconds/10 from midnight

  nm= int(secondspd/10);

  // file title

  String fn=Conv4digits(ng)+Conv4digits(nm)+ “.TXT”;

  // String to char array conversion



String Conv4digits(int n) {

  if (n < 10) return “000” + String(n);

  else if (n < 100) return “00” + String(n);

  else if (n < 1000) return “0” + String(n);

  else return String(n);



The title of the information generated by Arduino should not exceed eight characters, as within the outdated DOS, so this system checks that the variety of days doesn’t exceed 4 characters, that’s, that it’s between 0000 and 9999, with these directions:


 // verify the decrease restrict of days

if (ng < 0) ng = 0;

// days have to be 4 characters lengthy

if (ng > 9999) ng= 9999;


Fig. 10


The best way to present the environmental knowledge graphics

To characterize the historic diagrams of the three portions measured with the BME280 sensor, it’s essential to retailer the measurements in a buffer of acceptable dimension.

The TFT show has a definition of 320×240 pixels, which will be organized as 240 factors on the X-axis and 320 on the Y axis.

If you wish to use all 240 pixels to characterize the measurements over the twenty-four hours, you need to pattern each 1440/240 = 6 minutes (= 360 s), which is greater than positive for environmental measurements.

With uChip’s SAMD21 MCU there should not the reminiscence points that there can be with an Arduino Uno and a 3×240 integer (1440 byte) matrix isn’t important. A matrix of floats (2880 bytes) is also used, however it’s greatest to not waste an excessive amount of time on conversions throughout graphics whereas having excessive instances between measurements.

We selected to have a single GBuff buffer organized as a three-row by 240 column array of integer parts:


int GBuff [3][240];// knowledge buffer for graphics


The three strains characterize temperature, barometric strain, and relative humidity. The measurements are in float and, holding in thoughts the accuracy of the sensor and the perfect element of the graphs, the integers representing temperature in tenths of a level, strain in tenths of hP and humidity in per thousand remodeled into the vector GVal[3] are transferred to the buffer.

At every sampling, the utmost and minimal of every variable GVal[j] are calculated:


      for (int j=0; j <= 2; j++){

        if (GVal[j] > ValMax[j]) ValMax[j] = GVal[j];

        if (GVal[j] < ValMin[j]) ValMin[j] = GVal[j];



These values are used to create auto scale graphs, plotting the curves between these values will give a extra detailed illustration. The utmost and minimal are calculated from system startup. The switch of knowledge into the buffer has two modes of operation.

At first (first_buffer = true) the register fills up ranging from the left, from the column index BuffInd =0 till BuffInd =239, final level on the best:


      if (first_buffer){

        for (int j=0; j <= 2; j++){

          GBuff[j][BuffInd]= GVal[j];



        if (BuffInd == 240) first_buffer = false;     


As soon as the buffer is crammed, change the fill mode, all parts minus the final one, scroll one place to the left:


         for (int j=0; j <= 2; j++){

           for (int i=0; i <= 238; i++){

                          // shift left earlier values

             GBuff[j][i]= GBuff [j][i+1];                                                    }



Then the measurements from the final sampling are transferred to the final location (BuffInd = 239):


     for (int j=0; j <= 2; j++){

                        // replace buffer with final values

           GBuff[j][239]= GVal[j];



The PlotMeasures(int okay) operate will plot all three measurements in three separate 240×100 plots.

Shifting the information to the left creates a scrolling of the plot with an impact just like that of the outdated paper recorders and also you get a historic development of the measurements over the past 24 hours, very helpful for climate forecasting.


The menu on show

Urgent the contact show, at any time, a menu seems with 4 doable choices, comparable to 4 buttons, as seen in Fig. 11.


Fig. 11


The primary time it’s essential to press the final button, “SETTINGS” in blue color, to set the sampling interval in seconds, then a 12 months (the final two digits), month, day, hour, minutes and seconds. To set these seven numeric parameters you employ the GetNum(String immediate) operate that prompts the digital numeric keyboard, as seen in Fig. 12.


Fig. 12


After getting into the required parameter, you need to affirm with “okay” or cancel the entry with the “C” key. The setting finishes after getting into the seconds. From this system, the setting choice isn’t doable if the acquisition is in progress, i.e. if the show exhibits “Acquisition…”.

The second key, “MEASUREMENTS”, exhibits the date and time of the final sampling, the values of the measurements, the variety of samples saved on SD, the minimal and most values of the measurements and the title of the file, as proven in Fig. 13.


Fig. 13


On this case, Nc=269 samples had been acquired on SD. The final strains point out the minimal and most values, that are additionally the extremes of the graphs.

Within the newest model of this system, if the acquisition has been began, the title of the file to which the measurements are transferred can also be indicated.

The yellow “GRAPHICS” button will present the time plots of the three variables, seen in Fig. 14.


Fig. 14


This sampling, as seen in Fig. 13, was accomplished with 60 second interval, so the bodily variables diversified little and the autoscale creates the everyday steps.

The pink button, if the SD card isn’t inserted, stays with out writing and is ineffective. If the SD card is current and we now have not but began the acquisition, the message “Acq. Begin/Cease” seems. Urgent the button we begin the acquisition and the button turns into briefly pink with the writing “Acquisition Begin” after which turns pink with the writing “Acquisition…”. While you wish to finish the acquisition, press this key and it’ll briefly flip inexperienced with the message “Finish Acquisition”, after which you’ll be able to take away the SD card.

Processing the measurements with Matlab, we get hold of the next outputs:

Processing of uChip environmental measurements

Processed file title = 00583660.TXT

Recording begin date = 29-Dec-2020 10:11:04

Finish date = 29-Dec-2020 11:33:04

Variety of samples acquired = 83

Recording period = 82.00 [minutes]


The corresponding graph is proven that in Fig. 15.

Evaluating the graphs in Fig. 14 with these in Fig. 15, one can see that they’re very comparable, holding in thoughts that Matlab joins the factors with interpolated curves and that the horizontal scales are very completely different.


Fig. 15


This system written in Matlab to course of the information is the one in Itemizing 1.

Those that don’t have Matlab can download for free the GNU Octave program which now additionally has a great graphical consumer interface. This program additionally works with Octave with out modification.

Itemizing 1

% program TPHread.m reads knowledge written by the UChip system
% of environmental measurements with date in Julian and time in seconds
% Giovanni Carrera 29 Oct 2020
information= dir(‘*.TXT’);
nfile=dimension(information,1);% variety of information discovered
for indf=1:nfile,
fprintf(‘%d) %sn’,indf,information(indf).title);
whereas true
nf = enter(‘variety of information to be learn = ‘);
if (nf>=1) && (nf<=nfile), break, finish
nomefile = information(nf).title;
fid = fopen(nomefile);
if fid==-1
error([nomefile ‘: the file does not exist’]);
% Import the file
Information = importdata(filename, DELIMITER, HEADERLINES);
Gd = Information(:,1);% day vector in Julian
t = Information(:,2);% vector time in seconds
julian = Gd+t/86400+693960;% provides the fraction day and adjusts the 12 months
T = Date(:,3);% temperature in [°C].
P = Date(:,4);% strain in [hP].
RH = Information(:,5);% relative humidity in [%].
Ns = dimension(Information,1);
clear Information;
disp('Processing uChip environmental measurements')
fprintf('Processed file title = %sn',filename);
fprintf('Recording begin date = %sn', datestr(julian(1)));
fprintf('Recording finish date = %sn', datestr(julian(finish)));
fprintf('Variety of samples acquired = %d n', Ns);
Rt = julian(finish)-julian(1);
fprintf('Recording period = %6.2f [minutes]n', Rt*1440);
tz =julian-julian(1);
subplot(3,1,1), plot(tz,T,'r','LineWidth',2),grid,ylabel('T [C]'),title(['File: ' filename])
subplot(3,1,2), plot(tz,P,'g','LineWidth',2),grid,ylabel('P [hP]')
subplot(3,1,3), plot(tz,RH,'b','LineWidth',2),grid,ylabel('H [%]'),xlabel('days')


The uChip firmware is just too cumbersome to slot in this text, however yow will discover it within the obtain part of our web site together with the opposite undertaking information.


Checklist of Elements:

R1: 47 Kohm

R2: 1 Kohm

R3: 6.8 ohm

C1,C3: 100 nF

C2: 100 nF 63V polyester

T1: BC547


U2: BME280

LCD1: 240×320 2.4″ touchscreen show

J1: 4-pole male strip

J2: male strip 3 poles



– 4 pole feminine strip

– 8 poles feminine strip

– 14 poles feminine strip

– Printed circuit board S1540 (96×54)



The undertaking proposed right here is the idea for realizing detection programs of varied parameters, even not essentially environmental: it’s enough to decide on appropriate sensors and modify the firmware.





BME280 – Pressure, humidity, temperature sensor


Leave a Comment

2 + 10 =