Anotherpower.com Forum

Renewable Energy Questions/Discussion => Automation, Controls, Inverters, MPPT, etc => Topic started by: RFburns on July 23, 2016, 08:01:47 pm

Title: Arduino - where to start?
Post by: RFburns on July 23, 2016, 08:01:47 pm
Wasn’t sure where to post this really  :-\  . But I find the need to use an Arduino for a project (why this particular micro? well I have found some code that almost does what I need ) so anyone got some advice as to where to start ( otherwise I guess it’ll be get a module load the code and spend some time mucking with it). Should I get a starter kit ?(than what one UNO/Mega/Nano). Any help appreciated. RF
Title: Re: Arduino - where to start?
Post by: frackers on July 23, 2016, 09:00:22 pm
Depending on how many I/O pins you require for your application, I've found than Arduino nano clones from the usual Chinese retailers at $2 each (free postage) do the job nicely. I usually buy then in 10's so I have spares if I get carried away with a meter probe or stray piece of wire ;)

If I want something with a bit more CPU power, then one of the many stm32f103c8t6 clones( i.e. 32 bit ARM rather than 8 bit AVR), which are now supported by the Arduino IDE (or the ST Micro very good STM32CubeMX startup wizard). They work out even cheaper but they can be tricky to interface as they are 3.3v I/O pins.
Title: Re: Arduino - where to start?
Post by: oztules on July 23, 2016, 10:07:57 pm
So far found the nano to be able to do anything I have needed.... less then at a few  bucks a piece it is hard to beat, there are lots of IO pins to play with, so you will have serious project to use them all up I suspect  ( I did with the salt water RO machine).

I did use mega's for 30 dollars but have not needed that much io power... so then use nano exclusively now... two or three if necessary.

Get a handful of them , load the code, and change it to what you need... or post the code and someone will help.

Make sure you get the ones with the usb port... makes things very simple for folks like me to play with..

..........oztules
Title: Re: Arduino - where to start?
Post by: RFburns on July 23, 2016, 10:38:48 pm
Great Thanks I will  give the Nano's a go  :)
Title: Re: Arduino - where to start?
Post by: Pete on July 31, 2016, 12:31:55 am
Hi RF Burns, I am just getting into the beginnings of wanting to use Arduino's as well. I am not up to speed with the programming language yet but there is a simple graphical program called ArduBlock that makes the programming bit easier. May be worth a look.
good luck
Pete
Title: Re: Arduino - where to start?
Post by: RFburns on July 31, 2016, 06:05:45 am
O.k Pete I will check that out thanks. I have orderd some units to play with so will be about a month before much happens. RF
Title: Re: Arduino - where to start?
Post by: noneyabussiness on August 04, 2016, 05:50:01 pm
Hi all, also just wanted to add, on the nano clones if you are using a lcd or led output and are running out of pins, try using a shift register or I2C , very cheap (100 SN74HC595N is about 10 bucks) and plenty of librarys pre written to support them. A strong suggestion to is start with pre written libraries and have a look at how they work, you can learn so much
Title: Re: Arduino - where to start?
Post by: TaraByers on August 25, 2016, 01:21:25 pm
Hi..i am a new user here. As per my knowledge depending on how many I/O pins you require for your application, I've found than Arduino nano clones from the usual Chinese retailers do the job nicely. I usually buy then in 10's so I have spares if I get carried away with a meter probe or stray piece of wire.If you want something with a bit more CPU power, then one of the many stm32f103c8t6 clones.
Title: Re: Arduino - where to start?
Post by: Pete on September 07, 2016, 03:09:01 am
I have been working on my first Arduino project. I am making a Solar Hot Water controller with a nano and a 1.8" screen.
I know that I really don't need the screen to show the temperatures but still, it is my first try so it is still fun.
I am using LM335 sensors, and have a changeable differential in the program. At the moment the pump will turn on when the panels are 6 degrees C hotter than the Tank. Then when the difference falls to 3 degrees the pump will turn off.
I have found that I can get the screen to show the readings of Tank temperature, Panel Temperature and Pump status. BUT, there is a problem with running the controller off my USB port at the moment. The voltage is way down, maybe it is that the screen draws too much current for the Nano power supply or the USB but I am not getting accurate readings on the temperatures or digital states.
My LED, that is a stand in for the relay that will come later, is only glowing dull with less than 2 volts as a digital high output from my nano.
Is this normal, or do I need to supply the LED, and Screen from a separate supply?
Pete
Title: Re: Arduino - where to start?
Post by: noneyabussiness on September 09, 2016, 05:39:31 pm
Pete... for sure its current requirment.. the humble usb port can only really supply about 500ma, and personally i wouldn't put too much stock on it providing that continuously. . So maybe a external power supply would be a good idea, also make sure you have plenty of bypassing (10-100 uf caps) on everything. .. the amout of times i have personally had dramas on circuits to be fixed with a extra cap on the input/output
Title: Re: Arduino - where to start?
Post by: Pete on September 10, 2016, 12:47:29 am
Thanks for that noneyabusiness,  I have a couple of powered boards for experimenting on the way so will see it that solves my anamolies.
What purpose are the bypass capacitors serving?

