Weird Icons on LCD Panel (16x2 I2C) [Electrical Noise?]

So , My LCD Panel (16x2 I2C) is showing weird icons after a few times using the pumps. At the beginning when the pumps are not used it is normal , after using the pumps it shows weird icons sometimes after the first use or the third it's pretty random. From searching online I guess it's electrical noise but I don't know how to fix that.

#include <Wire.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// created by Seafoxc
//#include <SoftwareSerial.h>
//SoftwareSerial  EEBlue(0, 1); // RX | TX

//Timing
unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 1000;  //the value is a number of milliseconds

//defining the pins used for each drink, you can  changes this depending how you connect the pumps and the drinks.

const int buttonLeft_pin = 10;
const int buttonRight_pin = 11;
const int buttonConfirm_pin = 12;

int Vodka  = 2;
int Cointreau = 3;
int CranberryJuice = 4;
int Sprite = 5;
int  LemonJuice = 6;
int SugarWater = 7;
int BlueCur = 8;
int Gin = 9;

char *Cocktails[] = {

  "Vodka Sprite", "Blue Lagoon", "Cosmo", "Lemon Drop", "Blue Moon", "Blue Gin Moon", "Double Strike", "Tom Collins", "Flying Dutchman", "London Cosmo", "Vodka Cranberry", "Cranberry Gin"
};

int  counter = 0;
int  state = 0;
// how much time there is between switching to the next pump.
int  TimeBetweenPours = 500;


void setup()
{

  startMillis = millis();  //initial start time

  Serial.begin(9600);  
  Serial.println("The bluetooth gates are open.\
 Connect to HC-05 from any  other bluetooth device with 1234 as pairing key!");
  //LCD
  lcd.init();         // initialize the lcd
  lcd.backlight();    // Turn on the LCD screen backlight
  
  lcd.setCursor(0, 0);
  lcd.print(Cocktails[counter]);


  // Set pin 2-9 to  output pins to drive the relay board
  pinMode(2, OUTPUT); 
  pinMode(3, OUTPUT);  
  pinMode(4, OUTPUT); 
  pinMode(5, OUTPUT); 
  pinMode(6, OUTPUT); 
  pinMode(7, OUTPUT); 
  pinMode(8, OUTPUT); 
  pinMode(9, OUTPUT); 

  pinMode(buttonLeft_pin, INPUT_PULLUP);
  pinMode(buttonRight_pin, INPUT_PULLUP);
  pinMode(buttonConfirm_pin, INPUT_PULLUP);

  pinMode(LED_BUILTIN, OUTPUT);


//  My relayboard is a "low true" board. So setting the output to low energize the  relay's. You don't want that yhey all switch on when powering on the cocktailmaker...

  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);

  
}
 

void loop(){
currentMillis = millis();

  {
if(Serial.available()  > 0){ // Checks whether data is comming from the serial port
    state = Serial.read();  // Reads the data from the serial port
    Serial.println(state);
}

//  Cocktails:


//Vodka sprite
if (state == 'a') {
  Serial.println("Vodka  Sprite in the making");

  Mix(3000,0,0,0,5000,0,0,0); // Vodka, Triple Sec,  Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin 
  
 }

//  Blue Lagoon
if (state == 'b') {
  Serial.println("Blue Lagoon in the making");

  Mix(2000,0,0,5000,1800,1000,1800,0); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin  
  
 }
  

// Cosmo
if (state  == 'c') {
  Serial.println("Cosmo in the making");

  Mix(2500,1500,3800,0,1200,1200,0,0);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
  
 }

// Lemon drop
if (state == 'd') {
  Serial.println("Lemon  drop in the making");

  Mix(1500,1500,0,0,1800,1200,0,0); // Vodka, Triple Sec,  Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
  
 }

//  Blue Moon
if (state == 'e') {
  Serial.println("Blue Moon in the making");

  Mix(2000,0,3000,0,1800,1200,1200,0); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin
  
 }

// Blue Gin Moon
if (state  == 'f') {
  Serial.println("Blue Gin Moon in the making");

  Mix(0,0,3000,0,1800,1200,1200,2000);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
  
 }

// Double Strike
if (state == 'i') {
  Serial.println("Double  Strike in the making");

  Mix(2000,0,3000,0,1800,0,1200,0); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
  
 }

//  Tom Collins
if (state == 'h') {
  Serial.println("Tom Collins in the making");

  Mix(0,0,0,4000,1800,1800,0,2200); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin
  
 }

// Flying Dutchman
if  (state == 'g') {
  Serial.println("Flying Dutchman in the making");

  Mix(0,2000,0,0,1200,1000,0,2000);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
  
 }

// London Cosmo
if (state == 'j') {
  Serial.println("London  Cosmo in the making");

  Mix(0,2000,5000,1800,0,0,0,2000); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
  
 }
    

// Vodka Cranberry 
if (state == 'k') {
  Serial.println("Vodka  Cranberry in the making");

  Mix(2000,0,5000,0,0,1200,0,0); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
  
 }

//  Cranberry Gin   
if (state == 'l') {
  Serial.println("Cranberry Gin in the  making");

  Mix(0,0,5000,0,2000,0,0,2200); // Vodka, Triple Sec, Cranberry juice,  Sprite, Lime juice, Sugar water, Blue Curacao, Gin
  
 }

// Testin and maintenance  options

// Set-up Vodka
if (state == 'm') {
  Serial.println("Set-up  Vodka");
  Mix(1100,0,0,0,0,0,0,0); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin
 }

// Set-up Tripple Sec
if  (state == 'n') {
  Serial.println("Set-up Tripple Sec");
  Mix(0,1100,0,0,0,0,0,0);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
 }

// Set-up Cranberry juice
if (state == 'o') {
  Serial.println("Set-up  Cranberry juice");
  Mix(0,0,1000,0,0,0,0,0); // Vodka, Triple Sec, Cranberry  juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
 }

// Set-up  Sprite
if (state == 'p') {
  Serial.println("Set-up Sprite");
  Mix(0,0,0,1000,0,0,0,0);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
 }

// Set-up Lime juice
if (state == 'q') {
  Serial.println("Set-up  Lime juice");
  Mix(0,0,0,0,1100,0,0,0); // Vodka, Triple Sec, Cranberry juice,  Sprite, Lime juice, Sugar water, Blue Curacao, Gin
 }

// Set-up Sugar  water
if (state == 'v') {
  Serial.println("Set-up Sugar water");
  Mix(0,0,0,0,0,1200,0,0);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
 }

// Set-up Blue curacao
if (state == 'r') {
  Serial.println("Set-up  Blue curacao");
  Mix(0,0,0,0,0,0,800,0); // Vodka, Triple Sec, Cranberry juice,  Sprite, Lime juice, Sugar water, Blue Curacao, Gin
 }

// Set-up Gin
if  (state == 's') {
  Serial.println("Set-up Gin");
  Mix(0,0,0,0,0,0,0,1000);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
 }

// Cleaning
if (state == 't') {
  Serial.println("Set-up  Gin");
  Mix(4000,4000,4000,4000,4000,4000,4000,4000); // Vodka, Triple Sec,  Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
 }

//  Set-up all (intial first time after cleaning)
if (state == 'u') {
  Serial.println("Set-up  All");
  Mix(800,800,800,800,1000,1600,800,800); // Vodka, Triple Sec, Cranberry  juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
 }
    
}

  int buttonConfirm_state = digitalRead(buttonConfirm_pin);
  int buttonLeft_state = digitalRead(buttonLeft_pin);
  int buttonRight_state = digitalRead(buttonRight_pin);

  

  if(buttonLeft_state == LOW){
    
    if(counter>0){
      counter = counter - 1;
      Serial.print(Cocktails[counter]);
      ScreenChange();
      delay(1000);
    }
  }

  if(buttonRight_state == LOW){
    
    if(counter<11){
      counter = counter + 1;
      Serial.print(Cocktails[counter]);
      ScreenChange();
      delay(1000);
    }
  }


  if(buttonConfirm_state == LOW){ //Cocktails:
    //Vodka sprite
    if (counter == 0) {
      Serial.println("Vodka  Sprite in the making");

      Mix(3000,0,0,0,5000,0,0,0); // Vodka, Triple Sec,  Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin 
      
    }

    //  Blue Lagoon
    if (counter == 1) {
      Serial.println("Blue Lagoon in the making");

      Mix(2000,0,0,5000,1800,1000,1800,0); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin  
      
    }
      

    // Cosmo
    if (counter  == 2) {
      Serial.println("Cosmo in the making");

      Mix(2500,1500,3800,0,1200,1200,0,0);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
      
    }

    // Lemon drop
    if (counter == 3) {
      Serial.println("Lemon  drop in the making");

      Mix(1500,1500,0,0,1800,1200,0,0); // Vodka, Triple Sec,  Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
      
    }

    //  Blue Moon
    if (counter == 4) {
      Serial.println("Blue Moon in the making");

      Mix(2000,0,3000,0,1800,1200,1200,0); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin
      
    }

    // Blue Gin Moon
    if (counter  == 5) {
      Serial.println("Blue Gin Moon in the making");

      Mix(0,0,3000,0,1800,1200,1200,2000);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
      
    }

    // Double Strike
    if (counter == 6) {
      Serial.println("Double  Strike in the making");

      Mix(2000,0,3000,0,1800,0,1200,0); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
      
    }

    //  Tom Collins
    if (counter == 7) {
      Serial.println("Tom Collins in the making");

      Mix(0,0,0,4000,1800,1800,0,2200); // Vodka, Triple Sec, Cranberry juice, Sprite,  Lime juice, Sugar water, Blue Curacao, Gin
      
    }

    // Flying Dutchman
    if  (counter == 8) {
      Serial.println("Flying Dutchman in the making");

      Mix(0,2000,0,0,1200,1000,0,2000);  // Vodka, Triple Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao,  Gin
      
    }

    // London Cosmo
    if (counter == 9) {
      Serial.println("London  Cosmo in the making");

      Mix(0,2000,5000,1800,0,0,0,2000); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
      
    }
        

    // Vodka Cranberry 
    if (counter == 10) {
      Serial.println("Vodka  Cranberry in the making");

      Mix(2000,0,5000,0,0,1200,0,0); // Vodka, Triple  Sec, Cranberry juice, Sprite, Lime juice, Sugar water, Blue Curacao, Gin
      
      
    }

    //  Cranberry Gin   
    if (counter == 11) {
      Serial.println("Cranberry Gin in the  making");

      Mix(0,0,5000,0,2000,0,0,2200); // Vodka, Triple Sec, Cranberry juice,  Sprite, Lime juice, Sugar water, Blue Curacao, Gin
      
    }
  }
}

