Go Down

Topic: First time post, with compile questions and help (detailed) (Read 778 times) previous topic - next topic

JoeteckTips

Hello Arduino gurus,

I know nothing about Arduino. Going at this blindly. I truly envy you guys. This is some hard stuff.

I am looking to build a YouTube subscriber counter.

I have watched a very fasted paced tutorial video from www.educ8s.tv on how to create your very own YouTube subscriber counter display.

Not too offend anyone on this forum, as of right now I just do not have the time to understand the code and how it works. My Youtube channel needs me full time and learning a language is not in my cards right now. I hope you can understand. Perhaps later down the road.

I just need the program the ESP8266 D1 Mini and output to the 20x4 I2C LCD display.
These are the libraries I need. I believe I have added them successfully.  The top three are in red, not sure why.
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <LiquidCrystal_I2C.h>
#include <ArduinoJson.h>

If I get this working, I will give you a shout out in my Youtube video on who has helped me and direct everyone with a Arduino issue to come see ABC person(s). My channel is about reviews and how tos. I'm not trying to pass this off as my idea, but offer them a better tutorial making it easier for the beginner like myself.

Please tell me what I need to change or add to get this to work. Thank you.

JoeteckTips

---------------------------

Ok, the tutorial somewhat provided what I needed to do however it forgot to show you how to add the D1 mini into the arduino which I have done. I can see it in the list now. However when I try to compile and up load it to the 8266 it fails and gives me these errors. I have no idea what this all means

Any help would be wonderful. I will include the error and code so the debugging will be faster.

Also, do I need to have all the hardware connected before I program the device?


<begin error>

YoutubeSubscribers:115: error: 'POSITIVE' was not declared in this scope

 LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

                                                     ^

C:\Users\EDITING-JTT\Documents\Arduino\sketch_feb20a\YoutubeSubscribers\YoutubeSubscribers.ino: In function 'void setup()':

YoutubeSubscribers:122: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'

   lcd.begin(20,4);

                 ^

C:\Users\EDITING-JTT\Documents\Arduino\sketch_feb20a\YoutubeSubscribers\YoutubeSubscribers.ino:122:17: note: candidate is:

In file included from C:\Users\EDITING-JTT\Documents\Arduino\sketch_feb20a\YoutubeSubscribers\YoutubeSubscribers.ino:9:0:

C:\Users\EDITING-JTT\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: void LiquidCrystal_I2C::begin()

  void begin();

       ^

C:\Users\EDITING-JTT\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note:   candidate expects 0 arguments, 2 provided

Multiple libraries were found for "Wire.h"
 Used: C:\Users\EDITING-JTT\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\Wire
 Not used: C:\Users\EDITING-JTT\Documents\Arduino\libraries\Wire-master
exit status 1
'POSITIVE' was not declared in this scope

<end error>





 

ieee488


6v6gt

I guess that for the Liquid Crystal library, you have found example code which don't match the exact library you have downloaded.

Does your LCD display have an I2C backpack ?


gfvalvo

Post this in the Gigs and Collaboration forum.
Gigs and Collaborations
There you will need to negotiate an mutually agreeably payment for someone's services.


robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

JoeteckTips

If you wish to help out of the goodness of your heart, that would be great.

Thanks.


JoeteckTips

I get this error message now


Archiving built core (caching) in: C:\Users\EDITIN~1\AppData\Local\Temp\arduino_cache_436148\core\core_esp8266_esp8266_d1_mini_CpuFrequency_80,FlashSize_4M1M,LwIPVariant_v2mss536,Debug_Disabled,DebugLevel_None____,UploadSpeed_921600_a590c4fc365d9aab9d346add5c9c12f6.a
Sketch uses 328887 bytes (31%) of program storage space. Maximum is 1044464 bytes.
Global variables use 36504 bytes (44%) of dynamic memory, leaving 45416 bytes for local variables. Maximum is 81920 bytes.
error: Failed to open COM1
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

pert

Select the port of your D1 Mini from the Tools > Port menu. If that menu is grayed out or the port of your Arduino board is not shown then one of the following may be the cause:
  • You may need to install the driver for the USB-serial chip on your Arduino. Determine which chip is used on your Arduino and install the driver.
  • You may be using a charge-only or defective USB cable. Test your cable on another device to confirm that it works for data.
  • Using a USB 3.0 port on your computer may cause problems. Try a USB 2.0 port or use a USB 2.0 hub plugged into your USB 3.0 port.

JoeteckTips

Select the port of your D1 Mini from the Tools > Port menu. If that menu is grayed out or the port of your Arduino board is not shown then one of the following may be the cause:
  • You may need to install the driver for the USB-serial chip on your Arduino. Determine which chip is used on your Arduino and install the driver.
  • You may be using a charge-only or defective USB cable. Test your cable on another device to confirm that it works for data.
  • Using a USB 3.0 port on your computer may cause problems. Try a USB 2.0 port or use a USB 2.0 hub plugged into your USB 3.0 port.

It comes up in device manager as USB-SERIAL CH340 (COM1)

pert

OK, you have it right then. COM1 is the default port selection of the Arduino IDE but usually the Arduino board's port will be enumerated to something else so when there's an upload problem and the port is set to COM1 the problem is usually simply that they never selected the Arduino's port.

JoeteckTips

I think I may have a bad 20x4 LCD board. It has power, but it never powers on. I've tried a bunch of stuff. I even ran the a program to see if can see it and it can. Its at address 0x3f. I'm at a huge loss, because I have no idea what I'm doing and I have no idea what I am looking at to know if its right or wrong.

Nothing is compiling correctly. I need someone who can remote in and fix everything.

it will take months before forum posts will help.

JoeteckTips

Can anyone else get this code to work? if it does, then I have faulty equipment.




//////////////////////////////////////////////
  //   20x4 Subscriber Counter for YouTube    //
 //                                          //
//           http://www.educ8s.tv           //
/////////////////////////////////////////////

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <LiquidCrystal_I2C.h>
#include <ArduinoJson.h>

byte LT[8] =
{
  B01111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111
};

byte UB[8] =
{
  B11111, 
  B11111, 
  B11111, 
  B00000, 
  B00000, 
  B00000, 
  B00000, 
  B00000
};
byte RT[8] =
{
  B11110, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111
};

byte LL[8] =
{
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B01111
};

byte LB[8] =
{
  B00000, 
  B00000, 
  B00000, 
  B00000, 
  B00000, 
  B11111, 
  B11111, 
  B11111
};

byte LR[8] =
{
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11111, 
  B11110
};

byte UMB[8] =
{
  B11111, 
  B11111, 
  B11111, 
  B00000, 
  B00000, 
  B00000, 
  B11111, 
  B11111
};

byte LMB[8] =
{
  B11111, 
  B00000, 
  B00000, 
  B00000, 
  B00000, 
  B11111, 
  B11111, 
  B11111
};

const char* ssid     = "";       // SSID of local network
const char* password = "";   // Password on network
String apiKey = "";            // YouTube Data API v3 key generated here: // https://console.developers.google.com
String channelId = "";   // YouTube channel id

const char *host = "www.googleapis.com";
long subscribers,subscribersBefore = 0;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

void setup() 
{
  Serial.begin(9600);
  int cursorPosition=0;

  lcd.begin(20,4);
  lcd.setCursor(0,0);
  lcd.print("Connecting ....");

  createCustomChars();
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    lcd.setCursor(cursorPosition,1);
    lcd.print(".");
    cursorPosition++;
  }
 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Connected to JoeteckTips!");
  delay(1000);
}

void loop()
{
  int length;
  String subscribersString = String(getSubscribers());
  if(subscribers != subscribersBefore)
  {
    lcd.clear();
    length = subscribersString.length();
    printSubscribers(length,subscribersString);
    subscribersBefore = subscribers;
  } 
  delay(60000);
}

void printSubscribers(int length, String subscribersString)
{
  switch(length)
  {
    case 5: printDigits(subscribersString,5);printDigits(subscribersString,4);printDigits(subscribersString,3);printDigits(subscribersString,2);printDigits(subscribersString,1);break;
    case 4: printDigits(subscribersString,4);printDigits(subscribersString,3);printDigits(subscribersString,2);printDigits(subscribersString,1);break;
    case 3: printDigits(subscribersString,3);printDigits(subscribersString,2);printDigits(subscribersString,1);break;
    case 2: printDigits(subscribersString,2);printDigits(subscribersString,1);break;
    case 1: printDigits(subscribersString,1);break;
    default: break;
  }
}

void printDigits(String subscribersString,int digit)
{
  int length = subscribersString.length();
  char digitToPrint = subscribersString.charAt(length-digit);
  Serial.println(digitToPrint);
  switch(digit)
  {
    case 1: printDigitToScreen(digitToPrint,17); break;
    case 2: printDigitToScreen(digitToPrint,13); break;
    case 3: printDigitToScreen(digitToPrint,9); break;
    case 4: printDigitToScreen(digitToPrint,5); break;
    case 5: printDigitToScreen(digitToPrint,1); break;
  }
}

