- How to Adjust X and Y Axis Scale in Arduino Serial Plotter (No Extra Software Needed)Posted 1 week ago
- Elettronici Entusiasti: Inspiring Makers at Maker Faire Rome 2024Posted 2 weeks ago
- makeITcircular 2024 content launched – Part of Maker Faire Rome 2024Posted 3 months ago
- Application For Maker Faire Rome 2024: Deadline June 20thPosted 4 months ago
- Building a 3D Digital Clock with ArduinoPosted 9 months ago
- Creating a controller for Minecraft with realistic body movements using ArduinoPosted 10 months ago
- Snowflake with ArduinoPosted 10 months ago
- Holographic Christmas TreePosted 10 months ago
- Segstick: Build Your Own Self-Balancing Vehicle in Just 2 Days with ArduinoPosted 11 months ago
- ZSWatch: An Open-Source Smartwatch Project Based on the Zephyr Operating SystemPosted 11 months ago
Antennino: the low-power Arduino with Antenna
A multirole board, that stands out for its very low energy consumption and the possibility to be remotely programmed, emerges in the rich landscape of the IoT modules.
When talking about IoT, we usually refer to devices that are powered by batteries and that are scattered in the environment, for the purpose of acquiring and exchanging information concerning different (environmental or not) parameters. As regards peripheral devices, both the energy consumption and the possibility to update the firmware, without having to uninstall them (which is quite inconvenient, especially if the sensors have been hosted in places that are narrow or reached with difficulty), are important factors. The possibility to remotely update is also a benefit, even if the device must be – in order to be tested – in its natural place.
Antennino, the project described in these pages, has the aforementioned features: it implements an efficient energy consumption control and is updated OTA.
What is Antennino
The device we propose here is an Arduino-like circuit (the Antennino name is a portmanteau of Antenna and Arduino), a low cost and low power one, based on the Atmel chip and therefore perfectly compatible with the traditional Arduino IDE; the board integrates a communication bus and sensors, in order to acquire external information, in addition to a wireless link so to communicate with the outside world.
The beauty of Antennino, however, is that it is multirole, in the sense that the board itself, depending on how it is equipped, may be operated both from a remote module and from a data collector (gateway).
The heart of Antennino is the ATmega328P (the P indicates that’s a chip embracing the PicoPower technology, that is essential for the energy management we desired for this project) microcontroller. The communication with the outside world is carried out by means of an RFM69 (www.hoperf.com) transceiver module, that operates in the 433MHz frequency band and that supports the AES cryptography at a hardware level. A Flash memory has been placed on board of Antennino; it may be used in order to memorize the data concerning the reading of the sensors (Data Logger) or to implement the Wireless programming (OTA) of the Antennino module, a temperature sensor (DS18B20) and a photoresistor. In order to facilitate the use of additional external sensors, four Groove connectors are found: one for the RS232, one for the I²C-Bus, one of generic I/Os and one for the analog input. Moreover, Antennino has been arranged for the hosting of a small OLED display, to be used if it operates in the gateway mode. Antennino uses the same processor of Arduino Uno, therefore it could be used as a substitute of the same, in practice; given the wireless feature of our module, however, its main purpose is the one to create sensors or remote actuators that may exchange pieces of information with a gateway. We could create temperature, brightness sensors, alarm sensors for doors and windows, vibration sensors, remote actuators so to control a device etc. This is the functioning from a remote module.
The gateway may be an Antennino module (in the gateway mode) or, given that usually, the gateway is not battery powered, it could be an Arduino Uno, supplied with an RFM69 module, or a Raspberry Pi, still supplied with an RFM69 module. The solution with Raspberry Pi is the one proving to be the most suitable one since it enables the creation of a system for the memorization or post-processing of the received data. As regards the powering options, the possibilities are:
- to power Antennino via two standard 1.5V alkaline AA batteries or 1.2V rechargeable ones (the clips for the batteries are already found on the PCB);
- to power Antennino via a 3.6÷12 V external voltage;
- to directly power Antennino via a 3.3V, and to bypass all the regulators found on board.
As for this last possibility, please remember to never ever exceed the 3.3V voltage, otherwise you will damage the microcontroller and the different chips connected to it.
LowPower management via libraries for Antennino
Usually, when using a microcontroller of the PicoPower type, the management of the energy saving mode is carried out via specific libraries to be included in the firmware. Different depth levels of the energy saving mode are found, and in the deepest one the chip is as hibernated, and it is possible to wake it up only by means of an external hardware interrupt. But clearly, if we wanted to have our remote sensor to send us periodic reports, this solution would not be a viable one.
A slightly less deep mode is, in fact, the one that is used when we need the microcontroller to periodically wake up in an autonomous way from the idle state, so to carry out some tasks and then return to “sleep”. Usually, the timer waking the microcontroller at regular intervals is implemented via a timer that is internal to the microcontroller; therefore it is not set to a complete low consumption state, but it is left active in a state that is indicated by the WDT (Watch Dog Timer) acronym. Obviously, the fact that there is an active Timer causes a small but non-negligible power consumption, in the range of a few µA.
An alternative is the one we adopted with Antennino, in which we use an external interrupt manager, for the waking up of the microcontroller. This concept will be explained when examining the circuit diagram.
Antennino Circuit diagram
The heart of the system is the ATmega328p (U6) integrated circuit, whose timing is provided by a 16 MHz (Q1) resonator. A reset button (P1) and a notification LED (DL1), that occupies the PB1 pin, have been connected to the microcontroller. The CON8 connector is used in order to load the BootLoader, while the CON7 connector, coupled with a convenient USB/RS232 converter, is needed in order to normally load the sketches, via the Arduino IDE. Moreover, there are the CON5 and CON6 connectors, the ones that expose the available I/O pins of the microcontroller and that enable the application of an external 3.6-12 V power source or of a 3.3V direct one.
The Flash memory chip and the RFM69 transceiver have been connected to the SPI bus. As regards the RFM69 transceiver, we notice that there is the R14 pull-up resistor, that enables the keeping of the chip select line at a high level, so do not interfere during the loading stage of the BootLoader. On the 1-Wire Bus, the DS18B20 temperature sensor is connected. The A1 analogue input is engaged with the reading of the LDR1 brightness sensor while the OLED display goes over the I²C Bus.
As mentioned in the introduction, there are four Grove connectors, that enable the connection of as many sensors/external actuators. The pins of these connectors are exposed to the CON5 and CON6 connectors as well, and therefore in the case they have already been engaged, they cannot be engaged again, clearly. Differently, the I²CBus enables the connection of different devices on the same lines.
Please notice the PMOS T4, controlled by the PD4 Pin, that enables to take away the voltage from the DS18B20 and LDR1 internal and external (Grove) sensors, when it is brought to a high logic level.
The J7 and J8 connectors and the two resistive voltage dividers composed of R8-R12 and R9-R13 enable the reading of the voltage of the internal or external battery, to be acquired via the A/D A0 pin. The C12 capacitor, with its presence, filters possible spurious signals. The value of the resistive voltage dividers must be evaluated on the basis of the maximization of the resolution and of the full scale set as for the A/D converter.
Table1
The J2-J3-J4 jumpers enable to select the correct power source and therefore to set the most appropriate energy-saving management mode.
R1, R2, T1, C1, J1 and U1 compose the module that enables to wake up the TPL5110 chip and therefore to trigger a sort of interrupt for the microcontroller.
Please notice the decoupling capacitors found near every single chip, they have been placed so to ensure that possible noises are removed and to suppress possible sudden energy requests.
From the analysis of the circuit diagram, it is clear that some pins of the ATMEL chip have been engaged for some specific purposes, therefore it is not possible to use them in our projects as normal I/O pins and in fact some of them (the exclusive ones) have not even been established on external connectors. Table 1 summarizes the said pins.
The D11(MOSI), D12(MISO), D13(SCK) pins are signals to control the SPI protocol, and therefore in the case, your project considers the usage of an SPI device (a specific sensor, or a display) you will have to connect it to these three signal lines. The D10 pin is the ChipSelect pin related to the transceiver’s SPI protocol, while D8 is the ChipSelect pin of the (optional) FLASH module. The D2 pin (INT0) is the interrupt that is generated by the transceiver module when it receives a data packet in order to alert the microcontroller, while the D9 pin is used by the onboard LED.
The usage of the D2 pin (INT0) on the part of the Transceiver module prevents the possibility to use it for other purposes. In the case in which you have to use an interrupt, you will have to use the D3 pin (INT1).
Antennino LowPower management via an external timer
One of the peculiarities of Antennino is the one to be able to take advantage of the potentialities of the TPL5110 (Texas Instruments) chip, in practice that’s a digital timer with an intervention interval in the 100ms÷7,200s(2h) range (in the standby mode it absorbs around 35nA: you read that right, that’s just 35 billionths of an ampere) and that enables to control the power source line via a P-MOS, and excluding everything that is downstream of it. In this case, therefore, the energy saving strategy is completely delegated to the TPL5110 chip. The chip has an input pin (DONE) that may receive a feedback from the microcontroller in order to immediately deactivate the power if the operations that had to be processed have been completed.
Fig. 1
Moreover, there is a further input pin (DELAY/M_DRV) that gives the possibility to forcibly awake the TPL5110 in advance, before the natural due date of the set timing; this enables to receive an interrupt from an external source, to manage its requests and then to send a DONE command to the TPL5110 and to immediately return to the LowPower mode, thus deactivating everything but the TPL5110. It is possible to see a schematization of the use (derived from the Application Note of the integrated circuit) made of the TPL5110 chip in Fig. 1; while in Fig. 2 we refer to the timing of the events that are significant as for the chip’s activity.
Fig. 2
We listed the values of the resistors determining a delay in the timer’s intervention in Table 2 and in Table 3. We overlooked the table for the times below 1s since they are not relevant for the use we will make of the TPL5110.
Table 2
As you may see, the resistive value needed in order to obtain some specific time intervals must be a certain value, obtained by connecting two commercial value resistors in parallel. We considered the presence of the two resistors in parallel and even the one of a more practical trimmer in series. After that, you may insert two resistors in order to determine the minimal value wished and then to acquire other values, by acting on the trimmer adjustment. We will then analyze the hardware implementation and the implications at a software level of this solution as for our Antennino module, in detail.
From the TPL5110 datasheet, it is possible to infer that by bringing the pin that refers to the DELAY/M_DRV input pin at a high voltage level, it is possible to anticipate the timer’s awakening and therefore to obtain Antennino’s boot; but once Antennino has been awakened, how do we manage to tell it that’s not a scheduled awakening, but that it has been caused by an external event, for which we want a particular action to be carried out?
Table 3
From Fig. 3, it appears that in order to trigger the event we had to use an optoisolator (U1), so that there is no possibility to get the timer in touch with some dangerous voltages or to have it undergo some electromagnetic interferences (EMI).
The optoisolator’s anode has been connected to the voltage of the batteries by means of a resistor (R2) and therefore, in order to have the photodiode conduct, it is enough to bring the cathode of the same to ground; this will imply the passage to saturation of the phototransistor connected to a common emitter, therefore its collector will reach a voltage close to the zero, and this will have two effects. The first one will be that the T2 PMOS will be brought to conduction, thus bringing the DELAY/M_DRV pin to the battery voltage, and thus triggering the anticipated cycle of the TPL5110 timer and the consequent awakening of Antennino. The second effect will be that the T1 PMOS will be brought to conduction, that will determine the capacitor charging to the voltage of the batteries. The J1 jumper comes into action here, and it makes the C1 capacitor communicate with Antennino’s A2 analog pin. When Antennino boots, the voltage found at the ends of the C1 capacitor will be read, and since it was previously charged by the PMOS, a voltage greater than zero will be read: this will inform Antennino that it has been woken up because of an external event, rather than because of a normal scheduled timing cycle. Another precaution will be the one to discharge the capacitor via software, once the reading of its charge condition has been carried out so that at the next “normal” cycle of the timer, the capacitor will be found as discharged.
Fig. 3
The ATMEGA328P microcontroller operates at 3.3V and the same may be said for the RF module, for the Flash Memory and the different sensors we are going to add to the module. It is possible to use 2 AA batteries on board, in the case of rechargeable cells being used, they have a nominal 1.2V (1.5V for the alkaline ones) voltage and therefore at most, we will have 2.4V (3V) available. Clearly, in the case of battery power, it would be ideal not to have to use any voltage regulator: even though they have reached an efficiency level that was really inconceivable only a few years ago, they are still devices having a performance below 100% and thus by placing them between the power source and the circuit to be powered, they cause losses, though minor ones.
When we need to power a remote sensor by means of a battery that has at most a thousand mAh, it is clear that we have to carefully consider the code running on the microcontroller and the hardware solution to be adopted. In order to obtain the canonical 3.3 V in Antennino, we opted for the MAX856 chip, a switching-regulator by Maximin-IC, that shows some good performances. The MAX856 chip accepts an input voltage ranging from 0.8V to 3.3V, and supplies an output voltage of 3.3V, with a max current of 125mA. It has a phantom load of just 25µA and operates at a 500kHz frequency, thus allowing the use of small size inductors. The minimal voltage with which it is capable of starting is just 0.8V, and therefore it is capable of using the 2 AA batteries in a very performing way.
Antennino Battery duration
If we had a static system, always absorbing the same current, the calculation would be a very simple one.
Considering the battery capacity (C), expressed in mAh, and supposing (for example) an 85% correction coefficient that takes the self-discharge and the efficiency of the switching converter into account, we may evaluate the autonomy of the system. Given the medium absorption of our device (A), we may be able to determine the battery duration, expressed in hours, as:
Duration = (C*0.85)/A=(2,400 mAh*0.85)/40 mA=51h
Luckily, for most of the time, our device is in an idle state and it sometimes awakens, so to send the data packets and then return to sleep, therefore the formula we will have to apply is slightly more complicated.
By applying the following formula:
whose parameters are in Table 4, and taking into consideration that:
C=2400 mAh, Sa=40 mA, Wa=35 nA (3.5×10-5 mA), Wph=60, Wt=10ms
The calculation returns an autonomy of 3.49 years!
Table 4
Antennino Power source selection
Now that we introduced the low-power management, let’s see – in detail – what are the possible options when choosing the power source and how the different jumpers found on the PCB must be set.
The jumpers on the PCB enable to select the correct power source. The involved jumpers are J1 for the purpose of using the TPL5110’s wake-up function, and J2, J3, J4 for the purpose of selecting the power source. The possible options are the following ones:
- to power, it via (onboard) AA batteries, by using the MAX856 switching regulator and the TPL5110 LowPower management: J1 must be closed, J2 goes on 2-3, J3 goes on 1-2 and J4 on 1-2.
- to power it via (onboard) AA batteries, by using the MAX856 converter and the ATMEGA328P LowPower management: J1 must be opened, J2 goes on 2-3, J3 must be opened and J4 is closed on 2-3.
- to power it via an external voltage (3.6-12V), by using the MCP1703 linear regulator, the power has to be applied to the pin of the external connector: J1 must be opened, J2 is closed on 1-2, J2 and J4 must be removed.
- to power it directly, via a 3.3V external voltage, without having to go through the regulator and the LowPower management via ATMEGA328P: J1 must be opened, J2 must be removed and the same goes for J3 and J4.
- to power it via the (onboard) AA battery, no regulator is used, and with the LowPower management via ATMEGA328P (this is a peculiar mode that requires some modifications to the bootloader): J1 must be opened, J2 must be removed, J3 must be closed between 2 and 3 and J4 must be removed.
In order to decrease the energy consumption to its minimum and therefore to bring the service life of our valuable energy source to its maximum, the golden rule is the one to set the device to the low consumption mode as soon as the operations of processing (on the part of the microprocessor) and the sending of possible pieces of information to the gateway is completed.
In the case in which it is powered via battery, it would be beneficial to monitor its charge state, and therefore it is needed that the microcontroller reads the voltage level of the battery by means of one of the A/D conversion channels. This reading operation must be carried out with a frequency depending on how critical the operation is, however, and as previously indicated, as soon as the value has been acquired and the data has been sent, the device must absolutely enter the low consumption mode, thus disabling everything that is not needed. For example, it is possible to disable the A/D conversion section of the microcontroller, the RS233 of the same, to bringing the RF module in the reception mode, and to take away the power from the external sensors.
Similarly, when the sensor receives an interrupt, it has to manage the processing of the information and then to return to the low consumption mode, as soon as possible. For example, let’s suppose that the Antennino module is used in order to detect the opening of a door by means of a microswitch; the signal coming from the microswitch will have to be applied to one of the module’s digital inputs, when the pin state changes an interrupt will be sent to the microcontroller, that will exit the low consumption mode and will send a notification concerning the said state variation to the gateway. As soon as the information has been sent, the device must be promptly returned to the low consumption mode.
The RFM69 module in Antennino
Well, since we completed the discussion concerning the “energy management”, let’s move on now to the wireless section: the module we used in Antennino operates at a 433MH frequency, that may be freely used, provided our transmissions are relatively short ones. That’s fine as for our applications since the gateway and the remote module will communicate only in order to exchange pieces of information on the sensors’ state.
In the latest versions of the libraries of the RFM69 transceiver, it has been introduced the possibility to self-regulate the transmission power level, by means of a function named Automatic Transmission Control (ATC), that enables to further decrease the consumption on the part of the Antennino module, during the transmission stage, by automatically negotiating the minimum power needed for the data interchange. In Fig. 4 it is possible to see the RFM69 module and the layout of the contacts used for the purpose of interfacing the microcontroller. It is clear that the SPI protocol (serial MISO, MOSI, SCK, RST) is used, along with a Chip Select (NSS) pin and a (DIO0) pin for the purpose of notifying the interrupt to the microcontroller, in addition to the power source and the pin for the connection to the external antenna, obviously.
Fig. 4
Antennino Antenna
As a general rule, it would be preferable not to use RF modules lacking an antenna, not only because this compromises the service range of the module, but also because it could cause some permanent damages to the module itself.
In order to create an antenna, the rule is that it must be of a length that is equal to the wavelength (λ), or a submultiple of it.
Considering that our module operates at 433MHz, we may calculate the wavelength by means of the following formula:
λ = C/f
In which C is the propagation speed in the transmission medium, that is equal to the speed of light, 300,000 Km/s (expressed in meters), in the aether, while f is the wavelength, expressed in Hz.
Therefore, for a frequency around 433MHz it will be:
300,000,000/433,000,000=0.6928 m
Therefore that’s 69.28 cm. Since often it is not viable to use an antenna that is equal to the length of lambda, we often recur to fractions of λ.
In normal usage conditions, it is enough to weld a copper wire having an adequate length in order to create a monopole antenna being a ½ wavelength (329.44 mm) or a ¼ wavelength (164.7 mm).
It is also preferable that the wire chosen is a monopolar one (for example, an enameled wire used for the coils), moreover, the best performances are obtained if the wire is kept straight.
In the case a high gain is needed, Antennino is anyway provided with a U.FL micro connector, so to be able to connect a commercial antenna.
The OLED display Antennino
Antennino’s PCB enables the usage of a small OLED display with an I²C-Bus interface. It is to be noticed that there are many variations of these display that are available for sale, and at a first glance they all look the same, but they are not, at all; therefore the first thing we should pay attention to is the pinout of the component we wish to mount, since some types have the power contacts swapped.
The Antennino board may host displays having a pinout providing the VCC, GND, SLC, SDA contacts, arranged as shown in Fig. 5. In the case your display has an inverted arrangement, that is to say, GND, VCC, SLC, SDA, it is enough to interrupt the two thin tracks under the display connector on Antennino’s PCB and to solder the two jumpers, so to correctly power the display itself.
Once the powering problem has been solved, we have to identify the kind of chip used by the display. This may be slightly more problematic since usually, the seller does not declare at all the chip controller type on board. In broad terms, we may say that there are only two chip types: the most performing one is the SSD1306, and there is also the SH1106. As regards the Arduino library to be used in order to drive the display the choice comes down to the U8glib.h; this is because it requires limited resources, with respect to other libraries that we might be using.
In the next installments, we will see how to use the library in a profitable way.
Fig. 5
Conclusions
In this first installment, we introduced the hardware and described how the device was created. In the next one, we will explain how to load the bootloader on Antennino, so that our module may be managed from the Arduino IDE.
In a further article we will propose the traditional Hello World, that will use two modules: one for the purpose of simulating a sensor node and another one for the purpose of implementing a simple gateway. Moreover, we will see how to use the LowPower mode of the ATmega328P microcontroller.
Pingback: Antennino: the low-power Arduino with Antenna – The Bootloader | Open Electronics