Author Topic: Moving a project from Arduino to Raspberry Pi Zero  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

Offline aiq25Topic starter

  • Regular Contributor
  • *
  • Posts: 241
  • Country: us
Moving a project from Arduino to Raspberry Pi Zero
« on: July 25, 2017, 08:32:32 pm »
Hello. I'm working on a project that is currently using an Arduino but I would like to move it to a Raspberry Pi Zero. I think using the Pi Zero will be less hassle.

Currently I have the following modules interfaced with an Arduino Nano: RTC, graphics LCD, SD card. Basically it's a fancy clock module with some added features. The reason I would like to move it to the Pi Zero is because I would like to be able to play large audio files with the module. I kind of got this working with the Arduino but I would like to try it on the Pi Zero. I would also like to use a bigger screen using the AV output of the Pi Zero.

Are there any beginner tutorials anyone can recommend? I don't have any experience programming in Python or the Pi Zero. I have only worked with microcontrollers.
 

Offline ealex

  • Frequent Contributor
  • **
  • Posts: 313
  • Country: ro
Re: Moving a project from Arduino to Raspberry Pi Zero
« Reply #1 on: July 26, 2017, 12:08:35 pm »
short answer : it will be complicated.

long one:
i imagine you'll use the entire linux OS for it and not as a bare-bone system.

the main code will run the same but you'll have to change the entire IO stuff:
- no more raw access to RTC - you'll have to use C time functions or learn how to use
I2C / SPI linux drivers or, if you're lucky you might be able to install a kernel module for your RTC so you can see it in /dev/ or make the OS use it as the main clock
- no more raw access to LCD, etc
- the same for user IO - you'll have to use GPIO system and learn how to enable / disable GPIO's and make the C code react on events
- no more raw access to audio, etc - you'll have to spawn a mplayer process or something to play your audio file

basically you'll have to learn everything from scratch.
C experience will help a lot, but still you'll have to learn the external libraries / etc

some other disadvantages :
- you'll have to take care of the entire OS including specific SD wear problems / updates / install / etc
- greater cost
- greater power usage


i'm doing the reverse of what you want:  i'm using a RPI as a dev. system for some pulse-oximeter related code that will finally run on a cortex M0 micro.
to make porting possible :
- i made the low level I2C access as generic read / write functions that will be replaced with MCU specific code
- all debug information on screen is generated from macros that i can change / disable easily
- all data dumps are also handled by functions that can be disabled without changing the main code
- i've used types from "stdint.h" - that are equivalent between system : uint32_t is an unsigned 32bit integer even if i'll build that code for a Z80
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Moving a project from Arduino to Raspberry Pi Zero
« Reply #2 on: July 26, 2017, 12:15:52 pm »
If your only real problem is not enough storage space for large audio files then I think you'll have a LOT less trouble sticking to an Arduino and just adding an SPI flash chip or SD card. Or buying a "Arduino" with one built in.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Moving a project from Arduino to Raspberry Pi Zero
« Reply #3 on: July 27, 2017, 09:03:25 am »
The way I would approach this with a Raspberry Pi is quite different to Arduino.

- Get a Pi Zero W (with Wireless)

- Use NTP to get the time over wireless, I would not use a RTC. Automatic timezone changes.

- Use OpenGLes to do the display - making use of the GPU (see https://github.com/peepo/openGL-RPi-tutorial for tutorial code). This will be the biggest challenge to learn.

- Play audio files by fork()ing a process to play the audio streams

- Use basic GPIO for any required local user interface (buttons/switches)

- Do development remotely on the Pi over SSH.

You can find some very poor C code to see how to use GPIO and I2C at its lowest userspace levels at http://hamsterworks.co.nz/mediawiki/index.php/Raspberry_Pi - it is very old but you should get the gist especially for GPIO- you open a couple of special files and read/write values to them. One controls the pin direction (input vs output), the other reads the current value of the pin.

This is all very old-school, but then I am that sort of guy.
« Last Edit: July 27, 2017, 09:06:01 am by hamster_nz »
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf