$2 for 5PCBs - order with coupon code: JLCPCBcom
Any questions about JLCPCB or ordering, pls email support @jlcpcb.com
Now that I have two OLED displays on my Arduino, I alter the sketch to treat them as separate objects.
https://github.com/olikraus/u8g2/wiki/u8x8reference #seti2caddress
Interested in my new garden workshop? Follow the entire build on Julian's Shednanigans:
https://www.youtube.com/channel/UCXfDjPehpC7B7lW2JFxeS4w
Subscribed to my 2nd channel? Watch all my 3 minute videos on Julian's Shorts: https://www.youtube.com/channel/UCeewzdnwcY5Q6gcbnZKIY8g
Join me on Odysee/LBRY: https://lbry.tv/$/invite/ @julian256:d

Good morning, all today i want to take my humidity and temperature display and with my dual oleds i want to shift one of them to the other address the other i squared c address. So, let's take a look at the back of there and see how that's done i'll hoik it out trying not to disturb everything in the process and on the back of here there is an address link. Now it's a resistor, it's a 472 4k7 and you can either select 78, which i think is the default. Well, it certainly is on this.

You buy them with the link on address 78 or you can switch it to 7a. So it's a case of moving that resistor across the other two pads to select 7a. I'm going to do that now. I probably won't film it because it's very difficult to film stuff, this close because i kind of need magnifying glasses, but i will show you the aftermath a little bit of the process.

Let's clean my iron tip. If this is usable footage right, i think i'm going to heat both sides get the thing just generally hot hitting both sides is tricky there. It is it's off, don't want to annihilate it right, let's put it back on in the other position and see if it well doesn't work because um the program is addressing 78, so it shouldn't address 7a right done it, but i don't think it's very pretty. Oh, it's a bit wonky, but i think it is soldered on such that it will work, let's plug it in and try it i'll, probably have to reboot the program because i think there's some setup stuff that goes to the oleds reboot the program, and indeed it Talks to this old and no longer talks to this one, which is what i wanted kind of so here's the arduino sketch.

Let's take a look at this, i have a feeling that what we need to do here is simply have two objects and um i'm going to call them. I'm going to change the name from oleg to oled, so oled, and then i'm going to call it 78. So that i know the address so oled 78 begin, oled, 78 set font and so on and then down in the uh set cursor and print commands down in the loop. I will um use oled 78, but also oled 7a, so i'm going to put in a second line, i'm going to copy this line, copy and paste it in here, and this is going to be oled 7a and this is going to be oled 7a and then The only thing i need to add to this is the fact that it is on a different address, address 7a, and then i need to just change all this stuff down here, and it should work now, incidentally, if you're interested in knowing what the total code for This program is it's on the screen, i'm going to ensure that i keep this short enough by doing things like this.

Taking this line and putting two statements on one line, which i believe you can do to keep the whole program within the screen, so that you don't need to say: oh, where can i upload the software here? It is it's all on the screen now. I think i need this uh command. This is from the reference manual for ux 8x. It's set i2c address and i think i simply say, set i2c address and then put in a uint 8 and that i think, will be 0x7a.
I think that should work. Are there any notes here about the actual number? No? Well, let's just give that a try and see if it works right. I've put the line in so i've done a begin for oled 7a. Oh, i wonder if you have to oh, no, you don't have to set the font before you set the address.

No, you just begin an object um. Now. How do i know what i i need another constructor up here. I've got oleg well that will change to oled 78 and i need to uh duplicate that line.

So let's do that copy and paste it in down here it's the same hardware, but it's another object. Name: seven, a okay! So now i've i've constructed it now. I can talk about it or define its parameters and begin it set the i squared c address to 7a the default being 78.. I could put the set ic address in the 78 object, but it's defaults to that anyway, and now it's just a case of changing some stuff down here.

So i think what i'm going to do for the v and the a the volts and the amps i'm going to shift them to the other display. So all these olegs will be oh lead, uh, seven, a so i'll, just complete those and also do the uh. The first two lines as oled 78 and then i'll come back and we'll try it right. I think that's it.

I've got my two constructor calls and created my two names. I've done two begins to create the uh objects or instantiate them or something i think it's called and my 7a has a set. I squared c address in order that the uh arduino knows what address to talk to for that object and then all the set, cursors and prints down here have the correct names. So i'm going to upload that and see if it works and no it doesn't work.

I've only got the oled 78 data, which is my humidity percentage and my temperature in degrees celsius, but i think i know what the problem is. So let's go back to the reference manual uh. Yes, here it says um. Where does it say? Oh yes, call this procedure before begin and i didn't call it before begin so.

Obviously uh the begin method or function function. I think it is isn't it um uses the set. I squared c address information to set up the object, so i will go back and shift that around. Oh, i think my microphone level is going to be all over the place.

I found that my different scenes in obs are all set differently, never mind uh. Let's plow on so this set, i squared c address: thingy needs to come out uh control x and it needs to go before begin. So i need to put it in there ctrl v there it is then oled7a set. I squared c address to 7a begin.

