Tag Archives: hardware

Arduino with Huskylens detecting learned face

Arduino Uno with Husky Lens using I2C

The HuskyLens is an easy-to-use AI machine vision sensor. It is equipped with multiple functions such as:

  • Face recognition
  • Object tracking
  • Object recognition
  • Line trace
  • Color recognition
  • Tag recognition (QR code).

Via the UART / I2C port you can among others: boards connect:

  • Arduino
  • micro:bit
  • Raspberry Pi

Steps to take: Press Face detection, when a cross in a square is displayed, press the button on your HuskyLens

Set your husky protocol to I2C in the settings.

Minimal Code needed

/***************************************************
 HUSKYLENS An Easy-to-use AI Machine Vision Sensor
 <https://www.dfrobot.com/product-1922.html> 
****************************************************/

#include "HUSKYLENS.h"

HUSKYLENS huskylens;
//HUSKYLENS green line >> SDA; blue line >> SCL
int ID0 = 0; //not learned results. Grey result on HUSKYLENS screen
int ID1 = 1; //first learned results. colored result on HUSKYLENS screen
int ID2 = 2; //second learned results. colored result on HUSKYLENS screen
// and so on.....

int arjprevious = 0;
void printResult(HUSKYLENSResult result);
void setup() {
    Serial.begin(115200);
    Wire.begin();
    while (!huskylens.begin(Wire))
    {
        Serial.println(F("Begin failed!"));
        Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protocol Type>>I2C)"));
        Serial.println(F("2.Please recheck the connection."));
        delay(100);
    }
    
     huskylens.writeAlgorithm(ALGORITHM_FACE_RECOGNITION);
}

void loop() {
   if (huskylens.requestLearned())          //request blocks and arrows tangged ID != 0 from HUSKYLENS
   if (huskylens.requestBlocksLearned())    //request blocks tangged ID != ID0 from HUSKYLENS

    {
        for (int i = 0; i < huskylens.countArrows(ID0); i++)
        {
            HUSKYLENSResult result = huskylens.getArrow(ID0, i);  
        }
        int arj = huskylens.count(ID1);
        if ( arj != arjprevious )
        {
        if ( arj == 1 )
            {
            Serial.println("Learned face detected");
            }
            else
            {
            Serial.println("Learned face not detected");
            }
            arjprevious = arj;
        }
    }
    else
    {
        Serial.println("Fail to request objects from Huskylens!");
    }
}
Learned face detected ID1
Learned face not detected
Learned face detected ID1
Learned face not detected
Learned face detected ID1
Learned face not detected

Raspberry PI and Arduino black hole

This is NOT a post about the pi-hole project. Of which I apparantly never posted my setup.

I needed an extra PI for a project, and I always try to keep one spare.
But they are always gone, in use, missing .. whatever.

So I can´t work on this project right now, so lets rant about disappearing stuff

Like they are being sucked up in another dimension .. gone. WHERE ARE THEY?!?

How to keep track of them?

Any suggestions?


I used to have a sheet, but I often forget to keep track.
Do I use a MAC address scan on my switches?
First 3 parts of the Mac address are vendor specific.

So far i’ve found : Octopi, Beerbrew computer, Retro Arcade, Picore, Nodered, Domoticz 433toMqtt, Ledserver, Lasercutter-etch-a-sketch, mobile LMS music server, Pressure Lab AP, Escape Game AP (3 of them), one unused Raspberry zero (without Wifi), One at my old work, one broke, Kodi+Netflix,Ansible project, found another one .. Jumanji/Dashticz/NoderedDashboard demo (with screen)
WHERE THE F are the rest of them?
(Sdcards with temporary projects on them 29, I need to combine project on those cards. I’ve got a 64Gb card holding a Rpi OS and only a 1K python script!)

And Arduino’s are even worse … they are all over the place.
Those are probably 100+
(ESP32, 8266, Nano’s, Mega, M5Stack and alikes)

I know i have many temporary projects, but I keep most things organized in my projects containers.

