Jump to content

Arduino and Raspberry Pi Projects Thread


gavino200

Recommended Posts

I picked up some OLEDs and TFTs. I think I'm ready to start playing with programming them - well, the OLEDs anyway. I'll wait a while to tackle the TFTs. Likely, I'll acquire more as I play around. 

 

I'm going to set up a circuit and then scour the net for sketches to run. I'm planning to pick apart the sketches and see what happens when I change things. My goal will be to have a few template sketches set up, that I can then add content to later when needed. I'll also start looking at how to take an image I want to reproduce, and turn it into a bitmap for a sketch. I'm assuming there's a way to do that rather than calculating bitmaps, pixel by pixel, and adding them in. I have quite a few things to learn, but I think I'm ready to start. 

 

The TFTs will eventually run video, hopefully on the front of a downtown commercial building. As far as I know this will probably need to be controlled by a Rasberry Pi, rather than an arduino. Pi's are still a mystery to me, but I'm super curious about them and can't wait to take them on.

 

h7NieYl.jpg?1

Edited by gavino200
  • Like 3
Link to comment

This is actually much more doable than I expected. The main reason is that there are lots of sites out there that teach it very well. 

 

I found this page, that teaches all the basics of programming the 128x32 pixel OLED. I had a go at trying to convert a photo of myself into an bitmap image. I succeeded with a super low res image, but it will take a bit of trial and error with the code to get it to fit exactly on the screen. Still the devil is in the details so I'll stick with this until I work out how to tweak the code to get my mug to fill the screen. 

 

I'll also have to find a library that contains Japanese characters. Either that or I can just take pictures of text and turn them into bit-map images. 

 

wCIyDmM.jpg?1

 

3p8ZYfJ.jpg

 

gbnp19L.jpg

 

WieoV7H.jpg

 

 

  • Like 2
Link to comment

You look better on the first picture, but I like the last one, it makes me think of a noisy bitstream coming from deep space in a science fiction movie 😀

Based on my previous tests:

- The resolution of the 128 x 32 OLED might not be enough to display Japanese characters, unless they are really large

Display Area: 22.38 x 5.58mm

22.38 mm / 128 pixels = 0.175 mm/pixel

128 pixels / 22.38 mm = 5.71 pixels/mm = 145 DPI

- The highest resolution display I have found is this one: https://www.aliexpress.com/item/32859772356.html.

Display Area: 23.4 x 23.4mm

23.4 mm / 240 pixels = 0.0975 mm/pixel

240 pixels / 23.4 mm = 10.2 pixels/mm = 261 DPI

- It's not an OLED, it's a IPS TFT LCD, but it does not matter. I do not know why high resolution color OLED displays are not available to us...

- The following library can print anti-aliased unicode characters: https://github.com/Bodmer/TFT_eSPI. I have never used it. I have always used bitmaps created on my computer and transferred to the Arduino.

  • Thanks 1
Link to comment

Taking a fresh look at this today I worked out the problem. I had to edit the imaged in the Image converter to the correct number of pixels for the screen. In this case 128 x 32. 

So the process is fairly simple to put graphics on the screen.

1. Take a photo

2 Use MS paint to convert it to a monochrome pic. It makes sense to reduce it in size too.

3 Use an Image converter which is a free program to convert this into a bitmap

4 Cut/paste the bitmap into a very simple sketch and upload it to the arduino.

 

For this 128x32 OLED screen, I've learned the following.

How to print text, change font, size, screen location, and scroll the message around the screen in any direction or pattern.

How to draw shapes and graphics from scratch.

How to take an image and convert it into a bitmap to show on the screen.

I have basic template sketches to use to just add bitmaps, text, and graphics to, and have a fair idea how to manipulate and change them. 

 

I'm happy with this for now. I think I'll move on to playing with the TFTs.

 

qPdiq6q.jpg?2

  • Like 3
Link to comment

