Arduino – Plumbing for the Arduino Plumbing for the Arduino

// try to parallel processing on arduino like plumbing
// plumbing is more elegant,
// but its possible to do basic stuff without plumping on arduino using Alarms/Timer libs

breadboard setup

in this basic example,
three LEDs are blinking..
with different on/off times,
and one button,
pushed all LEDs will be switch on

#include <Time.h>
#include <TimeAlarms.h>

// try to parallel processing on arduino like plumbing
// plumbing is more elegant,
// but its possible to do basic stuff without plumping on arduino using Alarms/Timer libs

//AlarmId Alarm_A = Alarm.timerRepeat(start_every_seconds, func_name );
//AlarmId Alarm_A = Alarm.timerOnce(start_in_seconds, func_name );

const int PinA = 8;
const int PinB = 7;
const int PinC = 13;
const int ButtonPin = 6;

int mem_A0 = 0;// memory var A0
int mem_B0 = 0;// memory var B0
int mem_C0 = 0;// memory var C0

AlarmId Alarm_A_on = Alarm.timerOnce(2, A_high ); // would be nice to have: callbacks with args, but without, i try to do something with global vars
AlarmId Alarm_B_on = Alarm.timerOnce(3, B_high );
AlarmId Alarm_C_on = Alarm.timerOnce(4, C_high );

