Archives | Botshop
Diet Duino, Arduino low energy consumption for battery powered projects

Diet Duino, Arduino low energy consumption for battery powered projects

skeleton duino

To run an Arduino on battery power requires 2 things:

  1. First, you need to sort out the hardware because even if you put your Arduino to sleep (we will look at that soon) it is only the Atmel chip that will sleep, the rest of the components like power led, regulators and so on will still be very much alive
  2. Next, you can programmatically put the Arduino into different kinds of sleep modes that will drop the power consumption to μA’s

First sort the hardware power consumption.

When you want to use a battery source like a coin cell, the Uno is not an option it consumes on average 48mA without sensors and so on connected to it. Even a 9V will not last a day.

Our skeleton Duino performs much better at about 30mA and is already much better at about 40% energy saving compared to the Uno but there is more we can do…..

We created the Diet Duino to bring this down even lower to 16mA, that is about a 1/3 of the consumption of an Arduino Uno.

skeleton duino working

You can get the Diet Duino here: Diet Duino

We accomplish this by removing the power led (still a led on pin 13 if you want to see a power led – but make it blink slowly on the off and very quick on the on cycle so it uses as little power as possible) and most importantly, we use a rather expensive imported voltage regulator that is VERY energy efficient.

Now let the Atmega chip go to sleep wherever possible.

When be put the Diet Duino into sleep mode it is too low to measure, We can measure up to around 20 μA but looking at the only thing that consumes power – the voltage regulator we look at about 4uA.

Some perspective on sleep mode.

When you put an Arduino in sleep mode it does not take long for it to go to sleep or to wake up, it happens in milliseconds. This means that you can already replace all your normal Delay calls in your Arduino with “real sleep” commands with a very cool Arduino library that you can find here: Low-Power library from Rocketscream

It is very easy to use and you will find lots of information from the link above. The statement LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); puts the MCU in SLEEP_MODE_PWR_DOWN for 16 ms to 8 s, depending on the first argument. It disables the ADC and the BOD. Power-down sleep means that all chip functions are disabled till the next interrupt. Further, the external oscillator is stopped.  Only the level interrupts on INT1 and INT2, pin change interrupts, TWI/I2C address match, or the WDT, if enabled, can wake the MCU up. So with the single statement, you will minimize energy consumption to 3 uA. If you read the library documentation you will find lots of other settings to use.

To give you an example: If you measure temperature once ever 1 minute, the measurement takes maybe 1 second, that means your Arduino can sleep for 56 seconds.

In conclusion, with the Diet Duino and some basic programming, you can get over a year on one coin cell.

The Diet Duino is available here: Diet Duino low energy

 

 

 

How to use a PH probe and sensor

How to use a PH probe and sensor

If you worked with PH metering before you will know that PH values range from 0-14. Where PH 0 Will be very acidic, PH 7 will be neutral and PH 14 very alkaline. Water is near a PH 7 and this is usually around here that we will need to monitor PH of many things. A swimming pool, for example, should be slightly alkaline at 7.2, hydroponics systems around 6 (for optimum plant nutrition takeup) and aquaponics around 6.8.

I wrote this PH probe and sensor “how to” because it is not as straightforward as one would think (but quite easy when you understand the ins and outs) mostly because there is not a lot of information on this on the Internet, surely not detailed information.

We will first look at the ph probe module board and then the PH probe because both the PH probe and sensor have to be set correctly:

  • offset setting
  • limit setting
  • sketch to test the board analogue range
  • sketch for PH reading and calibration.
  • calibration of PH probe
  • PH probe usage

The ph probe module in this tutorial is available on our site here: PH probe module BNC connector

ph probe sensor module

PH Probe Sensor Pinout
TO – Temperature output
DO – 3.3V Output (from ph limit pot)
PO – PH analog output ==> Arduino A0
Gnd – Gnd for PH probe (can come from Arduino GND pin) ==> Arduino GND
Gnd  – Gnd for board (can also come from Arduino GND pin) ==> Arduino GND
VCC – 5V DC (can come from Arduino 5V pin) ==> Arduino 5V pin
POT 1 – Analog reading offset (Nearest to BNC connector)
POT 2 – PH limit setting

PH probe module Offset and how to use it.

This board have the ability to supply a voltage output to the analogue board that will represent a PH value just like any other sensor that will connect to an analog pin. Ideally, we want a PH 0 represent 0v and a PH of 14 to represent 5V.

BUT there is a catch……, this board by default have PH 7 set to 0V (or near it, it differs from one PH probe to another, that is why we have to calibrate the probe as you will see later on), This means that the voltage will go into the minuses when reading acidic PH values and that cannot be read by the analog Arduino port. The offset pot is used to change this so that a PH 7 will read the expected 2.5V to the Arduino analog pin, the analog pin can read voltages between 0V and 5V hence the 2.5V that is halfway between 0V and 5V as a PH 7 is halfway between PH 0 and PH 14,