Hitting a stumbling block with this TFT LCD Display Module 240x320 ILI9341. I'm pretty sure I have it connected correctly. And I think I have the necessary library installed. I'm running a test code that's supposed to be fore this model of TFT. But I get no response. Just the white screen of death. 

 

Gonna leave it for now, and take a fresh look at it later. 

 

Vs8vvpL.jpg

Link to comment

So I think I know the problem. These TFTs are not equipped with drivers that are designed to work with arduinos. So some changes need to be made to the test code for the Arduino to interface with the driver. However, I followed the steps here and had no success. It's possible there are different drivers for the items I bought. I'll leave it for a while, then see if I can get any specific information on the drivers for these units. I'll also find a different site and redo my wiring. Then try again. 

 

This seems to be a common problem. 

 

 

 

Link to comment

Still no luck with the larger TFT. I took a break and got the little one to work, at least with a simple graphics test. 

 

GWPkxL6.jpg

  • Like 1
Link to comment

So now I'm completely stumped. This YouTube tutorial is for the exact make and model of both TFT and Arduino that I'm using. I've followed it exactly. Still the white screen of death. 

 

 

Link to comment

It's late but I finally worked it out. This time I made a proper voltage divider, but that wasn't what did it. This YouTube video below talked me through exactly how to make the necessary code changes. The Adafruit code is designed for an Adafruit TFT device. These cheep screens have a "reset" imput wheras Ada's doesn't. For the code to work you have to make two small changes to allow for the reset input. I had only made on of the changes before. I believe I was looking right at an example of the second change before, but didn't pick up on it. 

 

Next to hook up the memory card and to work out how to add a second screen to the same circuit. After that I can work on image capture and manipulation, until I have a model building to put this into. 

 

6JPUnMy.jpg

 

This video explains everything about how to connect one of these cheep SPI TFT ILI9341s to an Arduino. No other material should be needed. 

 

 

Edited by gavino200
  • Like 2
Link to comment

Gavin is going to be hacking the ransomeware hackers next week at this rate, he will be uploading his consciousness to his new overlord skynet computer system at the end of the summer. All hail Overlord Gavin.

 

jeff

  • Haha 2
Link to comment
Martijn Meerts

I think he's managed to slow down time, so he has 48 hours in a day instead of 24 ...

  • Haha 2
Link to comment

I played again with the 2.2 inch ILI9341 TFT screen again yesterday. I've found the limits of what an arduino can do driving a screen like that. Basically I can use it as a display for fairly simple graphics. This will, I'm sure be useful for future projects but not very suitable for playing quality video, which is the task that I'm pursuing right now. It turns out that there is a way to make it show short video sequences where it shows them as a kind of slide show from an SD card, but it's very limited. I think I'd be better of trying this with a Raspberry Pi. 

 

So....this gives me the excuse I need to start dabbling in R-Pi's. 😜 ordered an R-Pi that I know is more advanced than what I need for this little project. I'm going to use this Pi as a mini-desktop computer, and then once I have some idea of R-Pi's I'll shop for the most basic Pi that will work for this project. I also got a little cooling fan for the Pi. I'll make a "case" for it out of old technical Lego.

 

I'm not sure what Arduino project I'll try next. Maybe Dani's platform announcement project, if it doesn't look too complicated. 

  • Like 1
Link to comment
  • gavino200 changed the title to Arduino and Raspberry Pi Projects Thread

I was browsing through @Dani's club'n'caldes blog looking for project ideas. I see that he has integrated his Arduino with LocoNet and Rocorail. He mentions having had help from someone on Team Rocorail. 

 

I've been wondering about this for a while. I like the idea of making automation solutions myself (using mostly other people's ideas), but I also want to have an integrated system controlled mainly in one place - iTrain. I'm going to shift my focus from projects to learning how to integrate Arduino projects with my Digikeijs system and iTrain. The DK and iTrains forums will be my first port of call. After that, I'll switch back to looking for projects. 

 

  • Like 1
