• NFCWifiManager.h

    naz2 days ago 0 comments

    Have you noticed that WiFi signal icon seems to go up but NFC signals go sideways. Hmmmm.

    In this project, I brought over a NFC chip that I was using on another project and have had a working antenna and ST25DV onboard for quite some time. It was after the hardware was in place for a few boards that I ended up programming it. I struggled to find a use for the NFC when I initially placed it other than I had the schematic and it seemed like fun. NFC is a cool technology, I'd love to find other uses for it! Energy harvesting!

    Initially I programmed this with a react-native app, but I realized that there are a few apps out there that implement writing WiFi records to the app (because it's a standard! hooray! standards working!). I have not look into the Play Store, but I assume there should be a few of those apps out there.

    I used the ST NFC Tap app, and something is wrong with the way it writes WiFi records, so the NFC Tools app on iOS is the one of choice for me.

    https://apps.apple.com/us/app/nfc-tools/id1252962749

    Below is the source code for a part of the eink screen that I call the NFCWifiManager. The way it works is that it in your Arduino code, you delegate responsibility of the WiFi to the NFCWifiManager. From here, it exposes begin() that should be called from setup() and loop() which should be called from within your loop.

    The loop will check the NDEF records on the ST25 and see if there is a WiFi record. If it detects there is a WiFi record, it takes the SSID and password and starts connecting as well as storing the values to Preferences. It then replaces the NDEF record with a URL showing that it is connecting.

    The isWifiConnected() tells you if there is an active connection, and getMessage() gives you way to show to the user what the status is (it gets displayed on the e-ink screen when wifi is not connected).

    To configure the device, you open up NFC Tools and add a new record of WiFi, set the SSID and Password, and write it to the device. That's it! The next loop, the WiFi record will be picked up and connection will be attempted. If the connection fails to connect the device resets and forgets the WiFi password. You can comment that out (look for preferences.clear())

    Beyond that, there is also this concept of a "serverAddress" which is where the e-ink screen queries to get the display data, and so to configure that you can set a URL through the NFC device, and that will set the server address. So for example, when I'm giving these devices out, I can include a sticker QR code that has the address of the default server and then when you receive it, you open up NFC Tools and import the URL from the QR code. Or just type it in like http://192.168.1.71/ the NFCWifiManager respects protocol, because sometimes on our local network, we don't go through the hoops for https.

    The getServerAddress() returns the processed address and if you hover over the NFC antenna with your phone and you aren't transmitting, it reads a URL which is the server address + display.html with the device ID. This can be used as a way for the user to edit their content on the screen.

    So to close up, the workflow for a person connecting their device would look like:

    1> Plug in the device to power

    2> The screen says "Tap To Configure" so you install a NFC Tool app

    3> You write your WiFi Record from the NFC app to the device and the screen connects

    4> You change the default server to your home server by writing http://192.168.1.71/ to the device and now the screen displays your local server (e.g. https://codeberg.org/wsqnyc/eink_web_server)

    #include <Preferences.h>
    #include <ST25DVSensor.h>
    
    enum NFCWifiStatus {
      NFC_WIFI_STATUS_NOT_CONFIGURED,
      NFC_WIFI_STATUS_WIFI_FAILED,
      NFC_WIFI_STATUS_INVALID_SSID,
      NFC_WIFI_STATUS_WIFI_CONNECTING,
      NFC_WIFI_STATUS_WIFI_CONNECT_SUCCESS
    };
    
    class NFCWifiManager {
     public:
      NFCWifiManager();
      ST25DV st25dv;
      Preferences preferences;
      bool initialized = false;
      void begin();
      bool isWifiConnected...
    Read more »

  • stumbled onto ecologies.online

    naz3 days ago 0 comments

    If you haven't seen that website check it out https://ecologies.online/

    Anyways, got me thinking about the cloud and how I've had a Raspberry Pi Zero W tucked next to my modem for a few years now and I rarely think about it. Anyway, I got a Raspberry Pi 5 and wow I must say, I know the price went up, but the difference is sometimes how much JLCPCB DHL shipping costs, so .. I mean, definitely worth the cost. Took me only a few minutes to provision nodejs with nvm (it takes at least an hour on the Pi Zero just because node has to be built for it, but nvm install 20.12 on the Pi 5 and it has a prebuilt binary and happily installs!

    Also watched game 2 of the NBA finals and decided to capture the screen showing the live scores of the game (its actually ahead of what I get on my TV which is a different fun problem to consider) but throughout the regular season, I'd like to know if there's a close game on and the screen can highlight it. Or just show when the Knicks are playing, even if the suck. I'll take a second here and acknowledge that the Celtics are a great team. I mean wow. It was nice the Pacers took the win from the Knicks because the Celtics completely decimated them it was amazing.

    Right, so the code is here:

    https://codeberg.org/wsqnyc/eink_web_server/commit/e565346a0d77f76bcdf765fe7cc5774e12928a3c

    And what this is the e-ink screen that I have is doing is making a request to my Raspberry Pi to fetch the binary needed for the display. The binary is made from the screenshot of a web view that is the index.html that the Raspberry Pi spins up a "headless" Chrome to take a screenshot of. The index.html has a few things to ensure that the content is loaded before the screenshot is taken, for example waiting for all API calls to complete and the UI to update, images to load, etc. Without that code, the screenshot is taken too early and the clock isn't as functional. Another thing I was playing with was locale and timeZone, which is all built into the browser's Date object and overall something I enjoy not having to think about. It's cool to recognize everyone has their choice of metric or imperial, as well as how to write out the time and date!

    Added a quick NBA fetch, cached it for a minute in the server, and wrote a component that output that on the HTML page. I got the integration written during the half time commercial break! Super fun!

    Also take a look at the screen! I hope to post more files and code, but this is fun to play with, and it runs on my Raspberry Pi so I can refresh it a lot and I don't have to worry about cloud costs!

    Here's a video captured with my Adafruit Memento

    and then here's a video of my iPhone capturing the Adafruit Memento and the e-ink screen!

  • initial log entry

    naz4 days ago 0 comments

    I enjoy the hackaday.io community and seeing others have similar ideas to mine.

    These are the projects that seem similar to this project:

    They appear to integrate the 7.5 inch screen, and two of them use Chromium to run a web backend. I agree with dwuhls in that the web is easier to design and layout than it is in C++. And not just that, the ease of tinkering with the display is important to me (adjusting HTML&CSS is fun for my version of painting). Just looking at these numbers: Stackoverflow 2023 survey results show more than 50% of the respondents knew HTML/CSS/JavaScript while only 25% of the respondents knew C++.

    The other thing I'd like to contribute to this area is how to configure the WiFi. I've given my screens to people, and the first question is "how do I setup the WiFi" and for some people explaining how to edit the source code to change the WiFi is too much.

    To tackle that problem, and I wanted to integrate the NFC standard (specifically using a WiFi NDEF record) to use any mobile phone that has NFC capability (most do, especially if it has a digital wallet), and apps that implement the NDEF standard (there are a few on iOS). So the workflow becomes, plug in the screen, oh hey you need to setup WiFi, grab your phone and open up the NFC Tools app and add the WiFi record. This may be more involved than doing the "disconnect from your wifi and connect to the device WiFi, and then either go through the captive capture when connected or navigate to a specific 192.168.1.x address, and then type in your WiFi and save" sure we all have done this for all our devices, but why not try something new and use NFC to configure your WiFi!