The uh: well, it's an object but begin it get it running and then set the font that should do it. Let's compile and upload i'll click that button there, and that seems to have done it um. You can see that the lines which talk it's the same data, because i've only got two uh sets of data coming out, but uh. It's a different set of instructions in the code, so you've got volts and amps here the intention was to have it measure, volts and amps of a battery um using the.
I can't remember what it's called it's a little uh i squared c voltage and current sensor in a219. That's the one um, but yeah that works. I've got the first two lines on the first display and the second two lines on the second display. So yeah i'm happy with that.

Now i just wanted to say a bit about the justification for continuing this project. I am planning to get some zigbee temperature and humidity sensors to put them in the shed or sheds, because i've now moved one of the miners to another shed because of overheating problems, and i plan to use those for the sort of smart setup. So perhaps, if a shed gets too hot, the temperature and humidity sensor could trigger the smart functionality of the tuyere app to switch off one of the mains switching points so that it can switch off that minor and bring the temperature back down. But the app on your phone, you need to switch your phone on.

You need to put in your pattern. You need to um. I think i showed my pattern there. You need to um and if you've got another app running because you're doing something else on your phone, you don't have to switch to the app it's not an always-on display, so this represents an always-on display.

So i can put this on my desk and i know at a glance because it's always there what the temperature in the shed is. So i think there is a justification for this and obviously i want to continue with this project, but that's a little bit about why i'm continuing this, apart from the fact that it's good fun, of course, so for the moment, cheerio.

By Julian

Youtuber, shed dweller, solar charge controller aficionado

13 thoughts on “Two Arduino Objects for Dual OLED”
  1. Avataaar/Circle Created with python_avatars Nick B says:

    Seven eight hex is so not seventy-eight. (It is, in fact, one hundred and twenty.) Seventy-eight is a decimal! You correctly say 0x7A in hex, so why not 0x78? Would you say ten for 0b10?

  2. Avataaar/Circle Created with python_avatars MrCalldean says:

    Julian: builds modular shed, power wall and own power management – because fuck you

    Also Julian: Feels the need to justify dual LEDs for properly good and innovative project.

    Really enjoyed this build, no justification needed fella.

  3. Avataaar/Circle Created with python_avatars Brendan White says:

    Think my previous comment was deleted as I had a link to the website.
    Might be worth looking at ZigBee2MQTT and NodeRed if you are using ZigBee (or planning to) instead of using Tuya Cloud. That way you can keep it all local and not rely on internet. This will run happily on a Raspberry Pi with CS2531

  4. Avataaar/Circle Created with python_avatars John Smith says:

    You're saying you have a humidity sensor connected to TUYA? You mean a separate aquara/mija sensor, or how have you gotten the arduino temp/humidity sensors to communicate with TUYA/WIFI?

  5. Avataaar/Circle Created with python_avatars J H says:

    Julian – What sort of network connection have you got from the house to the shed? [No need to answer. 🙂 ] I've been looking at Media Converters (Ethernet <> Fiber Optic) and they're surprisingly cheap (~$20/pair) and cheerful. Even the roll of pre-terminated fiber is cheap and cheerful. It seems that one could span a km (up to 20 km) for something like a few hundred dollars. I wish I had an application, and a free path between. I might explore the solution for my picnic table which is only 100 feet away, just for laughs. Cheers.

  6. Avataaar/Circle Created with python_avatars Rob Spencer says:

    I might be wrong as it has been a long while since I did any Arduino stuff, but I think you can declare both oleds on the same line:
    U8X8_SSD1306_128X64_NONAME_HW_I2C oled78, oled7A;
    Might save you a line 🙂

  7. Avataaar/Circle Created with python_avatars Tom William says:

    Do you think by adding a powered vent to the shed would help exhaust the hot air. You could possibly use your temperature sensor to trigger relay the fan of the powered vent

  8. Avataaar/Circle Created with python_avatars Daz Ryan says:

    I did something similar with OLED displays and found that the display dims if it is a constant display. In my case the temperature is always 20 something degrees so the 2 faded away. I redid it using scrolling

  9. Avataaar/Circle Created with python_avatars Nick F says:

    I'm enjoying watching the progress of this project. I was laughing when you decided to add the "multiple monitors" in a good way. I would totally have a quad display setup lol. I really can't wait to see it finished in a nice project box or custom case (I know… we profectionest tinkerers will never truly be finished with a project)

  10. Avataaar/Circle Created with python_avatars Richard Bloemenkamp says:

    I like your Arduino videos especially when mixed with cheap sensors, actuators, low power and computer interfacing. For example, the other day I saw a nice video where two Arduinos were used with a cheap on/off laser module and photo diode to create a wireless information/music channel without using a black-box Wifi or other RF-module.

  11. Avataaar/Circle Created with python_avatars steve64464 says:

    Messing with a ina219 on the rpi pico at moment , not sure what the max current it can handle mind , i assume it differs based on how much voltage being put through.

  12. Avataaar/Circle Created with python_avatars bjornjuul says:

    Great channel with lots of interesting projects. Strange question: where have you gotten the rubber tags or keyhangers with your logo from?

  13. Avataaar/Circle Created with python_avatars emcosta says:

    When you spend years in Software Engineering having that weird voice telling you how bad it is to have source code without "proper" formatting, it's so refreshing to see someone writing code without caring about that kind of stuff. Reminds me my good old days learning how to program and having some real fun.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.