void printDigitToScreen(char digit,int position)
{
  int digitToPrint = digit - '0'; //Convertion from char to int
  switch(digitToPrint)
  {
    case 1:digit1(position); break;
    case 2:digit2(position); break;
    case 3:digit3(position); break;
    case 4:digit4(position); break;
    case 5:digit5(position); break;
    case 6:digit6(position); break;
    case 7:digit7(position); break;
    case 8:digit8(position); break;
    case 9:digit9(position); break;   
    case 0:digit0(position); break;   
  }
}

void digit0(int position_x)
{
  lcd.setCursor(position_x, 1);
  lcd.write((byte)0); 
  lcd.write(1);
  lcd.write(2);
  lcd.setCursor(position_x, 2);
  lcd.write(3); 
  lcd.write(4); 
  lcd.write(5);
}

void digit1(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write(1);
  lcd.write(2);
  lcd.setCursor(position_x+1,2);
  lcd.write(5);
}

void digit2(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write(6);
  lcd.write(6);
  lcd.write(2);
  lcd.setCursor(position_x, 2);
  lcd.write(3);
  lcd.write(7);
  lcd.write(7);
}

void digit3(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write(6);
  lcd.write(6);
  lcd.write(2);
  lcd.setCursor(position_x,2);
  lcd.write(7);
  lcd.write(7);
  lcd.write(5);
}

void digit4(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write(3);
  lcd.write(4);
  lcd.write(2);
  lcd.setCursor(position_x+2,2);
  lcd.write(5);
}

void digit5(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write((byte)0);
  lcd.write(6);
  lcd.write(6);
  lcd.setCursor(position_x,2);
  lcd.write(7);
  lcd.write(7);
  lcd.write(5);
}

void digit6(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write((byte)0);
  lcd.write(6);
  lcd.write(6);
  lcd.setCursor(position_x,2);
  lcd.write(3);
  lcd.write(7);
  lcd.write(5);
}

void digit7(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write(1);
  lcd.write(1);
  lcd.write(2);
  lcd.setCursor(position_x+1,2);
  lcd.write((byte)0);
}

void digit8(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write((byte)0);
  lcd.write((byte)6);
  lcd.write(2);
  lcd.setCursor(position_x,2);
  lcd.write(3);
  lcd.write(7);
  lcd.write(5);
}

void digit9(int position_x)
{
  lcd.setCursor(position_x,1);
  lcd.write((byte)0);
  lcd.write((byte)6);
  lcd.write((byte)2);
  lcd.setCursor(position_x+2,2);
  lcd.write((byte)5);
}

int getSubscribers()
{
  WiFiClientSecure client;
  Serial.print("connecting to "); Serial.println(host);
  if (!client.connect(host, 443)) {
    Serial.println("connection failed");
    return -1;
  }
  String cmd = String("GET /youtube/v3/channels?part=statistics&id=") + channelId + "&key=" + apiKey+ " HTTP/1.1\r\n" +
                "Host: " + host + "\r\nUser-Agent: ESP8266/1.1\r\nConnection: close\r\n\r\n";
  client.print(cmd);

  int repeatCounter = 10;
  while (!client.available() && repeatCounter--) {
    delay(500);
  }
  String line,buf="";
  int startJson=0;
 
  while (client.connected() && client.available()) {
    line = client.readStringUntil('\n');
    if(line[0]=='{') startJson=1;
    if(startJson)
    {
      for(int i=0;i<line.length();i++)
        if(line=='[' || line==']') line=' ';
      buf+=line+"\n";
    }
  }
  client.stop();

  DynamicJsonBuffer jsonBuf;
  JsonObject &root = jsonBuf.parseObject(buf);
  if (!root.success()) {
    Serial.println("parseObject() failed");
    delay(10);
    return -1;
  }
 
  subscribers = root["items"]["statistics"]["subscriberCount"];
  Serial.println(subscribers);
  return subscribers;
}

void createCustomChars()
{
  lcd.createChar(0,LT);
  lcd.createChar(1,UB);
  lcd.createChar(2,RT);
  lcd.createChar(3,LL);
  lcd.createChar(4,LB);
  lcd.createChar(5,LR);
  lcd.createChar(6,UMB);
  lcd.createChar(7,LMB);
}


JoeteckTips

Since open source libraries change on a regular basis, there is no clear cut answer in what to use. Learning the Arduino is very difficult. Plus VERY frustrating for someone who wants to learn this stuff.

So many different versions of libraries. I am not sure why there isn't any standardization. This hardware; use this library. Its 100% guess work and it shouldn't be any guessing on what library to use.

Truly not an end user friendly hobby.

I have abandoned the project and will be returning all of the defective equipment back to Amazon.

I have given up.




Go Up