logo elektroda
logo elektroda
X
logo elektroda

Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780

nowy.zielony.pczątku 2724 26
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18251225
    nowy.zielony.pczątku
    Level 5  
    Hello, I would like to make a cryptocurrency course display based on WeMos D1 R2 ESP8266 and LCD 2004 4*20 I2C. I am a beginner about arduino and need help to adapt the code from oled to lcd. The display would display 2 currencies BTC/PLN(first line) and BCH /PLN(second line). The api would download from bitbay.net Here is the code:
    Code: C / C++
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #3 18252056
    nowy.zielony.pczątku
    Level 5  
    I found another code for just LCD and it works, only now I have a problem setting up the bitbay.net API
    Original code:
    Code: C / C++
    Log in, to see the code
    .


    The code after my change displays "BTC/PLN: 1.0".Please don't scoff, I don't know the programming language. I do by trial and error method using and comparing codes.

    Code: C / C++
    Log in, to see the code
    .
  • #4 18254745
    Anonymous
    Level 1  
  • #5 18255351
    nowy.zielony.pczątku
    Level 5  
    nowy.zielony.pczątku wrote:
    Code: C / C++
    Log in, to see the code
    .
    nowy.zielony.pczątku wrote:
    Code: C / C++
    Log in, to see the code
    .
    nowy.zielony.pczątku wrote:
    Code: C / C++
    Log in, to see the code
    .
    .

    And I changed it to as above. It displays "BTC/PLN: 0.00"
  • #6 18260623
    Anonymous
    Level 1  
  • #7 18260737
    nowy.zielony.pczątku
    Level 5  
    Originally there was
    nowy.zielony.pczątku wrote:
    const char* host = "api.coindesk.com";
    and there is
    nowy.zielony.pczątku wrote:
    const char* host = "bitbay.net";
    There was
    nowy.zielony.pczątku wrote:
    String url = "/v1/bpi/currentprice.json";
    and it is
    nowy.zielony.pczątku wrote:
    String url = "/API/Public/BTCPLN/ticker.json";
    .
    The full API address is: bitbay.net/API/Public/BTCPLN/ticker.json
  • ADVERTISEMENT
  • Helpful post
    #8 18266789
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #9 18269427
    nowy.zielony.pczątku
    Level 5  
    @khoam your code worked :D Except that another problem has occurred. The arduino reboots every now and then after showing the IP or after showing the course, this is the first problem, is this indicative of a faulty arduino? The second is that after connecting to the local internet it crashes on showing the IP address and does nothing further (the problem does not occur when connecting to the internet from the phone).
    Code: C / C++
    Log in, to see the code
    .
  • #10 18269450
    Anonymous
    Level 1  
  • #11 18269714
    nowy.zielony.pczątku
    Level 5  
    khoam wrote:
    I tested the program for several tens of minutes, but without the LCD display. There were no reboots. Try testing my version of the program from post #8 and write if there are reboots too. If there are none, then the problem may lie, somewhere in the handling of the display.
    .
    It displays such bushes:
    [code]
    Code: Bash
    Log in, to see the code
    .
    Am I doing something wrong? Because the idea is to see the register about here when the arduino turns on and after waiting a while, yes?
    Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780 .

    khoam wrote:
    Do you power the LCD module from +5V?
    .
    Well yes I have connected to +5V
    khoam wrote:
    If so, did you forget the level converters on the I2C bus between the Wemos and the display?
    .
    What is this?
    I would add that other code e.g. for displaying "hello world", works fine. It does not reboot.
  • #12 18269755
    Anonymous
    Level 1  
  • #13 18269896
    nowy.zielony.pczątku
    Level 5  
    Ok, so your @khoam code from post #8 on the serial port shows the course correctly and connects to the internet from the phone. When connecting to the home internet, it happens as you thought i.e. it stands on showing the IP and every now and then it prints "No connection to bitbay.net". Probably blocking something on the network (network in DHCP mode if that matters).

    After uploading the code from post #9 the arduino restarts and on the serial port it displays this at once:
    [code]
    Code: Bash
    Log in, to see the code
    .
  • #14 18269947
    Anonymous
    Level 1  
  • #15 18269979
    nowy.zielony.pczątku
    Level 5  
    The ESP8266 version is: 2.6.0
    The version of the ArduinoJson library is: 6.13.0
  • Helpful post
    #16 18270175
    Anonymous
    Level 1  
  • #17 18272184
    nowy.zielony.pczątku
    Level 5  
    @khoam Huge thanks for your help. The course display is working :D The final hurdle is the home network which I don't want to work with. I should add that I have eset antivirus which supposedly blocks something there but after unblocking it still the same.
    Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780 .
    Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780 .
  • Helpful post
    #18 18452278
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #19 18465384
    nowy.zielony.pczątku
    Level 5  
    The project is complete, so I am closing the topic. The project wouldn't really have happened if it wasn't for the help of khoam once again huge thanks. The certificate that khoam writes about can be found on the Firefox browser according to the instructions in the attachment under the name Certificate. I have also designed an enclosure for this project, of course it can be used for another project that uses a wemos r1 d2 and a 4x20 LCD display (note before printing please measure the distances of the slots in the wemos, I modelled the dimensions on ready-made enclosures for wemos and the dimensions did not match reality). The code may appear to be "pooled" (these are my inserts not khoam's) but it works and does the job. The whole project can be downloaded at this link: https://drive.google.com/open?id=1qeVcJkwW3P7SMQERinYGUtUpMU9ug-X7

    Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780 .
  • #20 18487493
    nowy.zielony.pczątku
    Level 5  
    There are two things to be improved/revised. One as the khoam himself pointed out that it would be useful for authentication from bitbay to be via a CA certificate rather than a fingerprint. I've tried to implement this but it's not my level, I've only just started with arduino. Where do I get something like the picture from? How do you do it? The other thing is that I would like the display backlight to turn on when I "wave" my hand, and it works, but the problem is that there are delays and other functions that delay. Do you have to use esp32 or is it enough to improve the code somehow? I tried to solve this problem with the millis() function but was unsuccessful.

    Course display on WeMos WiFi D1 R2 ESP8266 and LCD 2004 4*20 I2C Yellow HD44780 .

    Code: C / C++
    Log in, to see the code
  • #21 18487643
    Anonymous
    Level 1  
  • #22 18518471
    nowy.zielony.pczątku
    Level 5  
    khoam wrote:
    Maybe a better solution to start with would be to retrieve this data without validating the site certificate or fingerprint. The main change is to replace the following line of code:
    Code: c Expand Select all
    client.setFingerprint(fingerprint);
    By the following:
    Code: c Expand Select All

    client.setInsecure();
    Check if this will work with the "api.bitbay.net" website.


    The change works with api.bitbay.net.
    khoam wrote:
    new.green.start wrote:
    The other thing is I'd like the display backlight to turn on when the hand is "swiped", and that works only problem is there are delay-e and other fuctions that delay.

    I understand that on any of the ports the logic state changes due to a "swipe" of the hand? If so, the easiest way would be to connect an interrupt to that pin and set the display to brighten up in the interrupt handler - then it would happen immediately regardless of the delays in loop(). Turning off the backlight would have to happen already in loop() after the specified time.
    https://randomnerdtutorials.com/interrupts-timers-esp8266-arduino-ide-nodemcu/
    https://arduino-esp8266.readthedocs.io/en/latest/reference.html#interrupts
    .

    Well, not really because the switching would have to take place in a given range of e.g. 10-25 cm and the state changes every now and then. I bought an esp32 to solve this problem. To be precise, on one core would be added a watch and measuring the distance and on the other core would be added downloading data from api.bitbay.net. I uploaded such test code and the board keeps rebooting. Also, did I insert the future tasks well in the brackets "for (;;) "?

    Code: C / C++
    Log in, to see the code
    .
    Register during reboot

    Code: Bash
    Log in, to see the code
  • #23 18518691
    Anonymous
    Level 1  
  • #24 18523151
    nowy.zielony.pczątku
    Level 5  
    The cause turned out to be a limey usb hub. And again, another obstacle. I copied the code from esp8266 to esp32 and errors are popping up. With the added
    Code: C / C++
    Log in, to see the code
    .
    displays: 'class WiFiClientSecure' has no member named 'setInsecure'.
    with added
    Code: C / C++
    Log in, to see the code
    .
    displays: 'client' was not declared in this scope

    Moving this task to a void loop changes nothing.

    Removing one and the other causes this error to be displayed:
    Code: Bash
    Log in, to see the code
    .

    Code: C / C++
    Log in, to see the code
    .
  • #25 18523294
    Anonymous
    Level 1  
  • #26 18555772
    JanuszKornas
    Level 11  
    nowy.zielony.pczątku wrote:
    Does esp32 need to be used or is it enough to tweak the code somehow? I tried to solve this problem with the millis() function but failed.
    .
    Once you understand this code, you will grasp what you want and be able to do not such things....
    Link

    In general, the principle of using millis() instead of delay() is that the processor will fly through the loop as fast as the clock allows it to, and it will only perform your task (LED state change or whatever) when the time comes. This is a different way of solving your probem than interrupts.

    Interrupts are useful for the program's response to the user. The user is usually impatient and would like his events to be handled immediately. So, in the interrupts you change the state of some variable (the motion detector has detected movement), and in the main loop you react to such a change and determine in how much time it should e.g. turn off the backlight (you read the time with the help of millis() ).

    In the loop you execute functions that change states of variables (and also in interrupts), and then further in the loop you execute functions that execute something if some variable says so, or e.g. the time has come.

    You can, of course, use ready-made libraries for this, but if you do not implement such simple "multitasking" yourself, at least once, you will not understand how such libraries work.
  • #27 18556015
    Anonymous
    Level 1  

Topic summary

A user sought assistance in adapting code for a cryptocurrency course display using a WeMos D1 R2 ESP8266 and an LCD 2004 I2C. The initial code was designed for an OLED display and needed modifications to work with the LCD. The display was intended to show BTC/PLN and BCH/PLN prices sourced from the Bitbay API. Various responses provided guidance on modifying the code, including changing the API URL and addressing issues with the display and network connectivity. The user encountered reboots and connection problems, which were resolved by downgrading the ESP8266 board version and adjusting the code. The project was completed successfully, with suggestions for further improvements, such as using a CA certificate for authentication and implementing a hand-swipe feature for backlight control.
Summary generated by the language model.
ADVERTISEMENT