You will need to turn the offset potentiometer to get the right offset, The offset pot is the blue pot nearest to the BNC connector.

To set the offset is easy. First, you need to disconnect the probe from the circuit and short-circuit the inside of the BNC connector with the outside to simulate a neutral PH (PH7). I took a piece of wire, strip both sides, wrap the one side around the outside of the BNC connector and push the other side into the BNC hole. This short-circuit represents about a neutral PH reading of 7.

ph probe and sensor

ph sensor arduino connection

There are two ways you can do the adjustment.

If you have a multimeter handy you can measure the value of the PO pin and adjust the offset potentiometer until  PO measures 2.5V.

I prefer to just use the sketch below. Just download it to your Arduino as you will with any other sketch, open serial monitor and view the reading there. All this sketch does is to print the volts it receives from the analog pin and print it to the serial monitor. It of course first changes the digital value to volts to make it easier. Now simply turn the offset pot until it is exactly 2.5V. You can learn more about reading voltages and digital representation of volts here: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage

Offset sketch

void setup() {
 // initialize serial communication at 9600 bits per second:
 Serial.begin(9600);
}

// the loop routine runs over and over showing the voltage on A0
void loop() {
 // read the input on analog pin 0:
 int sensorValue = analogRead(A0);
 // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
 float voltage = sensorValue * (5.0 / 1023.0);
 // print out the value you read:
 Serial.println(voltage);
 delay(300);
}

PH limit setting

There is another pot that acts like a limit switch. Basically, the D0 pin on the sensor board will supply 3.3V to the pin until a preset PH value (that you set with the limit pot) is reached, at this point a red LED will light up and the pin will go down to about 0V.  I did not play with this much but suppose it can be handy if you want to activate a buzzer or something if a certain PH is reached, it will work great on an Arduino digital port – that will go high from about 2V up. This will work if the PH value goes higher than the set value. If you want it to trigger something when the PH goes lower, you need to monitor the digital pin to trigger when the digital pin goes low. You will unfortunately not be able to set this limit between two values, either if the pH goes up to high or if the PH drop to low. Programmatically you of cause can do an upper and lower limit.

Connecting and calibrating the PH probe.

The hard part is over and this offset does not have to be set again, even if you change PH probes. We have PH probes available here: PH probe Electrode BNC connector

Here is a couple of things to know about PH probes:

  1. The probes readings change over time and need to be calibrated every now and again to make sure the value is still the same and be adjusted if it did change.
  2. You need at least one PH buffer solution to calibration your PH probe. They are available at many different PH values, A buffer solution of 6.86 and 4.01 is most common as it covers the range of most applications. If you are only going to use one buffer solution make sure its value is near the value range you will use in your normal tests – if it is pool water a buffer solution of 6.86 is usually near enough.
  3. Buffers come in pre-made solutions or as a powder. I prefer the powder because it is cheaper and does not have an expiration date. The powder is easy to make up as well, I suppose it depends on the power you will use, the one I use you add the powder to 250ml distilled water and stir until all powder is dissolved. It will last about a month once you added water to it.
    buffer solution powder
  4. A PH probe takes some time to get to the right value, allow it to be in the liquid you want to measure for at least two minutes or longer, it does not mean it will be stable at one ph value, it will jump around a bit between 3 or 4 values but on the last digit, for example,  between 6.84 – 6.88
  5. PH values differ in different temperatures, although that might sound cumbersome, in the temperature range between 10 – 30 degrees Celcius the PH does not differ and from 30 degrees Celcius it goes up with about a pH of 0.01 to 50 degrees Celcius that is about 0.06. In most uses, it will be below 30 degrees Celcius and temperature do not have to be calculated in.

Hook up your PH probe after you removed the wire you used to short-circuit the BNC connector and download the sketch below.

PH measurement sketch

float calibration = 0.00; //change this value to calibrate
const int analogInPin = A0; 
int sensorValue = 0; 
unsigned long int avgValue; 
float b;
int buf[10],temp;
void setup() {
 Serial.begin(9600);
}
 
void loop() {
 for(int i=0;i<10;i++) 
 { 
 buf[i]=analogRead(analogInPin);
 delay(30);
 }
 for(int i=0;i<9;i++)
 {
 for(int j=i+1;j<10;j++)
 {
 if(buf[i]>buf[j])
 {
 temp=buf[i];
 buf[i]=buf[j];
 buf[j]=temp;
 }
 }
 }
 avgValue=0;
 for(int i=2;i<8;i++)
 avgValue+=buf[i];
 float pHVol=(float)avgValue*5.0/1024/6;
 float phValue = -5.70 * pHVol + calibration;
 Serial.print("sensor = ");
 Serial.println(phValue);
 
 delay(500);
}