void setup() {

// initialize the digital pin as an output.
pinMode(PinA, OUTPUT);
pinMode(PinB, OUTPUT);
pinMode(PinC, OUTPUT);

pinMode(ButtonPin, INPUT); // button
digitalWrite(ButtonPin, HIGH); // use internal pull-up resistor, and button with only one cable without resistor

void loop() {
Alarm.delay(1); // time frame segmentation

int BUTTON_STATE = digitalRead(ButtonPin);// check every ms, for best response
digitalWrite(PinA, HIGH);
digitalWrite(PinB, HIGH);
digitalWrite(PinC, HIGH);

void A_high(){
digitalWrite(PinA, HIGH); // set the LED on
AlarmId Alarm_A_off = Alarm.timerOnce(2, A_low );
Serial.print("mem_A0: ");Serial.println( mem_A0 );
mem_A0 = mem_A0+1;
void A_low(){
digitalWrite(PinA, LOW); // set the LED on
AlarmId Alarm_A_on = Alarm.timerOnce(2, A_high );

void B_high(){
digitalWrite(PinB, HIGH); // set the LED on
AlarmId Alarm_B_off = Alarm.timerOnce(3, B_low );
Serial.print("mem_B0: ");Serial.println( mem_B0 );
mem_B0 = mem_B0+1;
void B_low(){
digitalWrite(PinB, LOW); // set the LED on
AlarmId Alarm_B_on = Alarm.timerOnce(3, B_high );

void C_high(){
digitalWrite(PinC, HIGH); // set the LED on
AlarmId Alarm_C_off = Alarm.timerOnce(4, C_low );
Serial.print("mem_C0: ");Serial.println( mem_C0 );
mem_C0 = mem_C0+1;
void C_low(){
digitalWrite(PinC, LOW); // set the LED on
AlarmId Alarm_C_on = Alarm.timerOnce(3, C_high );

Arduino neighbourhood

Arduino neighbourhood:

pythonic board

python on nokia handy to steer arduino

python on a chip, only a bit of python power

mini pc:
iMX233-OLinuXino is Industrial grade Single Board Linux computer in very compact form.

PYTHON ARM-Board für Arduino-Shields you want to buy one? sold out!

wow, a board like Arduino?
using these many available shields from arduino?
and programming not in C/C++
its complete PYTHON !!!

150,- Dollars..  that price could be ok,
hmm for that money i can use a junkyard laptop 100,-euro (lenovo with celeron)
and work with arduino… complete Logic would be programmed at laptop in python..
having more calculation power … managing image recognition, shooting webcam images etc..

i will have an eye on that piece of pythonic hardware

Arduino Read Analog with MCP3208 and LM3940

i want to track a 12 Volt battery, charging and discharging cycles (bedini project)

using voltage divider: 3 pieces of 1K resistors 1%,
min readings at 12.00V, max reading for 15V…
15V divide by 3.. each resistor gets max 5V
these 5V are the analog input for Arduino..

but Arduino Analog readings have too much fluctuations..
and are 10 bit (1024steps) only.. but 10bit should enough?
5V / 1023 = 0,00488V = 5mV  for each step

this stabilizes board power!!! and so the Vref for the external extra ADC MCP3208

so i looked around on arduino pages..
coming around with the SPI ADC the MCP3208 12bit(4096steps)

i connected all pins to my ARDUINO MEGA 5V board..

the MEGA Vcc is fluctuating a bit too..
while connected to external power supply,
i checked this via

i must give the MCP3208 a Vref,
so i give the MEGA 5V as Vref for the MCP3208…
i have to await fluctuating measures, i guess..
and it was so…
for my purpose still too much fluctuating

so next step.. i use a voltage supply chip a  LM3940(low dropout), giving 3.3V from a 5V source,,
these 3.3V will be the Vref for the ADC MCP3208
you have to use capacitors with the LM3940! otherwise you will not get the 3.3V output.
in datasheet 0.47mikroF and 33mikroF,  i used 4.7mikroF
with that  i get best possible stable values… till now
but after 10 good values, there comes always one value out of order/magnitude…
why? i dont know.. i will test an extra 5V powersupply for the check that
>> the error was in my SPI handling.. solved that, it works great


by the way
i would like to buy a Arduino shield, an ADC shield..
doing all the stuff, stabilizing Vref,
giving real world measures.. less offsets..
BUT there is nothong available in online-shops…
so i hope the people from
will build the ADC shield


PS: alternativ power supply/converter
could used to get a stable Vref? LM317 could be interchanged with more expensive, better chip..

Python for programming Arduino

you can plug arduino via usb to a computer/laptop to use the computer/laptop for the main programm logic, using arduino only as sensor&actuator…

but powering an laptop all time..

hmm.. is there anything out there, using Python directly on the arduino?

you could use a cellphone/handy with symbian S60 and nokias DeveloperKit

arduino + Symbian S60

or something more like this, python on a chip
arduino + py-on-a-chip

so i am waiting for a extra ArduinoPythonShield, in the plug and play way…
that would be great.. solving many starting problems with C/C++
having more fun, faster results..

Arduino Voltage Sensing

at first i tried a simple voltage devider, (Oreilly Arduino Cookbook page177)
3x1k + 1x1k, measureing above the 1k .. for measuring max 20Volts,

i connected my Mega2560 via usb… and the values where a little „fluctuating“..
i started calculating middle-values, 10%-influence of new value on old value,.. and so on..
today i gave a try on adding a external powersupply to the Mega2560.. and hey..
the analog reads went fine.. quite stable!
no need for me for „attopilot voltage current sensor“ anymore (maybe later ;o) )

without external power supply:
528 2.59 10.35
528 2.59 10.35
531 2.60 10.41
529 2.59 10.37
530 2.60 10.39
528 2.59 10.35
529 2.59 10.37
529 2.59 10.37
530 2.60 10.39
528 2.59 10.35

with external power supply:
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00
510 2.50 10.00

another fact, when fluctuating measurments occur, is
when i try to measure above a potentiometer 1kOhm(4Watt) with a 12V LED lamp in serie.
direct measures at the powersource, battery did not fluctuate.




model: 50V / 90A look for the datasheet there

Voltage Measurement Test

Pin Setup:
V – Analog 0

i want to measure Voltages between 11 and 15 Volts…
so i will test Analog Reads and proof at same time with an DigitalMeter.
adding the breakout parallel shows a voltage drop..?!

in datasheet is stated, that the voltage measurment has a 14,7kOhm resistor, my multimeter shows 15,75kOhm, maybe my multimeter isnt good enough.

the breakout is for 3.3V, with 5V you loose some precision.
so my arduino is a 5 V board, 10-bit resolution (0-1023)


measured analog values and an factor x

76 -> 5.74
77 -> 5.82
78 -> 5.89

nTemp = analogRead(5) * 5000L / 1024L  / 10; 10-bit arduino explained

Python serial read for Arduino

# -*- encoding: utf-8 -*-

import sys
import time
import serial

print "ok"

# Parameter von Konsole entgegennehmen
#if len(sys.argv) != 2:
#   print "you have to pass the name of a serial port"
#   sys.exit(1)
#serial_port = sys.argv[1]

serial_port = "COM13"
arduino = serial.Serial(

# continous read
line = arduino.readline()

while len(str(line))!=0:

      line = arduino.readline().rstrip()
      print line

Arduino DS3234 RTC output: YYYY-MM-DD hh:mm:ss

Original Code Snippet from sparkfun,
added YYYY-MM-DD hh:mm:ss output
i used Arduino MEGA-2560 via USB, power from USB,
important: i have to use SPI_MODE3 instead of SPI_MODE1 !!!
SPI_MODE1 delivered bullsh**

RTC – MEGA2560
VCC – 3.3V
SQW – GND (squarewave signal output for interupters)
CLK – 52
MISO – 50
MOSI – 51
SS – 53

const int  cs=53; //chip select 

void setup() {
  //day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)
  //SetTimeDate(27,4,12,16,5,0); // manuell Zeit setzen, kein 00 benutzen!

void loop() {
int RTC_init(){ 
	  pinMode(cs,OUTPUT); // chip select
	  // start the SPI library:
	  SPI.setDataMode(SPI_MODE3); // both mode 1 & 3 should work 
	  //set control register 
	  digitalWrite(cs, LOW);  
	  SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled
	  digitalWrite(cs, HIGH);
int SetTimeDate(int d, int mo, int y, int h, int mi, int s){ 
	int TimeDate [7]={s,mi,h,0,d,mo,y};
	for(int i=0; i<=6;i++){
		int b= TimeDate[i]/10;
		int a= TimeDate[i]-b*10;
			if (b==2)
			else if (b==1)
		TimeDate[i]= a+(b<<4);
		digitalWrite(cs, LOW);
		digitalWrite(cs, HIGH);
String ReadTimeDate(){
	String temp;
	int TimeDate [7]; //second,minute,hour,null,day,month,year		
	for(int i=0; i<=6;i++){
		digitalWrite(cs, LOW);
		unsigned int n = SPI.transfer(0x00);        
		digitalWrite(cs, HIGH);
		int a=n & B00001111;    
			int b=(n & B00110000)>>4; //24 hour mode
			else if(b==B00000001)
		else if(i==4){
			int b=(n & B00110000)>>4;
		else if(i==5){
			int b=(n & B00010000)>>4;
		else if(i==6){
			int b=(n & B11110000)>>4;
			int b=(n & B01110000)>>4;
        /* ORIG output
	temp.concat(TimeDate[4]); // tag
	temp.concat("/") ;
	temp.concat(TimeDate[5]); // monat
	temp.concat("/") ;
	temp.concat(TimeDate[6]); // jahr
	temp.concat("     ") ;
	temp.concat(TimeDate[2]); // stunde
	temp.concat(":") ;
	temp.concat(TimeDate[1]); // minute
	temp.concat(":") ;
	temp.concat(TimeDate[0]); // sekunde
        // custom
        //temp.concat(" -- ");
        String DD = String( TimeDate[4] );
        if (DD.length()==1){ DD = "0"+DD; }
        String MM = String( TimeDate[5] );
        if (MM.length()==1){ MM = "0"+MM; }

        String YYYY = String( TimeDate[6] );
        if (YYYY.length()==1){ YYYY = "200"+YYYY; }
        if (YYYY.length()==2){ YYYY = "20"+YYYY;  } // ;o)
        if (YYYY.length()==3){ YYYY = "2"+YYYY;  }  // ;o)
        temp.concat( YYYY );
        temp.concat( "-" );
        temp.concat( MM );
        temp.concat( "-" );
        temp.concat( DD );
        String hh = String( TimeDate[2] );
        if (hh.length()==1){ hh = "0"+hh; }
        String mm = String( TimeDate[1] );
        if (mm.length()==1){ mm = "0"+mm; }
        String ss = String( TimeDate[0] );
        if (ss.length()==1){ ss = "0"+ss; }
        temp.concat(" ");
        temp.concat( hh );
        temp.concat( ":" );
        temp.concat( mm );
        temp.concat( ":" );
        temp.concat( ss );

tinkerforge microcontroller easy

offensichtilich ein Arduino Wettbewerber,

Python API

zum Batterien Laden/Entladen (Bedini Experiments) bräuchte man: 30,-Euro 4,-Euro 10,-Euro 13,-Euro