Link to comment

This is interesting. A short video showing how a Motor shield and an Arduino Uno can be used to reproduce the functionality of a basic DCC Control unit. 

 

 

  • Like 1
Link to comment

This paraphrased from a machine translation of a post by bbernhard on the iTrain forum

 

"Well, there are several ways to connect an Arduino to ITrain.


1) You make the Arduino "understand" messages with DCC. It becomes an accessory decoder, so to speak. To do this, the DCC signal must first be processed electrically and then decoded accordingly by the software. Which function you then pack behind the aspects is up to you. However, this is also the most demanding variant. He doesn't necessarily have to understand DCC, Loconet or the like works too. Still, it doesn't get any easier. There are also many finished projects.

2) For every function that the Arduino is supposed to carry out, you can donate an output from an existing accessory decoder. TheArduino then simply monitors this output. As soon as this is activated, it begins to perform the function behind it. This is very easy to implement, but one of the function outputs of an additionally required DCC decoder is assigned with it.

3) You completely break away from the typical model railway hardware / protocols and do your own thing. We showed how this can be done last year with the platform clocks and timetable displays. The connection between iTrain and Arduino is realized via LAN or Wlan. If you want to do that, it is better to work with ESP or NodeMCU controllers, because the WLAN is already integrated.


If you are still at the beginning as you write, then I would first advise you to version2). You can concentrate fully on the programming of your function and do not have to deal with connection and protocol topics. There is also nothing to prevent it from being used later in more complex variants.

That from the point of view that you want to LEARN AND UNDERSTAND what you are doing.
If the only thing you can do is to recreate an existing project, then it doesn't really matter. Solder it together, play on a sketch and hope that it works."

 

So basically

Option 2. iTrain -> Digikeijs command center -> Decoder -> Arduino iput -> Arduino Output -> effect

This does seem inefficient. And expensive, however it does make it worthwhile to make an arduino DCC decoder. (option 1) That was something I wanted to do anyway just to understand better how decoders worked. I guess the advantage of option 2 is that you can completely ignore dealing with DCC. But I think sooner or later I'll have to take that on. 

 

Option 3. iTrain -> Arduino -> effect

This is clearly preferable. I need to learn more about the iTrain to aruino link. I need to understand how iTrain gives commands. 

 

 

 

Edited by gavino200
  • Like 1
Link to comment

Some interesting Arduino projects from a German site, including making a DCC decoder, turnout control, LED control and a welding light. (I wonder if I could find a TV simulator using a RGB LED somewhere?). 

 

 

  • Like 1
Link to comment

This is enough to one of these days to dive into this.  To make cool things happen on a layout.

 

I'll be buying a Pi this year but for a totally unrelated reason -- to run HomeBridge on, which is a smarthome bridge into the Apple HomeKit system for non HomeKit devices.

 

I have enough stuff to retire 5 times and keep me busy.  Unfortunately retirement is a good chunk of time away...

  • Like 2
Link to comment
1 hour ago, chadbag said:

This is enough to one of these days to dive into this.  To make cool things happen on a layout.

 

I'll be buying a Pi this year but for a totally unrelated reason -- to run HomeBridge on, which is a smarthome bridge into the Apple HomeKit system for non HomeKit devices.

 

I have enough stuff to retire 5 times and keep me busy.  Unfortunately retirement is a good chunk of time away...

 

The Arduinos have been fun. I expected it to be a huge headache, but there are some layout things that I really want that I need them for. I'm surprised for find that I really like it. 

 

My Raspberry Pi just arrived. This one is a bit fancier than what I need. I'm waiting for a heat sink/fan before I use it. My son is going to help me make a case for it out of old technical lego. 

 

I'm starting with the very basics. I'm about to go on vacation (local road trip) so I won't do anything with it for a while, but I'll probably do a bit of YouTube surfing to familiarize myself with what it can do. 

 