A note on buffer solutions: do not CROSS CONTAMINATE! What I mean by this is to not take the probe from one buffer solution to another or from a liquid sample you tested to a buffer solution without rinsing it thoroughly with distilled water first. You will change your buffer solutions ph and your calibration will be off.

When you place the probe in the first solution you might be surprised at how far off it can be, it’s normal though. Remember to leave the probe in the solution for at least two minutes to stabilise. In the script’s top line you will see a variable called “calibration”.  Change this value to the difference between what you see in serial monitor and the buffer solutions value, for example, if you read 5.81 and the buffer solution is 6.86 you should change the variable’s value to 2.05.

Upload the changed sketch and see how the value looks now.

Some ideas for you.

You can add a potentiometer to your project and program that to change the calibration for you. You always run a risk that the pot might be adjusted my mistake so a button with a 5-second delay can be programmed to put the unit in calibration mode.
This becomes great if you add an LCD screen to it and if you add the calibration value in EEPROM so it holds it even if the PH project is powered off.

How about adding a buzzer to the 3.3V limit output to notify you when the PH is out of range. Usually an upper or lower will be enough, in most applications, you will either be worried about high or low PH values but not both. If this is a problem and you need the PH to be in a certain range you can easily do that programmatically and have the buzzer on a digital pin. If it is crucial you can even add a GSM module to this so you can get an SMS or how about a dosing pump to automatically get the PH back in range.

I just might, but do not hold your breath (so much to do but so little time) :-), do something like that in the future with our cheap Skeleton Duino.

PH probe and sensor conclusion

If you go through these steps once it becomes as easy as pie. All the parts, even those I mention in the ideas section is available on our site.

 

Types of electronics power modules tutorial

Types of electronics power modules tutorial

power modules tutorial

The different types of electronics power modules tutorial and how to choose the right one for you.

If you click on our power supplies and modules category you will see many different power supplies and modules, there are adjustable ones, buck, boost, step-up, step-down, constant current, low power, high power and the list goes on and on. Hence this power modules tutorial.

The one thing all these different units have in common is that they all manage/change power in one way or another. Usually, they change a high voltage to a lower voltage, most commonly used power supplies also change AC current (from your house plug for example) to DC as required by most electronics. The popular 12V power supplies used on Arduino’s are a good example that changes AC to DC and lowers the 220V Volts to 12V

A power supply is a complete unit with wires inside a case where a power module is just the electronic circuit board.

Raspberry Pi Power Supply LM2596 Adjustable Step Down Power Supply module DC

In the rest of this power modules tutorial, I will refer to power modules but it is the same for power supplies.

The amps a power module can handle are probably the first thing you will look at when getting yourself one.

When developing projects we need more than a mere 12V power supply, we need to supply different power to different parts of a circuit and change it in ways to charge batteries and all kinds of other thigs, hence the big range of power modules.

When working with these modules you will often can a module that is bigger than the required input e.g. 12V for an Arduino Uno although all components require 5V and then from this supply make the voltages less as you go along.

Power usage

Once you decided on the voltage you will require you will need to think about the amps you will need. You need to understand that a voltage is supplied by a power supply and the wrong voltage will destroy your components but the amps it uses are drawn from the supply as needed by the components. Different components need more power than others.  One component might need 12V and 100mA and another 12V but 300mA. Together they will require 400mA.  The formula for power is V x A, thus you will need, in this example 12V x 0.4A thus a minimum of 4.8 Watt of power. Becuase amps are not ” pushed” into the circuit like voltage but “pulled” in as required by the components you can and should use a supply that can provide more than the required amps like a 1A supply. You want the supply to not work at its highest rating as to not put an unnecessary strain on them. An over worked unit will be very hot to the touch, a unit with amps to spare will be slightly warm to the touch.

Step-up, step down, buck and boost.

The word “buck” had me a bit confused when starting with these modules until I figured out it is just another word for step-down. A step-down unit just means you are going to make the volts less. This is done with a voltage regulator IC.

Boost is another word for step-up, this means you are going to make the supplied voltage more. This is done with devices called inductors.

To further explain these modules I will discuss a couple that is often used, why you will use them and shortly how to use them. As we explore some of these modules you will also learn about adjustable and constant current modules.

Adjustable 3A Ultra small power module

The most basic buck module, its small, can handle quite a big amount of current and its voltage can be adjusted.Adjustable 3A Ultra small power module

Way to the top right-hand side in the picture you can see the holes where you can connect your power source. The left side is where the adjusted power will be available to connect to your circuit. You should see the little adjustment pot that you will adjust to the correct required voltage, it’s the component near the bottom right next to the “+” sign.

This module is small but can deliver up to 3A and can adjust power sources between  4.5V to 28V down to
0.8V to 20V.