Cheers
Pete
Title: Re: Arduino - where to start?
Post by: noneyabussiness on September 10, 2016, 10:46:15 pm
Just an example. . I was implementing a networked of sorts nrf24l01 and it would work on my bench intermittently, sometimes fine, but a lot of dropped packets... they were sitting inches apart, that should not happen  :o.. 13ma max current draw at 2Mbps , my bench power supply is modified server psu's so handle 50 odd amp... no problem. .... well after hours of WTF is going on here etc. I read in a forum about bypassing this chip with a .1uf cap as close to the chip as possible. .. so i have a drawer of 6.3v caps there so i soldered one on and the bloomin thing never dropped another packet ::) :o..  in fact page 62 of the datasheet recommends a 4.7uf cap... even though it had it own power supply etc. The sudden current draw was enough to reak havoc on the chip. The cap would supply the power during that transition. .. so long story short caps provide power when the power supply is catching up... i hope this makes sense
Title: Re: Arduino - where to start?
Post by: DJ on October 18, 2016, 10:38:43 pm

Seems there is so much in this area that can be done with these things I'm going to have to learn them.

Can anyone recommend some good starter kits and or sites/ programs to kick off with?
Also interested in who has the things For $2 ea?  Local electronics retailers charge substantial amounts for the starter kits as well as the boards. Got to love fleabay!

I have been reading the direct panel control thread but it's way over my comprehension atm but it's something that I would like to do as well as an automated control for my oil oil burners. Even something that just shut the fuel and air off after a water tank reached a pre determined temperature would be a big help to start with and I could look at adding  Complic.... automation from there.
Title: Re: Arduino - where to start?
Post by: MadScientist267 on October 19, 2016, 06:13:12 am
I'm on "serious project #3" involving them, have had a taste now of both Uno and Mega... best place to start... hmm... I'll go with "neck deep" lol

Uno is a bit of a squeeze on resources but even at my n00b h4x0r level LOL... still has a surprising bit of bite as you get the hang of things and aren't afraid to think outside the box or at least beat one senseless with a soldering iron haha

Regardless of flavor, there's compiler puke to deal with... If you're unfamiliar with the language like I was (pronounced "still am" lol), find your way to the top of everything it throws at you and correct that issue, and half the time the rest is just the compiler trying to make sense of it's own meltdown haha I wish someone would have given me that little tip from the gitgo... and may have, probably did even... but there's what I've got to add on it. LOL

EDIT - On the displays... If you like challenges that eventually all seem to have solutions but don't mind flying nearly solo at times, the knock off shields work just fine once you find the right magic wand and wave it... At a fraction of the cost of the "real" displays... also hit and miss on description vs what's actually received, and gonna encounter a cracked screen here and there along with bent pins, but again if you're no stranger to a soldering iron and needlenose (especially with Uno), typically the actual displays are ok, good color saturation/vibrance etc and plenty bright... toss a few bucks at half a dozen for the price of just 1 of the "real fruit" ones and so far I've averaged out ahead, just some head on desk action to work out the magic trick that brings them to life.

And what's this about shifting registers? Lol That's what the iron and needlenose are for... bust the pins off that you need to move, and reroute them :o

