bridystone / SevSegShift

Seven segment display controller library for Arduino
MIT License
28 stars 8 forks source link

Issue with esp8266 #7

Open Brndyk opened 3 years ago

Brndyk commented 3 years ago

Hello, I use the same code (Of course I adjusted the pins) on my Arduino UNO and an esp8266 (nodemcu). On the Arduino I got the expected result but on the esp8266 I got nothing.

#include "SevSegShift.h"

#define SHIFT_PIN_DS   D0 
#define SHIFT_PIN_STCP D1
#define SHIFT_PIN_SHCP D2

SevSegShift sevseg(SHIFT_PIN_DS, SHIFT_PIN_SHCP, SHIFT_PIN_STCP); 

void setup() {
  byte numDigits = 8;
  byte digitPins[] = {11, 10, 9, 8, 15, 14, 13, 12};
  byte segmentPins[] = {0, 1, 2, 3, 4, 5, 6,  7};
  bool resistorsOnSegments = false;
  byte hardwareConfig = COMMON_ANODE;
  bool updateWithDelays = false;
  bool leadingZeros = false;
  bool disableDecPoint = false;

  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
  updateWithDelays, leadingZeros, disableDecPoint);
  sevseg.setBrightness(100);
}

void loop() {
  sevseg.setNumber(12345678);
  sevseg.refreshDisplay();
}
bridystone commented 3 years ago

Mhhhh… unfortunately I don’t have an esp at hand to check if it works. is the original sevseg library working with esp? This library merely adds a layer for shift registers, but uses the functionality of sevseg.

bridystone commented 3 years ago

as I understand it the SevSeg library is not intended for ESP. So the SevSegShift is also not working here.

RyanTheTechMan commented 3 years ago

@Brndyk I am running into the same issue with my ESP8266. I don't know too much about how shift registers work or even how to display numbers on the seven-segment display. Unfortunately, it doesn't look like this project will be able to work for the ESP8266 in its current state.

If any progress has been made please let me know. If there are sources I can learn the basics of how to display characters that would be good too.

foxblock commented 3 years ago

SevSeg and SevSegShift should both work on the ESP8266 and ESP32, they both don't do anything special that requires an Arduino hardware. I can confirm this, as I got SevSegShift working on the ESP32.

The problem is a different one, which I reported here: https://github.com/bridystone/SevSegShift/issues/9

As a quick fix, just move these two lines

  byte digitPins[] = {11, 10, 9, 8, 15, 14, 13, 12};
  byte segmentPins[] = {0, 1, 2, 3, 4, 5, 6,  7};

to the global scope (i.e. above the setup function). Then the program should work fine.

m-zarka commented 2 years ago

Hey ... thank you for this great library ... i used the library on ( Uno board ) with PNP transistors (BC327) as a switches for ( 1.8" seven segment 5v common anode ) ... so i defined the hardware to :

byte hardwareConfig = P_TRANSISTORS;

and the result was perfect ... so i decide to make same setup for " NTP clock " using ESP32 and shift register and pnp resistors from external power ( 5v ) and sure i gathered the GND's" i followed the previous instructions and raised up the flowing lines to global scope


  byte digitPins[] = {16, 5, 4, 15}; // These are the PINS of the ** ESP32 **
                    //D0, D1, D2, D8
  byte segmentPins[] = {0, 2, 4, 6, 7, 1, 3, 5}; // these are the PINs of the ** Shift register **

and its works BUT the display is showing digits so dim .... and even non used segments has some flow of electricity and turn on but so dim ....

My Schematic

i don't have experience in all of that ... its just Hobby and I hope your generosity to solve this problem for me

foxblock commented 2 years ago

I think the problem you are describing is a result of the ESP being 3,3V logic while the Arduino uses 5V Logic (i.e. all GPIO pins on the ESP only take 3,3V as HIGH input and emit 3,3V on HIGH output instead of 5V on the Arduino). 3,3V probably is not enough to fully close the transistor, See here: https://forum.arduino.cc/t/pnp-transistor-conducts-at-3-3v/578833/2 Also make sure you are connecting the right pins. You code uses pins 16, 5, 4 and 15 for the transistors, but I am pretty sure your schematic shows different pins connected. So just check that (it might be correct, I don't know the specific board you are using).

m-zarka commented 2 years ago

first of all i would to thank you for your gentle response ...

3,3V probably is not enough to fully close the transistor,

yes you are right, my problem is how to control current flow using PNP transistors as it drives the high side and its need a lot of focus on it and calculating to find a suitable formula ... i found there are nothing global setting ready for all application ( how smart am i 👎 ) so i will reconsider in my setup to find best solution depending on your nominated post wich you provided ... I will let you know the results when i will success ( i hope so ) ....

You code uses pins 16, 5, 4 and 15 for the transistors, but I am pretty sure your schematic shows different pins connected.

I meant d1,d2,d3,d4 as digit 1 and digit2 ... but i used 16, 5, 4 and 15 pins on board ... This is my fault, I should be more clear... Once again Thank you