1

I am trying to get a serial connection between an RaspberryPi and a Picaxe 18M2 Microcontroller. I found out that I should build the following cirucit because the Rasperry and the Microcontroller have different levels.

The level adjustment circuit

So here is a picture of my attempt to build this circuit.I checked it several times but maybe I made a mistake anyway (If needed I will send more pictures):

My attempt Main Part

I have the following code, that run's on the Picaxe 18M2 Microcontroller

main: 'high B.3 'green led
      'high B.0 'red led
       serout C.3,N4800,(10,13)  'Start a new line
       serout C.3 ,N4800,("Press a key- ") ' Send a message
       serin C.4,N4800,b1 ' Receive a character into variable b1
       serout C.3,N4800,(b1) ' Transmit character back to the screen
       if b1="a" then hot ' Is character ?a?? If yes goto hot
       goto main 'No, so loop back to start
hot:   serout C.3,N4800, (10,13,"A is the Hot Key!")
            high B.0
            pause 5000
            low B.0
            pause 5000
            high B.0
       goto main ' Loop back to start

I tried to connect over putty on my PC about the same serial connection I use to program the microcontroller. So i open a serial connection with putty on my COM1 Port with a baud rate of 4800. There the programm works. Not perfectly but it works and i am able to highlight a red led when i enter an "a". When I'm opening a serial connection on the Raspberry with minicom on /dev/ttyAMA0 I'm just getting back some weird charachters and it seems like i'm not able to send a charachter back to the microcontroller. I also tried baud rates of 600,1200 and 2400. I event tried it with picocom but that doesn't work either. Does anybody have an idea what I could be doing wrong?

1

Personally I'd dump 90% of that circuitry.

Assuming the PICAXE is 5V. The Pi is 3V3.

Connect the grounds.

Connect the Pi's TX to the PIXAXE's RX (use a series resistor if you want).

Connect the PICAXE's TX to the Pi's RX using a pair of resistors to cut the PICAXE 5V to a Pi safe 3V3.

Use stty -F /dev/ttyAMA0 x to set the Pi's baud rate to x.

  • I did like you said and connected the Pi's TX to the Picaxe's RX directly. I also changed to the Pi's baud rate to 4800 which I tought would solve my problem but it doesn't work anyway. – lucky_96 Jan 20 '16 at 22:06
  • The code seems to be using 600 baud as well as 4800. That might be confusing the issue, although I don't really see why. – joan Jan 20 '16 at 22:15
  • Oh thanks i messed this up because I was trying out different baud rates. You're right that should be 4800 as well. – lucky_96 Jan 20 '16 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.