That's one benefit of going with the cheap route... hack up the magic on one, apply it to the masses. Personally, I would have still run across the need to reroute pins, but it's a lot less stressful to approach a $5 display than a $35 (or more, ack lol) with your weapon of choice... None of this pin register shift thingy stuff hehehe They don't come with clutches anyway ;D

To wit... LOL:

[attachimg=1]

When you're finished rearranging an uno, it's like napalm in the morning... smells like... victory haha Draw you up a board or whatever to make the changes you want for "production runs" or whatever suits your fancy, and roll  8)

I of course jest a bit, and I'm far from guru on them but so far seems that however you go about them, they're fun to play with, even when WTF factor goes so far off scale that you forgot you were subconsciously monitoring it ;)

Steve
Title: Re: Arduino - where to start?
Post by: eidolon on February 10, 2017, 08:51:59 am
One thing to remember when making temperature reading with voltage based sensors. The usual reference is the 5V supply.  That supply voltage can change when you plug in the USB port vs external board supply.  The higher voltage will prevail.  I use a USB cable with the power wire cut and replaced with a diode.  that prevents supply differences of less than the voltage drop influencing the calibration.  You can use the internal reference, but that is only 1.1V and doesn't match up with many sensors.  It also puts you down in the noise.
Title: Re: Arduino - where to start?
Post by: MadScientist267 on February 10, 2017, 11:24:42 pm
On temp measurement... Dallas 1 wire bus (eg DS18B20 etc).

For analog anything, AREF is your friend.

I have a similar hack for the USB now as well, albeit with the 5V lead completely disconnected. I left the USB shield and negative supply pin in place, which still can cause ground loop effects on things, but I figure provides a little insurance against any common mode voltage that might somehow be present from taking out the port in the laptop. Course if it's strong enough.....
Title: Re: Arduino - where to start?
Post by: welshman on February 11, 2017, 06:55:36 am
something i found very usefull when dealing with erratic values from adc's https://github.com/dxinteractive/ResponsiveAnalogRead . it can take a value from analogread or be given a value directly and then remove the noisy readings to give a good stable reading. much better than smoothing.
Title: Re: Arduino - where to start?
Post by: MadScientist267 on February 11, 2017, 05:06:31 pm
Appears to be just a complicated oversampling routine...?
Title: Re: Arduino - where to start?
Post by: frackers on February 11, 2017, 05:17:58 pm
Appears to be just a complicated oversampling routine...?

Its a type of IIR (Infinite Impulse Response - actually an exponential moving average) filter with a second order (i.e. rate of change) adjustment on the Alpha value applied to the input with a 'deadband' to further stabilise constant values.

Reasonably useful provided you're mindful of the implicit delay in getting an output from it.
Title: Re: Arduino - where to start?
Post by: MadScientist267 on February 13, 2017, 01:42:04 am
Hmm ok, might have to give that a good look see... cool.
Title: Re: Arduino - where to start?
Post by: eidolon on February 13, 2017, 08:04:55 pm
Just in playing around with Miles Burton's DS18B20 library with multiple sensors, I find I get occasional bad reads. Figure they will figure it out some day. These are always easy to filter out because they are read as 0.  I only do heating so that is easy.  You still can't beat good old analog for doing runs of 100 feet an more and filtering out noise.
Title: Re: Arduino - where to start?
Post by: Pete on February 14, 2017, 02:34:48 pm
Well it was a steep learning curve, but I have my solar hot water controller up and running now. It has worked great for the last couple of months.
I ended up using averaging to get the readings from the sensors accurate. I think the problem was really down to a bad build the first time as my pump would turn on and off regularly after a short run. I rebuilt the unit and the problem ceased. So now I have a working unit that does what I want.
I used an arduino nano, a 1.8" tft screen to display temperatures and pump state and a relay to run the pump.
I did kill a couple of Arduino chips trying to run the unit of 12 volts, though. In the end i used a breakout board with its own regulators, I also used a 7809 three terminal regulator to make sure that the small power supply on the breakout board was not overloaded.
I have attached the code for anyone who wants to build one.
I also found that the relay board I used had opto isolation and worked with a "low input" so I used a BC558 transistor as an inverter to invert the output from the Nano chip to drive the relay.
Pete
Title: Re: Arduino - where to start?
Post by: MadScientist267 on February 15, 2017, 02:30:13 pm
I did kill a couple of Arduino chips trying to run the unit of 12 volts, though. In the end i used a breakout board with its own regulators