One of the rows with Ikea containers, a few for bigger projects and now i’m using the plastic boxes you get when you order chinese or thai.

OpenPLC editor with Raspberry and Arduino

Here I’m going to post my tests with OpenPLC.

UPDATE 20231012 202301015

It’s a long time i’ve made a PLC ladder, but lets see how and what this integration brings me.

OpenPLC interface on a Raspberry, I could not start a program on RPI 5!
But it compiled correctly. See below rpi3
Schematic with a led and two buttons (and one floating in the middel, which i forgot to remove)
Working example ( wemos and display are from another project those are not connected )

UPDATE 20231015 – Raspberry 3 with OpenPLC

GND to leds and buttons
GPIO2 (pin 3) to a button
GPIO3 (pin 5) to another button
GPIO14 (pin 8) to the led

Now OpenPLC works correct (RPI3)

https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3
./install.sh rpi 

## Warning .. takes a really long time

Wiringpi is deprecated
But can be installed using the last git repo

git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi
./build

Flute note detection with leds

Yesterday I got my MAX9814 in, last night I got it working.
Used the leds from a lightpainter project to test controlling the leds.

Why is it, that it doesn’t matter how much components and ledstrips you buy, you alway need more.

First parts of the Scale, then a part of Farewell to Uist

Arduino Nano, using FastLeds library and FFT.
Ledstrip is WS2812, and the MAX8914 microphone

Busy day: PHP, Python, RP2040 and Frequency detection.

While watching a online python course, I was writing the code for a music guessing game (Highland Bagpipe Tunes)
The core is working, now it’s a matter of filling this “pruts” with tunes.

Switching between python, php, bash and C is a nightmare 🙂

A screenshot of work in progress

Then the postman came .. with goodies.
I needed the MAX9814 analog microphone with amplifier, all of my other sensors were not up to the task.

So I switched to this WIP with the MAX9814.
I want to make a little gadget using an Arduino and 9 leds, which uses FFT to blink which note I am playing on my Highland Pipes.

So detecting is working, now I have to attach a bunch of leds.

First test using Arduino Cloud (I still prefer PlatformIO) But this is better than the old IDE. (Note, you have to install an agent to connect your browser to a board)

Next thing I did today:
Getting my waveshare RP-2040 Zero working with micropython.

Great the little NeoPixel Led on the board.

Steps to get this working:

  • Install Thonny
  • Connect the rp2040 via USB with the boot button pressed
  • place RPI_pico.xxxx.uf2 on the mounted usb disk, it will reboot
  • Run Thonny connect and run a test program

Want to run program @boot ?
save -> to device, and call main.py

Copperbar effect with image on 80×86

I’m still having problems getting a working floppy drive in my machine.
(Broken FDD card, drive errors etc)

The raster bar (also referred to as rasterbar or copperbar) is an effect used in demos and older video games that displays animated bars of colour, usually horizontal, which additionally might extend into the border, a.k.a. the otherwise unalterable area (assuming no overscan) of the display

When you look at the left side of the screen you see the color bar in the border (outside the normal pixel screen)

I first tried to get it working in DosBOX, but thats a mess.
Good for simple emulation but not hardcore register manipulation.

Below dosbox

Three examples below are in PCem

Not waiting for vsync, gives some idea how much timing is left when doing bars
Other effect added
Effect as on the real hardware except emulated using PCeM
use16
org 0x100

CRTC_INDEX = 0x03D4
CRTC_DATA = 0x03D5
INPUT_STATUS = 0x03DA
MAXIMUM_SCAN_LINE = 0x09
LINE_OFFSET = 0x13

jmp start

updown DB 30
direction DB 0
filename DB "shoes.bmp",0

start:
; set mode 320x200 256 colors palette
        mov ah,0x0
        mov al,13h
        int 10h

; clear screen routine, not really needed
clearscreen:
        push ax
        mov ax, 0a000h
        mov es, ax
        pop ax
        xor di, di
        inc ax
        mov cx, 64000 ; 320x200
        rep stosb