I see I'll need to get a micro SD card. I was assuming I could use the SD from my old Canon camera but that's way to big. 

 

I used to have a pile of old monitors and keyboards, but it seems I threw them out on my last move. I just bought a small cheap keyboard and mouse as sharing these with my desktop would be annoying. As luck would have it, one of my desktop monitors has an HTMI port that isn't being used. So all I need is an HTMI to micro HTMI cable. Sharing one of my screens shouldn't be too much of a problem. 

 

I guess my first task will be to choose what operating system I want to run. 

 

kLeHmCE.jpg

 

Edited by gavino200
  • Like 2
Link to comment

Unsurprisingly Ken from Sumida Crossing has an excellent page on the basics of Raspberry Pi's. It drops off at around 2017 but it's still very helpful. I'm going to follow Ken's advice on making back ups and keeping records. He also has good advice on not frying your Pi!

 

I've researched operating systems, and I'm going to go with the basic Rasbian OS. I have a couple of reasons for this. It's quite fast and very stable. But my main reason is that it has the widest user base and is used for the majority of projects, beginner and to some extent advanced. I'll flash Rasbian to an SD card directly rather than filling my SD up with everything found on NOOBs.

 

Looking at Pi cases there are a number of guides to making them out of Lego. The size of the Pi board matches almost perfectly with the Lego grid pattern. I wonder if that's a coincidence or if the makers used Lego cases from the get-go. Of all the guides I've seen this is my favorite. It has good design as well as basic function. It's from a Lego site, rather than a computer site. 

 

I'll have a bit of an extra challenge, as I've chosen (likely unnecessarily) to fit mine with a cooling tower. This will make it a bit harder to make something that looks good. I'm hoping that Star Wars and Technical Lego will be useful. The base at least will be simple, as it will be identical to the YouTube creations. And I'll have a round tunnel on both sides to conduct the air through the fan. The rest is unknown, for now. 

 

Another challenge to making mine look good is that I'm planning to use a break-out board from Adafruit for my GIOPs. Most case designs just ignore these, but the GIOPs will be central for what I want to achieve with the Pi. I'll need to have immediate access to them at most times. It would also be helpful to have them labeled. I'll either have my ribbon cable accessible through a door, or I'll just have it permanently exiting the side of the case. The reviews of the break-out board mention that the ribbon is very difficult to detach and reattach. Many mention that it breaks easily, so likely I'll leave it permanently attached. This NES style FakeLego case gives me an idea. I could try to include a chamber with a door to store the break-out board.  I may be able to do this with the vertical space dictated by the fan, rather than having to expand the footprint of the case.

 

 

That's all for now. 

 

I

 

 

Edited by gavino200
  • Like 1
Link to comment
17 minutes ago, Madsing said:

This link points to a breakout board only compatible with old Raspberry Pi 1. Yours must be newer and this is the correct breakout board: https://www.adafruit.com/product/2028. This is the one you have to buy 😀

 

Thanks. That's the one I bought. I just checked. 🙂 I just put the wrong link in the post.

 

A problem I didn't see at first is that the fan will use two GPIO ports. So I'll either have to cut two wires from the adapter cable for the fan, or extend the fan wires and have them come off the adapter. That seems to make more sense. If I really need those GPIO ports for a task I can just disconnect the fan - It's massive overkill anyway. 

 

I'm going to return the "ice-tower" for the "low profile ice tower". That will reduce the height. Also, it means that I don't need to keep the GPIO side of the case free for the airflow. The air can enter on the other side and leave through the top. That way I should be able to make space with a panel door to hold the break-out board and ribbon. Hopefully that will cut down on the ugliness. This will be my "Learning node", and will sit on my desk, so I'd like it to look good. 😜

Edited by gavino200
  • Like 1
Link to comment

Yep, we passed a roadworks on the road today that had a light-sign-truck. I was telling my son about this very project of Madsing's. I'm fascinated by these tiny screens. 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...