Saturday, August 13, 2022
HomeElectronicsEnvironmental monitoring with uChip - Open Electronics

Environmental monitoring with uChip – Open Electronics



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


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

For our venture, 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, outfitted with a 32-bit microcontroller. The TFT show, contact controller, and SD card are related through 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 method lends itself to growing 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 indicators.


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 based mostly 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 appropriate with Arduino Zero. It has two 8-pin strip connectors with an an identical pitch to a DIL16 chip. Each side of the board are seen in Fig. 2.


Fig. 2


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


Fig. 3


There’s a 500 mA switching Increase (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 through 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 cellphone 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 may join a 3.3V to 5V energy provide on VEXT or a lithium battery of applicable capability to pin 16 which now turns into an enter. An excellent diode, product of 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 Increase, which is mechanically activated by the pin ID of the OTG connector. The Increase can also be activated or deactivated with the BOOST_ENABLE (PA14).

In case you need to cut back the noise generated by switching energy provides, you need to disable each Increase and Buck converters on this case, the MPU is 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 reveals the pin-out of the board.


Fig. 4


Desk 1 reveals the accessible pins of uChip and people utilized by the venture.


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 images in Fig. 5 present the show board used; as you may see, on one aspect it has a 14 pin connector for the show and the contact controller, on the alternative aspect a 4 pin one for the SD-Card. Fig. 6 reveals the schematic of this board, whereas Desk 2 reveals the connections with uChip made on this venture. The indicators 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 scale back the I/O pins and to optimize the interface, the show graphics controller, the SD, and the contact controller have been merged right into a single SPI bus.  To save lots of pins, the MCU-driven reset was additionally disbursed 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 may 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 Web on numerous 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 steel case measuring simply 2.5×2.5×0.93mm. It additionally consumes little or no energy, so it’s notably 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 reveals the useful diagram of the sensor. All particulars on the Bosch sensor might 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 primary energy provide for the analogue and digital circuits, and Vdd the ability provide for the digital I/O interface. Generally, they’re related collectively, as within the case of the breadboard we used within the venture, 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 stage adapter, crucial to attach it to an Arduino Uno or different microcontrollers powered at 5V, within the case of uChip the indicators have to be at 3.3V and these elements are fully pointless. This board, having solely 4 pins, supplies solely the I²C interface (CSB=1).

SDO pin permits altering the tackle (LSB) that by default is SDO=0 (jumper to floor) so the tackle is 1110110 (0x76). If SDO =1, an operation that requires slicing the jumper and connecting to Vdd, the tackle turns into 0x77, an operation that isn’t crucial 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

Effectively, now that we now have analyzed the person modules that make up the system, let’s see the wiring diagram of the advanced, 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 method, we suggest the ability provide from a micro USB connector, with a purpose 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 attainable to energy the system additionally with a VEXT voltage from 3,3V to 5V. For voltages greater than 3.3V the show will seem brighter. You may as well use a lithium-ion battery (3.7V typical). The ability 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 ought to be elevated. Powering from USB, the common consumption of the system could be very low: about 12 mA with out a backlight and 38 mA when it’s turned on, i.e. while you intervene on the contact show to enter parameters or learn measurements. The show is mechanically 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 connect with different gadgets, corresponding to a GPS receiver or different; and likewise 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 modifications, additionally help you monitor three analogue indicators A6 (J2), A3 and A5 (J1).


The RTC (Actual Time Clock)

The MCU SAMD21 has integrated 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 downside is that eradicating the ability will trigger the set time to be misplaced, however this may be overcome with some artifice, as will likely be seen later.


System energy provide

To energy all of it you may flip to a battery or a mains energy provide; the only technique and skill to offer 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 might be additional lowered and the autonomy might be enormously 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 out there, 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 temporary blackouts. The system might be improved utilizing two easy 1.5V batteries related 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 ample to function the MCU.

A extra advanced 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 just a few days of blackouts.


The libraries used to handle the uchip

Let’s transfer now on the firmware points, 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 (Girl 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 have been additionally used for the BME280 sensor.: Adafruit_Sensor.h  and Adafruit_BME280.h.

As for the uChip, you could 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 isn’t essential to obtain the motive force, which is important 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 take a look at the general operation of the environmental monitoring system, with which we’re going to document 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 approach and likewise otherwise 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 techniques, 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 will likely 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 venture, 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, in fact, 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 corresponding to Excel, which has as preliminary reference the first January 1900 and never 1970 whereas Matlab has the first January of yr zero, to modify from one system to a different simply add the times of distinction.

With the library RTClib, the serial day is definitely 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 you could add the times similar 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 rework 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 steadily appended to the queue.

That is what the ASCII file appears like:






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

The info was processed in Matlab, nevertheless it may 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. If you happen to additionally enter the fraction of a day, you can even 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, yr, hour, minutes and seconds with the Exel capabilities which have the identical title.


Producing the file for sd card

The epoch was used to generate information 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 occasions 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 era 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 previous 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:


 // test 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 right way to present the environmental information graphics

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

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

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

With uChip’s SAMD21 MCU there usually are not the reminiscence points that there could 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, nevertheless it’s greatest to not waste an excessive amount of time on conversions throughout graphics whereas having excessive occasions between measurements.

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


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


The three traces signify temperature, barometric strain, and relative humidity. The measurements are in float and, maintaining in thoughts the accuracy of the sensor and the very best element of the graphs, the integers representing temperature in tenths of a level, strain in tenths of hP and humidity in per thousand reworked 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 information into the buffer has two modes of operation.

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


      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 stuffed, change the fill mode, all components 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 previous paper recorders and also you get a historic pattern of the measurements during the last 24 hours, very helpful for climate forecasting.


The menu on show

Urgent the contact show, at any time, a menu seems with 4 attainable choices, similar 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 yr (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 attainable if the acquisition is in progress, i.e. if the show reveals “Acquisition…”.

The second key, “MEASUREMENTS”, reveals 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 have been acquired on SD. The final traces 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 finished 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 quickly pink with the writing “Acquisition Begin” after which turns pink with the writing “Acquisition…”. Whenever you need to finish the acquisition, press this key and it’ll briefly flip inexperienced with the message “Finish Acquisition”, after which you’ll take away the SD card.

Processing the measurements with Matlab, we receive 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 length = 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, maintaining 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 obtain free of charge the GNU Octave program which now additionally has graphical consumer interface. This program additionally works with Octave with out modification.

Itemizing 1

% program TPHread.m reads information 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 yr
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 length = %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 you could find it within the obtain part of our website together with the opposite venture information.


Listing of Parts:

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 venture proposed right here is the idea for realizing detection techniques of varied parameters, even not essentially environmental: it’s ample to decide on appropriate sensors and modify the firmware.





BME280 – Stress, humidity, temperature sensor





Please enter your comment!
Please enter your name here

Most Popular