Raspberry Pi

Raspberry Pi – homemade level converter for serial communication rs232 3.3 volts to 5 volts TTL for AVR microcontroller

I found that the Raspberry Pi serial interface rs232, described in a older post by myself, was too bulky.

Pi and AVR should be connected through a less amount of wires.

So I’ve searched the best hints to solder a cheap and uncomplicated level converter, that can directly be connected between the GPIO of the Pi and the rx/tx pins of the microcontroller.

On the German website I found a useful circuit with transistors and resistors that I had in my toolbox. (something similar but also matching parts)

The following images are showing my circuit diagram and the test setup.

The first test worked flawlessly both in the direction to the Pi and in the direction to AVR microcontroller.


The third picture shows the circuit diagram used and the fourth image the development on breadboard. Now I can connect my test board and the Pi over normal jumper cable to have hanging around without various additional boards.

Raspberry Pi

Raspberry Pi – using the serial interface (RS232)

The Raspberry Pi is equipped with many interfaces.
And the possibilities can rise more than exponentially by using of the USB port.
But to communicate with AVR microcontrollers is the best suited way by using a serial interface.
Of course, the Raspberry Pi A has a serial interface, but unfortunately merely as pins on the GPIO connector.

The required pins, could be connected theoretically directly to the microcontroller eg. ATMega8.
But that would require that the microcontroller operates at 3.3 volts.
My Pollin evaluation board works with 5 volts, but is made with a complete RS232 interface for communication with PC or other equipment.
The easiest way would it be, when the Pi would have an RS232 interface like a PC with the same connectors and signal levels.
By Googling I’ve found the website Serial Port Add On.
The described Serial Port to TTL Digital Converter Module there, I’ve bought at Ebay.

GPIO Header Pins
2 4 6 8 10 12 14 16 18 20 22 24 26
1 3 5 7 9 11 13 15 17 19 21 23 25
1= 3.3V, 9= GND, 8= TX, 10= RX

The jumper cables to connect to the Raspberry Pi were included in the delivery.
I’ve connected the module with the Pi, as shown in the picture below.

To get the serial interface up and running, are some changes in/etc/inittab and /boot/cmdline.txt necessary.


  • comment line: ‘T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100’
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100


  • delete of: dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

pictures of my PI inclusive ‘serial device’

RaspberryPI_mit_serieller_Schnittstelle_VS RaspberryPI_GPIO_serielle_Schnittstelle1_VS RaspberryPI_GPIO_serielle_Schnittstelle2_VS RaspberryPI_GPIO_serielle_Schnittstelle3_VS RaspberryPI_GPIO_serielle_Schnittstelle4_VS

Video, for Demonstration

The video is already on my ‘Hello World Example’ in the ATMega8 area of my website in use.

For that I’ve written a little perl script. Surely it is possible to use programs like minicom, but I dont wanted to spend the time to familiarize myself with a new tool.
The script was written faster and from my perspective it’s much more flexible for further use and for experiments.

Raspberry Pi

Raspberry Pi – via UMTS into the internet – configuration | setup

Raspberry Pi Model A connected via UMTS!

I’ve bought a relatively cheap, used ‘MEDIONmobile’ UMTS stick on Ebay and I’ve separately purchased a ‘Aldi Talk Starter Pack’ at a German Aldi market.

Aldi offers a tariff with 150MB UMTS speed and thereafter GPRS speed, for 3.99€ a month with a possibility to cancel the contract monthly.
It will ‘only’ used the E-Plus network, but that is relatively well available on my location.

short summary: what was necessary to go online?

  1. install wvdial
  2. modify /etc/wvdial.conf
  3. creating a Batch script with 2 lines, to set the SIM card password
  4. customize /etc/network/interfaces
  5. open connection

1. install wvdial

pi@raspberrypi - $ sudo apt-get install wvdial
Success!  You can run "wvdial" to connect to the internet.
  (You can also change your configuration by editing /etc/wvdial.conf)
pi@raspberrypi - $

2. modify /etc/wvdial.conf

For this, a little bit of preliminary work is necessary.
It is important to know something about the path through which the UMTS device will be addressed.
After plugging the stick – enter the command ‘lsusb’ to see whether the key has been detected.

pi@raspberrypi ~ $ lsusb
Bus 001 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270/E870 HSDPA/HSUPA Modem
pi@raspberrypi ~ $

Attention: In the Raspberry Pi Model B it didn’t work to insert the stick directly into the Pi, since my power supply wasn’t strong enough. (I’ve used a 5Volt 700mA power supply.)
But the operation via a USB hub went smoothly.
The Model A can handle it, probably because they self consumes by default less power.

The last entries in /var/log/messages, will show the path through which the UMTS modem is added.
In my case: /dev/ttyUSB0.

Feb 20 15:17:26 raspberrypi kernel: [   10.527167] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
Feb 20 15:17:26 raspberrypi kernel: [   11.313066] usbcore: registered new interface driver option
Feb 20 15:17:26 raspberrypi kernel: [   11.323480] USB Serial support registered for GSM modem (1-port)
Feb 20 15:17:26 raspberrypi kernel: [   11.334289] option 1-1.3:1.0: GSM modem (1-port) converter detected
Feb 20 15:17:26 raspberrypi kernel: [   11.345030] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB0
Feb 20 15:17:26 raspberrypi kernel: [   11.354849] option 1-1.3:1.1: GSM modem (1-port) converter detected
Feb 20 15:17:26 raspberrypi kernel: [   11.375418] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB1

Now I’ve configured the /etc/wvdial.conf for my ‘Aldi – Medionmobile’ access.

pi@raspberrypi /etc $ cat wvdial.conf 
[Dialer Defaults]
Phone = 
Username = 
Password = 
New PPPD = yes
[Dialer eplus]
Modem = /dev/ttyUSB0
Phone = *99#
Username = eplus
Password = gprs
Init3 = AT+CGDCONT=1,"IP","",""
Auto Reconnect=on
Stupid Mode=off
Idle Seconds=0
Auto DNS=on

3. creating a Batch script with 2 lines, to set the SIM card password

Who has secured the SIM card with a PIN, must ensure that the UMTS modem knows these PIN, before dialing.
Therefore serves the following bash script:

pi@raspberrypi /usr/local/bin $ sudo cat
echo "AT+CPIN=4711\n\r" > /dev/ttyUSB0

And now make sure so that only Root may have a look inside.

pi@raspberrypi /usr/local/bin $ ls -al
insgesamt 352
-rwx--x--x  1 root staff     50 Feb 24 13:14

4. /etc/network/interfaces anpassen

Finally, 4 lines coming into the /etc/network/interfaces.

pi@raspberrypi - $ sudo cat /etc/network/interfaces ab auto ppp0
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto ppp0
iface ppp0 inet wvdial
provider eplus
pre-up /usr/local/bin/
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

pre-up /usr/local/bin/ -> refers to the script for PIN transfer.

5. open connection

The connection builds up automatically immediately after booting, assuming that the Stick is plugged.

Independent of the automatically solution, the connection can be established and closed, with the the following commands:

pi@raspberrypi - $ sudo ifup ppp0
pi@raspberrypi - $ sudo ifdown ppp0
Raspberry Pi

(Deutsch) Raspberry Pi – Keep alive zum Webserver senden

Sorry, this entry is only available in German.

Raspberry Pi

(Deutsch) Intro – RaspberryPI

Sorry, this entry is only available in German.