Display for Arduino

Advert

Display for Arduino

Home Forums Electronics in the Workshop Display for Arduino

Viewing 25 posts - 1 through 25 (of 26 total)
  • Author
    Posts
  • #508677
    Peter Bell
    Participant
      @peterbell11509

      Hello Not really model engineering but at least I'm using my Myford to make the parts!

      As a fairly inexperienced Arduino user I am building a dedicated weighing scale using a 1kg load cell.

      Its all working fine using a lcd display but what I would like is use a larger display and this where it gets difficult as there so many variations to choose from. Tried a max 7219 without much success also some tft but all seem difficult to use, at least for me!

      Can anyone reccomend an easy to use current larger display that worked for them, say 1.8" or 2.2"?

      Thanks Peter

      Advert
      #32153
      Peter Bell
      Participant
        @peterbell11509
        #508813
        Andy Stopford
        Participant
          @andystopford50521

          You need the 7-segment display with i2c backpack – that way there are only two data lines to connect up. They are readily available from ebay and look really good. Unfortunately I've only used one with a Raspberry Pi zero, so I can't give you the C code to make one work (I used Python for the Pi, and the libraries are different anyway).

          Hopefully the following link to Adafruit's information and instructions won't fall foul of the forum rules:

          https://learn.adafruit.com/adafruit-led-backpack/

          edit: Sorry, the ebay ones are SPI rather than i2c; they should be similar to get working, but for simplicity, it might be best to use the Adafruit ones – if you're in the UK, Pimoroni sell them – they cost a bit more than the ebay ones, unfortunately. 

          Edited By Andy Stopford on 20/11/2020 20:27:24

          #508852
          duncan webster 1
          Participant
            @duncanwebster1

            I think you want one of these TM1637

            I've not used this particular one, I've used 8 digit and other 4 digit serial displays, much better than LCD for visibility, but limited scope of non numeric characters

            #508854
            Ady1
            Participant
              @ady1

              The max 7219 is good with the MD_Parola library but it uses a lot of memory

              There's a chap here who has made an LCD version with teeny code

              The parola library is worth the extra effort though, because it lets you do virtually anything with an LED dot matrix, pins 10 11 and 13 have given me the least problems so far

              an awful lot of examples are like crippleware for a beginner with the arduino, but small tweaks suddenly make all the difference

              Coding is still the same old teeth grinding brain squeezing grope in the dark subject that it was 20 years ago but at least the arduino can give you a leg up and start talking to stuff

              I think the problem with dot matrixes is you have to tell it EVERYTHING, so you get stuff like below x 100s to define every character or shape, like every dot in newsprint

              //////////////

              const char font5x7 [] PROGMEM = {      //Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
                  B00000000,  //Space (Char 0x20)
                  B00000000,
                  B00000000,
                  B00000000,
                  B00000000,
                  B00000000,
                  B00000000,
                  6,

                  B10000000,  //!
                  B10000000,
                  B10000000,
                  B10000000,
                  B00000000,
                  B00000000,
                  B10000000,
                  2,

                  B10100000,  //"
                  B10100000,
                  B10100000,
                  B00000000,
                  B00000000,
                  B00000000,
                  B00000000,
                  4,

                  B01010000,  //#
                  B01010000,
                  B11111000,
                  B01010000,
                  B11111000,
                  B01010000,
                  B01010000,
                  6,

               

              Edited By Ady1 on 20/11/2020 23:48:02

              #508858
              Ady1
              Participant
                @ady1

                If you can dump your readings into the serial monitor this should transfer them to a 7219

                Just add these lines to your routine, tweaking the names of variables as required

                I'm assuming your readings are floats and you have a 4 module 7219

                ——————————-

                #include <MD_Parola.h>

                #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
                #define MAX_DEVICES 4

                #define CLK_PIN 13
                #define DATA_PIN 11
                #define CS_PIN 10

                MD_Parola P1 = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

                String J;

                float weight;

                void setup()

                P1.begin();

                void loop()

                J=String(weight);

                P1.print(J);

                 

                —————————————

                Somewhere in your void loop() will be a

                 Serial.print(weight);

                line for printing your weighing sensors output to the monitor, the variable in brackets is your float

                omg…I hate code…

                Edited By Ady1 on 21/11/2020 00:25:51

                #508892
                Peter Bell
                Participant
                  @peterbell11509

                  Many thanks for the help, hesitated asking but pleased I did! The power of this site is amazing.

                  Never heard of an I2c backpack so ordered some Adafruit bits also a TM1637 to try. Nice tutorial on the Adafruit.

                  Meanwhile Ady I'll have a go with the Parola suggestion but looks far more than what I need. Copied the code and got it to compile after adding some curly braces. Added to my weighing sketch but its doing some funny things with the Max display, need more time to play, hopefully later.

                  #508909
                  Ady1
                  Participant
                    @ady1

                    Don't forget your wires on the arduino, use 10 11 an 13

                    Pasting your current code in here would be the simplest route

                    #508931
                    Ady1
                    Participant
                      @ady1
                      Posted by Peter Bell on 21/11/2020 09:48:58:

                      Copied the code and got it to compile after adding some curly braces.

                      It needs to be done in steps

                      1. Get your weighing machine outputting data to the computer monitor

                      2. connect up the 7219

                      3. insert my code into your weight routine to transfer data to the 7219

                      simples! (we wish)

                      Edited By Ady1 on 21/11/2020 11:53:13

                      #509352
                      Peter Bell
                      Participant
                        @peterbell11509

                        This is my working sketch at least for weighing and LCD display–must have got it wrong as I cannot make the Parola do anything? Inserted what I think but probably not in the right place! Certaily takes a lot of memory.

                        Can make the 7219 scroll from other sketches so the module is working.

                        #include <MD_Parola.h>
                        #include <HX711_ADC.h>
                        #include <Wire.h>
                        #include <LiquidCrystal_I2C.h> // LiquidCrystal_I2C library
                        HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
                        LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
                        #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
                        #define MAX_DEVICES 4
                        #define CLK_PIN 13
                        #define DATA_PIN 11
                        #define CS_PIN 10
                        MD_Parola P1 = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

                        const int Reset = 3;
                        float weight;

                        String J;

                        void setup() {
                        P1.begin();
                        Serial.begin(9600);
                        lcd.begin(16, 2);
                        lcd.print(" Starting &quot;
                        lcd.setCursor(0,1);
                        lcd.print(" 20/11/20 &quot;
                        LoadCell.begin();
                        LoadCell.start(2000);
                        LoadCell.setCalFactor(851.58); // calibration factor for load cell => strongly dependent on your individual setup Higher for less
                        pinMode( Reset,INPUT_PULLUP );// Pin3 pull up
                        lcd.clear();
                        }

                        void loop() {
                        LoadCell.update();
                        float i = LoadCell.getData();
                        lcd.setCursor(3,0);
                        lcd.print("Weight[g]:&quot;
                        lcd.setCursor(6, 1);

                        Serial.println(i,1);

                        J=String(weight);
                        P1.print(J);

                        lcd.print(i,1); //Prints weight rounded to 1 place
                        lcd.print (" &quot;

                        if ((digitalRead(Reset) == LOW)) { //Tare
                        lcd.setCursor(0, 1);
                        lcd.print(" Tare &quot;
                        LoadCell.tare();
                        delay(500);
                        lcd.clear();
                        }
                        //delay (1000);
                        }

                        #509354
                        Ady1
                        Participant
                          @ady1

                          Can make the 7219 scroll from other sketches so the module is working.

                          #include <MD_Parola.h>
                          #include <HX711_ADC.h>
                          #include <Wire.h>

                          HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>

                          #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
                          #define MAX_DEVICES 4
                          #define CLK_PIN 13
                          #define DATA_PIN 11
                          #define CS_PIN 10
                          MD_Parola P1 = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

                          const int Reset = 3;
                          float i;

                          String J;

                          void setup() {
                          P1.begin();
                          Serial.begin(9600);

                          LoadCell.begin();
                          LoadCell.start(2000);
                          LoadCell.setCalFactor(851.58); // calibration factor for load cell => strongly dependent on your individual setup Higher for less
                          pinMode( Reset,INPUT_PULLUP );// Pin3 pull up

                          }

                          void loop() {
                          LoadCell.update();
                          float i = LoadCell.getData();
                          lcd.setCursor(3,0);

                          Serial.println(i,1);

                          J=String(i);
                          P1.print(J);

                          if ((digitalRead(Reset) == LOW)) { //Tare

                          LoadCell.tare();
                          delay(500);

                          }
                          //delay (1000);
                          }

                          #509356
                          Ady1
                          Participant
                            @ady1

                            Get rid of anything to do with the LCD and give that a go

                            GL

                            #509358
                            Peter Bell
                            Participant
                              @peterbell11509

                              Got rid of all lcd but no difference I'm afraid….

                              #509367
                              Ady1
                              Participant
                                @ady1

                                Is your weight sensor outputting to the monitor ok?

                                #509369
                                Peter Bell
                                Participant
                                  @peterbell11509

                                  Sorry forgot to say—yes working fine

                                  #509374
                                  Ady1
                                  Participant
                                    @ady1

                                    Well All I'm doing is outputting that number (i) to the 7219…

                                    Try changing

                                    Serial.begin(9600);

                                    to

                                    Serial.begin(57600);

                                    And check your LED wiring is ok

                                    EDIT: I have gone and bought a HX711 from the bay because I've finished my last project, arrives in about a week or less

                                    Package include:
                                    1 x Weighing Load Cell
                                    1 x HX711 module

                                    Edited By Ady1 on 23/11/2020 13:48:58

                                    #509385
                                    SillyOldDuffer
                                    Moderator
                                      @sillyoldduffer

                                      Just a suggestion but I see Peter's code says:

                                      J=String(i);
                                      P1.print(J);

                                      The problem may be because P1.print() expects to be given a C string (small s) rather than a C++ String (big S)

                                      Try

                                      P1.print( J.c_str() ); // get a C null terminated string from the C++ String J,

                                      If memory is very short, causing the dreaded 'undefined behaviour', remove big S Strings from the program because they use a lot of memory.

                                      C++ may be much clearer and less error prone with:

                                      J=String(weight);

                                      but pure C is faster and uses far less memory with:

                                      char buf[24]; // big enough to hold a 23 digit number
                                      dtostrf( weight, 6, 1, buf ); // convert weight into C string in buf, minimum 6 characters, with 1 decimal place.
                                      P1.print( buf );

                                      Dave

                                       

                                      Edited By SillyOldDuffer on 23/11/2020 14:29:53

                                      #509451
                                      Peter Bell
                                      Participant
                                        @peterbell11509

                                        Thanks for the suggestions.

                                        Tried thems in many combinations including baud rate but didnt make any difference,

                                        When read i instead of weight got the display to do something, see attached reading a 1kg weight , no weight just flashes the decimal places.

                                        Put the lcd back as it doesnt seem to be the culprit.

                                        Tried another display with identical results, perhaps its time to give up and wait for the I2c display and other to arrive!

                                         

                                        max display.jpg

                                        #include <MD_Parola.h>
                                        #include <HX711_ADC.h>
                                        #include <Wire.h>
                                        #include // LiquidCrystal_I2C library
                                        HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin
                                        LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)
                                        #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
                                        #define MAX_DEVICES 4
                                        #define CLK_PIN 13
                                        #define DATA_PIN 11
                                        #define CS_PIN 10
                                        MD_Parola P1 = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

                                        const int Reset = 3;
                                        //float weight;

                                        String J;

                                        void setup() {
                                        P1.begin();
                                        Serial.begin(57600);
                                        lcd.begin(16, 2);
                                        lcd.print(" Starting ";
                                        lcd.setCursor(0,1);
                                        lcd.print(" 20/11/20 ";
                                        LoadCell.begin();
                                        LoadCell.start(2000);
                                        LoadCell.setCalFactor(851.58); // calibration factor for load cell => strongly dependent on your individual setup Higher for less
                                        pinMode( Reset,INPUT_PULLUP );// Pin3 pull up
                                        lcd.clear();
                                        }

                                        void loop() {
                                        LoadCell.update();
                                        float i = LoadCell.getData();
                                        lcd.setCursor(3,0);
                                        lcd.print("Weight[g]:";
                                        lcd.setCursor(6, 1);

                                        Serial.println(i,1);

                                        J=String(i);
                                        //P1.print(J);

                                        P1.print( J.c_str() );
                                        lcd.print(i,1);
                                        lcd.print (" ";

                                        if ((digitalRead(Reset) == LOW)) {
                                        lcd.setCursor(0, 1);
                                        lcd.print(" Tare ";
                                        LoadCell.tare();
                                        delay(500);
                                        lcd.clear();
                                        }
                                        //delay (1000);
                                        }

                                        Edited By Peter Bell on 23/11/2020 18:47:21

                                        Edited By Peter Bell on 23/11/2020 18:48:13

                                        #509631
                                        SillyOldDuffer
                                        Moderator
                                          @sillyoldduffer

                                          So it's trying – the output suggests the display is being controlled via SPI but sent the wrong commands, therefore lighting up the wrong segments.

                                          The Parola library depends on the MD_MAX72XX library, and its .h file explains as there is no standard way of connecting the LCD blocks to the converter chip on the end, so the library supports 4 options. They are:

                                          GENERIC_HW, ///< Use 'generic' style hardware modules commonly available.
                                          FC16_HW, ///< Use FC-16 style hardware module.
                                          PAROLA_HW, ///< Use the Parola style hardware modules.
                                          ICSTATION_HW, ///< Use ICStation style hardware module.

                                          Possibly your module isn't an FC16? Anyway, no harm trying the 3 alternatives to

                                          #define HARDWARE_TYPE MD_MAX72XX::FC16_HW

                                          eg.

                                          #define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW

                                          or

                                          #define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW

                                          or

                                          #define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW

                                          Dave

                                          #509657
                                          Peter Bell
                                          Participant
                                            @peterbell11509

                                            Thanks for the help Dave. Tried all the 3 alternatives but still got the same result I'm afraid. Also tried another display just in case this one is a dud or not what it's marked with identical results.

                                            Think its time to put this display aside and wait until the ones arrive that were suggested earlier in the thread, sure they will bring new problems to the surface and then more learning.

                                            Peter

                                            #509729
                                            SillyOldDuffer
                                            Moderator
                                              @sillyoldduffer

                                              Had another couple of thoughts.

                                              Maybe you have the correct device, wiring, and HARDWARE_TYPE, but are sending it data it can't cope with. The floating point number generated by:

                                              J=String(i); // Could send too many characters to fit the display, or the decimal point is illegal punctuation.

                                              (Floating point numbers change size depending on the result. By default String does 2 places of decimals eg String(1.0/3) gives "0.33", but watch out for the likes of 1000000.0/3 giving 333333.33. The Parola documentation looks as if punctuation is allowed, so the decimal point should be ok.)

                                              Test by assigning some short constants to J in your code , to see if they work. Eg.

                                              J=String("ABC" ) ; // Note – fits in a 4-cell block
                                              if that works then

                                              J=String("123" )  ;
                                              & if that works

                                              J=String("1.3" ) ;
                                              & if that works

                                              J=String(1.3);

                                              Assuming all that fails, have you tried any of Parola's examples? (See File->Examples menu )

                                              This one does nothing but say 'Hello', always a good first step to prove the basics are working. If Parola's own example can't be made to work, suspect wiring error or dud device. Note HARDWARE_TYPE needs to change to do your FC31. If the LEDs display hello, experiment by sending it Strings as above.

                                              // Program to demonstrate the MD_Parola library
                                              //
                                              // Simplest program that does something useful – Hello!
                                              // Uses the Arduino Print Class extension
                                              //
                                              // MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
                                              //

                                              #include
                                              #include
                                              #include

                                              // Define the number of devices we have in the chain and the hardware interface
                                              // NOTE: These pin numbers will probably not work with your hardware and may
                                              // need to be adapted
                                              #define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
                                              #define MAX_DEVICES 11

                                              #define CLK_PIN 13
                                              #define DATA_PIN 11
                                              #define CS_PIN 10

                                              // Hardware SPI connection
                                              MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
                                              // Arbitrary output pins
                                              // MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

                                              void setup(void)
                                              {
                                              P.begin();
                                              P.print("Hello!" );
                                              }

                                              void loop(void)
                                              {
                                              }

                                               

                                               

                                              Edited By SillyOldDuffer on 25/11/2020 09:31:39

                                              #509831
                                              SillyOldDuffer
                                              Moderator
                                                @sillyoldduffer

                                                Just a cotton-picking minute!

                                                Just noticed the board shown in Peter's picture is an 7-segment LED type and the Parola library is for 16×16 dot matrix display. They both use the MAX72xx and SPI, but otherwise aren't compatible

                                                Instead try a MAX7219 library for segment displays, best downloaded and installed from the Arduino's Library Manager. Several choices but max7219 by Jonathan Evans looks easiest.

                                                Dave

                                                #510234
                                                Ady1
                                                Participant
                                                  @ady1

                                                  Got it in today, this works ok

                                                  #include <MD_Parola.h>
                                                  #include <HX711_ADC.h>
                                                  #include <Wire.h>

                                                  HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin

                                                  #define HARDWARE_TYPE MD_MAX72XX::FC16_HW
                                                  #define MAX_DEVICES 4
                                                  #define CLK_PIN 13
                                                  #define DATA_PIN 11
                                                  #define CS_PIN 10
                                                  MD_Parola P1 = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

                                                  const int Reset = 3;
                                                  //float weight;

                                                  String J;

                                                  void setup() {
                                                  P1.begin();
                                                  Serial.begin(9600);

                                                  LoadCell.begin();
                                                  LoadCell.start(2000);
                                                  LoadCell.setCalFactor(851.58); // calibration factor for load cell => strongly dependent on your individual setup Higher for less
                                                  pinMode( Reset,INPUT_PULLUP );// Pin3 pull up

                                                  }

                                                  void loop() {
                                                  LoadCell.update();
                                                  float i = LoadCell.getData();

                                                  Serial.println(i,1);
                                                  delay(1000);
                                                  J=String(i);
                                                  P1.print(J);

                                                  if ((digitalRead(Reset) == LOW)) {

                                                  LoadCell.tare();
                                                  delay(1000);

                                                  }}

                                                  #510236
                                                  Ady1
                                                  Participant
                                                    @ady1

                                                    I sent the 5v live and ground to the breadboard and connected the modules from there, the 7219 first

                                                    The 7219 is greedy because it's 100s of LEDs

                                                    Does negatives too

                                                    edit: must confess that the outputs look weird to me, 100.5 is 10.05 kgs perhaps… hmmm

                                                    Just noticed sods post… oops

                                                    well if you get the led one it works ok… ish

                                                    my brain has exploded so I'll look at calibration testing later

                                                    Edited By Ady1 on 27/11/2020 16:32:31

                                                    #510361
                                                    Peter Bell
                                                    Participant
                                                      @peterbell11509

                                                      May thanks for all the help and suggestions.

                                                      Tried them without success, however after reading the other thread on Arduino displays and following the suggestion from SOD I felt inspired enough to start looking up what I had on the 7219 which gave limited success due to my lack of knowledge before being abandoned 2 years ago.

                                                      This time around from what I have learned I managed to work out what I was doing wrong and ended up with a working 7219 display on my weighing scale. This is my code below.

                                                      The Adafruit display worked immediatly and its nice and large and bright so good suggestion.

                                                      Next challenge is to explore storing and then retrieving a float value, can anyone reccomend an easy way or good tutorial etc?

                                                      I keep hearing about wearing out eproms, is it best to store things like that on an SD card?

                                                      Peter

                                                      #include <HX711_ADC.h>
                                                      #include <Wire.h>
                                                      HX711_ADC LoadCell(4, 5);
                                                      #include <HCMAX7219.h>
                                                      #include "SPI.h"
                                                      #define LOAD 10

                                                      const int Reset = 3;
                                                      float weight;
                                                      HCMAX7219 HCMAX7219(LOAD);

                                                      void setup() {

                                                      Serial.begin(9600);

                                                      HCMAX7219.Init();
                                                      HCMAX7219.Clear();
                                                      HCMAX7219.print7Seg("27-11-20",8);
                                                      HCMAX7219.Refresh();
                                                      LoadCell.begin();
                                                      LoadCell.start(2000);
                                                      LoadCell.setCalFactor(851.58);
                                                      pinMode( Reset,INPUT_PULLUP );
                                                      }
                                                      void loop() {
                                                      LoadCell.update();
                                                      float i = LoadCell.getData();

                                                      Serial.println(i,1);

                                                      HCMAX7219.Clear(); /* Clear the output buffer */

                                                      HCMAX7219.print7Seg(i,1,4,4); /* Write some text to the output buffer */

                                                      HCMAX7219.Refresh(); /* Send the output buffer to the display */

                                                      if ((digitalRead(Reset) == LOW)) { //Tare

                                                      HCMAX7219.Clear();
                                                      HCMAX7219.print7Seg("TARE",4);
                                                      HCMAX7219.Refresh();
                                                      LoadCell.tare();
                                                      delay(500);
                                                      }
                                                      //delay (1000);
                                                      }

                                                      7219-11.jpg

                                                      7219-22.jpg

                                                      7219-33.jpg

                                                    Viewing 25 posts - 1 through 25 (of 26 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up