Yeah, dunno how, but magic smoke events didn't come to mind immediately for me with this thread... they're certainly prone to it.

I'd recommend never using the onboard regulator unless you're only powering the chip itself and maybe some very minimal requirements needed for sensors. This seems to be particularly true when it comes to "shield" displays and the backlights. Would appear that the LEDs just pull things way too close to the regulator limits depending on what you've got. Not worth the risk. I use "full spec" 7805 or some other form of external supply now for anything like that, haven't had any trouble since.


Quote from: eidolon
Just in playing around with Miles Burton's DS18B20 library with multiple sensors, I find I get occasional bad reads. Figure they will figure it out some day.

The good news is, there are relatively simple workarounds for this provided the bus itself isn't experiencing severe interference. There are ways to read the bus blazing fast, and between CRC and a couple other tricks, can eliminate the bad reads.

I'll never use NTC/ADC for temp ever again whenever I can avoid it.

That said, I agree it's definitely got its uses (fan or PWM control, etc) but only when the outcome isn't in need of a calibrated number. Too much work hehe

Steve
Title: Re: Arduino - where to start?
Post by: solarnewbee on February 15, 2017, 07:48:38 pm
Hey Mad and Pete!

I just love those DS18B20 sensors especially when using them in conjunction with a site called Cayenne mydevices.com they have a pc, mac, android and ios dashboards to monitor and control your raspberry pi or arduino devices from anywhere in the world. Those sensors are automatically detected on GPIO4 and then you only have to fill in the labels for each.  They have made it very easy to set up and the Cayenne community pages offer lots of help, great people over there. For many of the sensors they give you an IDE sketch and after say the first button you program then you can just add on more buttons to the dashboard by adding widgets. They just released the MQTT bring your own thing for Arduino and other devices as well as sensors that are not included as standard fare at Cayenne. I have a Rpi3 up and running overseas, it works but readings are zilch since I wasn't able to get my panels on the roof. Next year though got to do it because there's 32 LFP's sitting in the electrical room ie. extra bedroom ha un-used. I'm working on a PLduino which is Mega 2560 based and of course it's kicking my behind.

Check it out it's fun

SN
Title: Re: Arduino - where to start?
Post by: frackers on February 15, 2017, 08:28:07 pm
I love 1-wire stuff. My irrigation controller (running on a wireless router - i.e. v. small Linux box) uses 16 GPIO chips (DS2413), 3 temperature sensors (DS18B20) and 2 battery monitors (to measure current/voltage - DS2438).

My wind turbine controller (Arduino Mega based) uses the same chips for power measurement, inverter control and temperature sensing.

There are libraries to implement your own functionality on an Arduino but operate as a 1-wire client so it just hangs off the bus like everything else. Very handy if you want to measure RPM or something similarly exotic ;)


Title: Re: Arduino - where to start?
Post by: Pete on February 15, 2017, 11:06:58 pm
MadScientist, yes I agree, it I have found that it is best to power external things like the relays from the regulator power supply. I think the onboard regulators on the shields died from trying to drop the 12 to 13.8 volt from the batteries to 5 volt. When they have only a 9 or 8 volt supply they seem to be able to handle it better.
As far as smoke goes, yes the Nano chips did seem rather easy to turn into smoke. I learnt as a kid from watching Lost In Space that once your gear goes up in smoke you either vacuum it our or hit it with a fire extinguisher. Then magically everything fires up again and there is no need to repair it.
Somehow in my world this does not work. So a couple of Nano's and a couple of Shields ended up in the bin.
Just as well we live in a throw away world eh.
Cheerio
Pete
Title: Re: Arduino - where to start?
Post by: frackers on February 16, 2017, 12:17:20 am
Most of the Nanos I have smoked have been the diode in series with the 5v - change the diode and away you go again ;)

Since you can get them from China for less than the local cost of the mega328p chip that on them, then I suppose you get what you pay for!