void  Mix(int DelayTimeVodka, int DelayTimeCointreau, int DelayTimeCranberryJuice, int  DelayTimeSprite, int DelayTimeLemonJuice, int DelayTimeSugarWater, int DelayTimeBlueCur,  int DelayTimeGin ) {


  state = 0;
  delay(800);
  digitalWrite(Vodka,  LOW);   
  delay(DelayTimeVodka);            
  digitalWrite(Vodka, HIGH);  
  delay(TimeBetweenPours);  


  digitalWrite(Cointreau, LOW);   
  delay(DelayTimeCointreau);            
  digitalWrite(Cointreau, HIGH); 
  delay(TimeBetweenPours); 
 

  digitalWrite(CranberryJuice, LOW);   
  delay(DelayTimeCranberryJuice);            
  digitalWrite(CranberryJuice, HIGH); 
  delay(TimeBetweenPours);


  digitalWrite(Sprite, LOW);   
  delay(DelayTimeSprite);            
  digitalWrite(Sprite,  HIGH); 
  delay(TimeBetweenPours);

  
  digitalWrite(LemonJuice, LOW);   
  delay(DelayTimeLemonJuice);            
  digitalWrite(LemonJuice, HIGH);  
  delay(TimeBetweenPours); 


  digitalWrite(SugarWater, LOW);   
  delay(DelayTimeSugarWater);            
  digitalWrite(SugarWater, HIGH); 
  delay(TimeBetweenPours);  


  digitalWrite(BlueCur, LOW);   
  delay(DelayTimeBlueCur);            
  digitalWrite(BlueCur, HIGH); 
  delay(TimeBetweenPours);
 

  digitalWrite(Gin,  LOW);   
  delay(DelayTimeGin);            
  digitalWrite(Gin, HIGH); 
  delay(TimeBetweenPours); 



  Serial.println("Drink is done!"); 
  state = 0;
}

void ScreenChange(){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(Cocktails[counter]);
}


Just guessing... without seeing your program... that could be a symptom of lcd.write() when you meant to have lcd.print()

No , sadly that's not the problem. I use LCD.print()

How many guesses do I get without seeing your sketch?

You mean the code ?

No, the sketch. This is an Arduino forum.

edited the post. I really don't think it's the code since other code also had the same probem but try your luck. Appreciate the help :smile:

It looks like you are printing the address value of the characters. Try LCD.write();... but you will need to count through the elements of the array.

what do you mean with counting through ? cause now it shows nothing

Each drink is an array of characters. Cocktails[] is an array of arrays.

This works for me...

#include <LiquidCrystal_I2C.h>

char *Cocktails[] = {"zero one", "two three", "four five"};

#define I2C_ADDR    0x27
#define LCD_COLUMNS 16
#define LCD_LINES   2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);

void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print (Cocktails[1]);
  Serial.print(Cocktails[2]);
}

void loop() {
}

That doesn't look different to my code

Maybe it is the size of each element, or the number of elements? "char"is less than 8 not this

Turn your compiler errors to full send.

Same test sketch with your full list... works.

#include <LiquidCrystal_I2C.h>

char *Cocktails[] = {"Vodka Sprite", "Blue Lagoon", "Cosmo", "Lemon Drop", "Blue Moon", "Blue Gin Moon", "Double Strike", "Tom Collins", "Flying Dutchman", "London Cosmo", "Vodka Cranberry", "Cranberry Gin"};
int cocktails = sizeof(Cocktails)/sizeof(Cocktails[0]);