It is important to note that this unit itself uses a bit of voltage (as does most) to do the adjustment, normally around 0.8-2V, the higher the voltage is to adjust the more volts it uses itself.  You will thus need a voltage input that is 1-2V higher than what you want the output to be. If you use a 5V input you should easily get the unit to adjust between 0,8V and 4.2V, a 12V input 0.8V – 11V and so on.

to adjust these modules you need to hook it up to power and then use a multimeter on the output side to adjust the screw to the correct voltage.

You can look at the full specs here.

Adjustable Power step down module with Voltmeter

Next up is a similar module then discussed above, also a buck module,  but this one comes with a voltmeter for easy adjusting the power output without the need of a multimeter.

LM2596 Adjustable Power Converter

In fact, if you use a 12V 2A power supply with this product you have quite a neat desktop power supply. It has 2 buttons so you can check both the input and output voltages on the screen and small LEDs indicating if you are looking at input or output volts. These types of modules are best used as power sources while doing development, not final products (like the one discussed previously) except if your project will need a permanent voltage meter. I use them all the time while developing and testing products and the screw terminals are very useful to attach different products without having to solder them.

If you look at the components on this board you can see there is quite a difference compared to the first ultra small board we looked at. The main thing is that the ultra small board is as basic as they come to make the board as small as possible to incorporate them into final products. This board we look at right now is more expensive and another reason why I use them just as desktop power units to save on costs on final products.

However, they also use more powerful voltage regulators that can handle up to 40V input and 37V output for bigger voltage projects. It also has bigger stabilising capacitors that are very useful to have while developing higher voltage projects, stabilizing caps help to keep the output voltage very smooth even if the input voltage is not.

You can get all the specs for this module here.

AC-DC 220V to 12V power module

You do not need a bulky 220V to 12V power supply, especially if you are going to have a low power design.

This module takes 220V AC on the one side and supplies 12V DC on the other side. A WARNING though, you work with 220V power, it can kill you! But these modules are great when you insert them in your home build PC boards to make things look neat. I do not recommend them to new comers but introduce them here as part of the power modules tutorial as education. From this output, you can then add. for example. an ultra small step-down module to get the volts exactly where you want it to be just as you would with a normal 12V power supply.

More about these units here.

This concludes our look at basic power modules Next week we will look at more advanced modules in part 2 of this tutorial.

 

Skeleton Duino Review

Skeleton Duino Review

skeleton duino working

We designed this little board here at Bot shop as our solution to saving costs on using Arduino in our projects. Using an Arduino Uno on a finished project is firstly a bit expensive, throwing money in the water on components etc. not used in a final product. Secondly, the Uno board is unnecessary big for a final project that in itself mean bigger more expensive cases, thirdly it consumes unnecessary power (4x more than the Skeleton Duino) especially if you think of using batteries.

You can get one here.

You might be aware of the fact that in its basic form you just need the Atmega microcontroller, the crystal and 2 caps. A good idea is a 5V voltage regulator as well so you can use power sources bigger than 5V. The male rails, USB converter chip (quite expensive), 3.3V regulator, power jacks etc just add to cost and size of the board. All these are great while you develop but will not be used in a final product.  Jumper cables that fall out become a nuisance etc.

We use the Arduino Uno to develop our projects because it is easy to upload the code, push in jumper wires and get things to work. Once completed, we look at other boards for the final project. We used the Arduino mini but that is still a bit pricey and we do not like the SMD micro controller and having to go through the troubles of uploading sketches with an ISP uploader.

Eventually, we used strip board to have the Atmega, crystal and capacitors on a small board for projects but that looks nasty. Worth than that is building it on stripboard, the cutting away of tracks and soldering connection wires is a pain.

Here is an example of a pic from the Internet of such a board.
Uno stripboard

So we came up with the Skeleton Duino board. There is zero fluff, no USB to TTL to program the chip. no headers and a socket to plug in Atmega IC’s instead of the SMD chips.

Programming the Atmega micro controller

The whole idea is to program the chip on your Arduino Uno, take it out of the ic socket and then put it into the ic socket of the skeleton Duino. I hope it is needless to mention that you need the Uno with the micro controller in a socket not those with the Atmega SMD chip.  It does have a power LED, status LED and a 5V voltage regulator on board but that’s it.

Power consumption.

Unexpectedly actually, this board has quite a low power consumption because there are no additional voltage regulators. resistors, IC’s and so on. An Arduino

An Arduino Uno uses without anything connected to it 45 mA. The Skeleton Duino uses 9mA. This is important if you use batteries as a power source, they will last x 5.6 times longer.

Features:

  • The power terminals uses 2.54 pitch if you want to use screw terminals
  • 5V regulator
  • Power LED
  • Status LED
  • Dimensions: 45mm x 25mm
  • ……uh, ok that it.

We sell these boards on our site here.