Atmega8 as UART-SPI interface (Atmega8 to RaspberryPi)

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi. I am new to this all - let's say: two years in programming.

In my Garden i have a solarsystem with a MPPT75/10 controller. The MPPT75/10 is sending hex Data on a UART interface every minute. See: VE.Direct protocol GitHub

 

I am trying to read the HEX Data with the Atmega8 and give it to a RaspberryPi via the SPI interface.

There telegraf and grafana will do the rest.

In the next month i will give updates here.

 

As i have no idea of the right path to do this - i am looking forward for any hints and links to similar project / solutions you know.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The simplest solution would be a usb->serial adapter. No fiddling with spi and another microcontroller. The Pi is better at USB than it is SPI.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RPi has UART also.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bx1 wrote:

RPi has UART also.

Yeah I wondered about this too. Exactly what is the point of the AVR?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you theoretically can do it, someone will try. And even if you cannot theoretically do it, someone will try that, also.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Jun 15, 2019 - 09:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the response.

I know. the RPi has UART - its used in my setup by the OpenSprinkler Board.

The one USB Port (RPi Zero W) is used for a LTE Stick - it's in my garden and i just have this LTE connection (ssh-tunnel) from my apartment to the garden. 

 

So when i understand your comments right - its far to complicated?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since the pi does not bring out the upper gpio pins where alternate tx/rx pins reside (there are 2 uarts, but both happen to use the same pair of user accessible gpio pins), you are stuck with one uart via the gpio pins. But, you can still use the other uart via Bluetooth (which takes over one of the uarts- the better one of the two). So one alternative would be to use a serial to Bluetooth adapter of some sort on your controller box.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or a small usb hub.....
Incidentally, NXP has some ics that do spi to uart, but then you’d need to have code on the Pi to talk to it. It seems like solving a problem with a bigger problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

VOIR wrote:
I am trying to read the HEX Data with the Atmega8 and give it to a RaspberryPi via the SPI interface.

 

FYI: I have not used SPI on a Raspberry PI, but ...

 

Take a look at this from Sparkfun: Raspberry Pi SPI and I2C Tutorial.

 

Make the Pi an SPI master and the mega8 the slave.

 

Use a circular buffer on the mega8 for receiving data via the USART.

 

By "HEX Data" do you mean binary data bytes from the USART?

If so, one approach is to convert each data byte to 2 ASCII hex characters ('0' ... 'F')

to represent each data byte.  Send the 2 ASCII hex characters to the Pi followed by

an ASCII ',' as a separator and ASCII NULL (0x00) when no new data is available.

 

On the Pi, convert each pair of ASCII Hex characters back to a binary byte of data.