#define I2C_ADDR    0x27
#define LCD_COLUMNS 16
#define LCD_LINES   2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);

void setup() {
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  for (int i = 0; i < cocktails; i++) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.println(i);
    lcd.setCursor(0, 1);
    lcd.print (Cocktails[i]);
    Serial.print(i);
    Serial.print(" ");
    Serial.println(Cocktails[i]);
    delay(1000);
  }
}

void loop() {}

Well, It only happens after turning on the pumps sometimes not always when not turned on I don't have a problem. That's why I don't think it's the code

Sorry, I skipped that. Try to isolate the pump power (different power source), and maybe opto-isolate the pump data pin.

Possible EMI (Electromagnetic Interference) Issue

This sounds like it could be related to EMI, either conducted or radiated. While I can't confirm this is the problem without more information, your frizzy picture is not clear, I also can't rule it out. Most MOS logic circuits are fast and sensitive to edge transitions. Minimizing lead lengths (which act as antennas) to less than 10 inches (25 cm) is crucial, as longer leads can pick up frequencies up to about 750 MHz, not accounting for reflections and other effects.

Tips to Reduce EMI:

  1. Keep Connections Short: Both transmitters and receivers are affected by antenna length—longer antennas have greater gain and can pick up more interference. Use the KISS principle: Keep It Short & Simple.
  2. Avoid Parallel Lines: Ensure power and logic lines are not running parallel to each other to minimize crosstalk and interference.
  3. Use a Zero-Crossing Solid-State Relay: This can be a simple and effective solution to reduce EMI, especially when dealing with AC loads.

Historical Context: This issue has been known since the early 1960s with TCTL (Transistor-Coupled Transistor Logic), later known as TTL (Transistor-Transistor Logic). It prompted the development of line drivers and other technologies to manage EMI.

For further reading on related topics, check out these resources:

  • Triac Principles and Circuits, Part 1: Learn about triacs, which are often used in switching applications and can be susceptible to EMI.
    Read Part 1
  • Triac Principles and Circuits, Part 2: This article continues exploring triac applications and EMI considerations.
    Read Part 2
  • Arduino Forum Discussion on Flashing LEDs: An example of EMI considerations in a practical Arduino project.

To protect your electronics from electromagnetic interference (EMI). EMI can cause malfunctions or degradation in performance if not properly mitigated. Here are some approaches you can consider:

1. Shielding

  • Shielded cables: Use cables with shielding (like braided metal or foil wraps) to reduce the amount of EMI they emit or pick up.
  • Enclosures: Place sensitive electronics in metal or conductive enclosures (Faraday cages) to block external electromagnetic fields.

2. Grounding

  • Proper grounding: Ensure that all electronic components and their enclosures are properly grounded to prevent stray electromagnetic signals from affecting them. Grounding can direct EMI away from sensitive components.

3. Ferrite Beads

  • Ferrite beads: Install ferrite beads on cables that run to and from sensitive electronics. These components help suppress high-frequency EMI by dissipating it as heat.

4. Twisted Pair Cables

  • Twisted pair wiring: If you're running wires, use twisted pair cables for signal lines. The twisting helps cancel out EMI that would otherwise be picked up by the wires.

5. Capacitors and Filters

  • EMI filters: Install EMI filters (low-pass, high-pass, or band-stop) on power supply lines or signal lines to prevent high-frequency noise from reaching sensitive electronics.
  • Capacitors: Capacitors between power lines and ground can help smooth out high-frequency noise.

6. Distance from EMI Sources

  • Separation: Keep sensitive electronics as far away as possible from sources of EMI, such as motors, ignitions, and power cables.

7. Proper Cable Routing

  • Avoid running signal cables near power lines, ignition systems, or any high-current cables to reduce the possibility of picking up interference.

8. Use EMI-Resistant Components

  • Whenever possible, use components that are specifically designed to be resistant to EMI, such as EMI-hardened sensors, controllers, and processors.

9. Suppress Noise at the Source

  • Suppress ignition noise: Use resistor-type spark plugs or ignition leads with built-in suppression to reduce EMI from the bike’s engine and ignition system.
  • DC-DC converters: For bikes with electric systems, install noise-suppressed DC-DC converters to minimize EMI from power supplies.

Why By implementing a combination of these techniques, you can significantly reduce the impact of EMI on your bike’s electronics. If you need help with a specific part or scenario, feel free to provide more details!

Well I would like to use only one cable as power source that's why I have the converter but what is that Isolation you're talking about ? How would that work ?

See the EMI information above... A guy ( @Koepel ) who just stepped away from the forum said "do not trust pumps" (motors) as one of the top ten points of advice.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.