; call file loader
        call Loadfile

        push cs
        pop ds

; after displaying the image or displaying an error, wait for keypress to exit
waitforkeyloop:
        call effect     ; Calling the effect
        MOV AH,1
        INT 16h
        JZ waitforkeyloop
        XOR AH,AH
        INT 16h
Exit:
        MOV AX,3        ; default text mode 3
        INT 10h
        MOV AX,4C00h    ; exit to dos (terminate process)
        INT 21h

Loadfile:
        MOV DX,filename
        MOV AX,3D00h    ; open filehandle
        INT 21h
        JC Err1
        MOV BX,AX       ; filehandle
        MOV CX,0FFFFh   ; size
        mov dx,0a000h   ; destination 0000:a000h - Screen memory
        mov ds,dx

        MOV DX,0
        MOV AH,3Fh      ; read from file
        INT 21h
        JC  Err1
        MOV AH,3Eh      ; close filehandle
        INT 21h

        RET
; print error
Err1:
        push cs         ; make ds same as cs
        pop ds
        MOV DX,TxtErr1  ; error
        MOV AH,09h
        INT 21h
        RET

effect:
        cli             ; stop interrupts
        call waitvretrace       ; wait for vertical retrace
        mov al, 0    ; set color index 0 to black (needs to be converted to a function
        mov dx, 3c8h
        out dx, al
        inc dx       ; now 3c9h
        mov al, 0h
        out dx, al   ; set R = 0
        mov al, 0h
        out dx, al   ; set G = 0
        mov al, 0h
        out dx, al   ; set B = 0

; gets start scanline and direction
        mov al,[updown]
        mov ah,[direction]
        cmp ah,0
        jz      addcounter
        dec al
        cmp al,30
        jnz gohere
        mov ah,0
        mov [direction],ah
        jmp gohere
addcounter:
        inc al
        cmp al,100
        jnz gohere
        mov ah,1
        mov [direction],ah
gohere:
        mov [updown],al

; al = scanline, call wait for scanline
        call waithretrace
        mov al, 0    ; set color index 0 to blueish
        mov dx, 3c8h
        out dx, al
        inc dx
        mov al, 11h
        out dx, al
        mov al, 22h
        out dx, al
        mov al, 33h
        out dx, al
; wait 10 scanlines (height of bar)
        mov al,10
        call waithretrace

; draw black again
        mov al, 0    ; set color index 0's rgb value
        mov dx, 3c8h
        out dx, al
        inc dx       ; now 3c9h
        mov al, 0
        out dx, al   ; set R = 11h
        mov al, 0h
        out dx, al   ; set G = 22h
        mov al, 0h
        out dx, al   ; set B = 33h

        sti     ; start interrupts again
        ret

; this waits for vertical retrace
waitvretrace:
        mov dx,INPUT_STATUS
waitv1:
        in al,dx
        test al,8
        jnz waitv1
waitv2:
        in al,dx
        test al,8
        jz waitv2
        ret

; routine that waits for horizontal retrace
waithretrace:
        mov cl,al
        mov dx,INPUT_STATUS
waith1:
        in al,dx
        test al,1
        jnz waith1
waith2:
        in al,dx
        test al,1
        jz waith2
        dec cl
        cmp cl,0
        jnz waith1
        ret

TxtErr1 DB "shoes.bmp not found!",7,10,13,"$"

Mikrotik Wifi, 80386 and Lilygo streaming

Quiet days, I working on some art.

But here are the last ‘prutsen’

My current Wifi setup

I’ve got a Wifi outside of my network for guest and emergency. ( 2 SSIDs)

Then a main Wifi router in my livingroom, one in my workshop/studio and one in the Attic (Electronics Lab)

So three main Wifi AccessPoints. These all have the same SSID’s but on different frequencies. That way i’ve got roaming in and outside my house.
Also some virtual accesspoints are configured.
I’ve got a main, folkband, IOT, guest-inside all on 2.4Ghz and 5Ghz.

I watched a lot of YT presentations about Mikrotik Wifi.

So I ended up with DFS safe channels 20Mhz for 2.4 and 20/40Mhz Ce for 5Ghz. (subchannels for each after some frequency scanning)
(2.4 does a failback to 20Mhz whenever there is even one client detected which connects only on this band. Such as some old IOT stuff)
2.4 in only 1,6 and 11 no overlap, each on another device.
300Mbps is sufficient for my wifi 🙂

I’ve got accesslists in place and i’m going to read into kicking a client when the signal strenght is below -50dB

80386 (DX) Computer

Besides my 8088 and 8086 machines I needed a machine which could run our old demo’s. So I bought a new toy.

It has 8Mb Ram and runs at 40Mhz.

I’ve noticed that many of my VGA register manipulation code, can’t be run on a modern VGA monitor, I need to use a CRT for that .. Another thing to buy

Lilygo T-Display S3 Streaming

Not my code: https://github.com/Steve5451/esp32-stream-desktop
A very cool project!

Needed to fix arduino code, due to the TFT_eSPI library issues.
And I’ve got a S3 with another resolution, but that was an easy fix.
Then needed to reinstall nodejs with another version.
Had to modify the code because the tcp server would not start.
Weird errors logging, but in the end fixed … very cool

I probably end up designing a 3D printed case that looks like a monitor or tv.

MartyPC

Perviously i’ve posted about PCem

But I wanted to have a emulator which could load extension biosses also.
This for my own tinkering.

I was told to look at MartyPC and PCE/ibmpc

I don´t like it being written in Rust, but it does the job.

Running the Basic Extension Rom
Running one of my own roms. I knew it didn’t work, now i can use the buildin debug to see why!
Another of my test roms, which is working!

ROM config part i’ve got in martypc.toml

rom_override = [
    { path = "./roms/BIOS_5160_09MAY86_U19_62X0819_68X4370_27256_F000.BIN", address = 0xF0000, offset=0, org="Normal" },
    { path = "./roms/BIOS_5160_09MAY86_U18_59X7268_62X0890_27256_F800.BIN", address = 0xF8000, offset=0, org="Normal" },
    { path = "./roms/myromextension.bin", address = 0xF6000, offset=0, org="Normal" }
]

GLABios for Laser XT/3

In previous post :

I mentioned a 2 ROM setup because the 8086 is 16bits instead of 8.
So I was wondering that maybe a recompile was needed, or the data being split over two roms (odd/even)

The guy from GLABios was so kind to build me two interleaved roms.

So while working on a padded bench, I tested the ROMs.

Working outside .. on the padded bench

Back to the roms, it didn’t work!

But I missed a detail in the technical manual (the bold text)

In Turbo XT /2 and Turbo XT /3, there are two 28-pin sockets for ROM,
both of them are occupied by 2764 which stored the BIOS. The contents
of the two 2764 are identical.
One of them contribute the ODD Byte to the system and the other EVEN Byte. Together they support 16 Bit BIOS
access.

I don’t know why this is how it works, but when I flashed two the same 28C64’s it worked!
(I also tought that is was strange that both original roms had the same markings.

It workes!

Only remarks/observations:

  • There was a longer wait time before the CF Card was detected/accessed
  • GLABios mentions 8088 in the splashscreen, but the machine is a 8086

UPDATE

GLABios was not updated for displaying 8086 yet.
Error 1701 was the (old spinning) harddisk not being connected.

Nice .. harddisk infomation like size, rom address and CHS

8086 sideway scroller ‘n stuff

Today I was working on my own brew ISA card (wirewrapping).
Did some mini modeling stuff.
Sorted some pipetunes.
And played around with my 8086.

Got it on a desk now, and replaced the harddisk with the CF card.
Also got an old SoundBlaster working, so i wanted to see what of my old code could still run.
Apparanty most code was compiled for 386/486 🙁
So i recompiled some stuff.
Below a horizontal scroller example.

Meanwhile i got my new fans in for my NUC (Kodi player, it was making a hell of a noise due to bad ball bearings.