Tag Archives: raspberry

Wanted to make a mini Sid Player, and failed

I’ve got an old Speaker Phat, and a Raspberry Zero

An audio add-on board for Raspberry ( same size as the Zero )
Connections

My initial idea was to have the “High Voltage Sid Collection” (Downloaded the 55000 pack)
On a mini device, battery operated and with a little keypad.

On the keypad i can select the Sidtune to play, or pressing
A and a number the Sids from a certain artist.

The display gives you information about the tune being played.
( The display has an I2C hat to convert 8bits to I2C )

See pinout phat above.
I’ve got three choices for I2C connection (green/blue to the Phat)

  • Direct connect and use different addresses
  • Use a I2C hub and different addresses
  • Define a secondary I2C on the raspberry

So I made the first test setup …

Underrun occurred .. So back to the drawingboard.
I probably need a better Audio Hat.
First to try .. Zero fast enough for sidplay2?
Maybe audio over hdmi works??

Shelly Flood Sensor

I’ve had this Shelly sensor for a long time. But never posted anything about this.
Last weekend we had a -situation- in our kitchen, so what better time to test this device again!

This little disc shaped device has three metal points on its bottom side, those are the flood (water) sensors.
It stay’s in sleep mode when all’s good.
It does several things when it detects water.

  • Emits a alarm signal
  • Wakes-up wifi
    • Sends a MQTT message (when not connected to the cloud like i have)
      MQTT is a alarm message AND it wil send the temperature of the device!
  • After a while (when dry) goes back to sleep

There are connection point on the print you can use .. happy hacking!

My node-red configuration

Above is the part where the mqtt messages gets processed by Node-Red
Sending it to PushOver and my little MqttLcdNotifier

Above is the MqttLcdNotifer .. there are several parts to this

  • Top line is from shelly flood and other notifications
  • Text input puts text from the NR GUI on my TV and the LCDDisplay
    • same parts are being used by my 3D printer when the print tool is getting TO hot, or printing is finished
  • Trigger at work WAS a notification for work .. nonfunc
  • mqttlcd-button is the mqtt message send from the display (the one that i was pushing) to stop the beeping and clears the display
  • Bash notify, is as previously posted a flow which i can control from my linux machines notify “compiling complete” for example.
    This is also being broadcast from my livingroom using speakers.
    (See separate post about this)

Wellll, put this in place 2 years ago, never looked at it again .. still works

Volume is low, due to alarm sounds 🙂

Generic matrix keyboard

In this case designed for my 6502, but it is a generic setup.

I it just a dual 16key matrix decoder merged together. You can probably use this with raspberries, arduinos etc.

I wanted to use 74C923 but these are nowhere to be found. And even then, the number of keys wil be 20.
So i am tying together two 74C922 using some logic in a PLD.

First draft

It wil be something like above. Using the data availabe signal i can combine both 16key matrixes. (In theory .. it is all untested)

PLD Code

GAL22V10
Address Decoder

PHI2 DA0 DA1 D01 D02 D03 D04 D11 D12 D13 D14 GND
NC D0 D1 D2 D3 D4 DA NC NC NC NC VCC

DA = DA0 + DA1
D0 = D01 & DA0 + D11 & DA1
D1 = D02 & DA0 + D12 & DA1
D2 = D03 & DA0 + D13 & DA1
D3 = D04 & DA0 + D14 & DA1
D4 = DA1 

DESCRIPTION
Key matrix merger

I’ve got my new keys of the keyboard in today!

  • 0-F – hex keys
  • G = Go
  • R = Reset
  • S = Step
  • M = Memory
  • Cursor keys (up/down for memory locations)
  • ??? I’ve got room for 8 more keys

My inkscape template (keys are 10/10mm)

Printed on white and red paper

https://media.henriaanstoot.nl/keyboardmatrix.svg

MCH2022 Badge

Almost … friday will be the day i’ll attend May Contain Hackers.
Besides the awesome villages and talks.

UPDATE: 20220727
UPDATE: 20220812

You get a hackable badge, this one is more amazing as previous versions.

I can’t wait to have a go at this cool gadget. I personally could do without the pcb fancy design.

  • Espressif ESP32 Wrover-E with 16MB of flash storage and paired with 8MB of PSRAM, for front-end badge computing and compatibility with the badge.team ecosystem back to the 2017 SHA badge.
  • Lattice ICE40UP5K FPGA for hardware-accelerated graphics and user FPGA hardware designs.
  • Raspberry Pi RP2040 for advanced USB communication and board management.
  • 2Ah LiPo battery to give you a full day of fun on a charge.
  • 16-bit DAC with stereo output to headphone socket, onboard mono speaker.
  • ILI9341 2.2 inch TFT display with a 240 by 320 pixel resolution.
  • Bosch BNO055 orientation sensor.
  • Bosch BME680 environmental sensor.
  • The usual array of addressable LEDs.
  • SAO and Qwiic expansion connectors, FPGA PMOD expansion, plus onboard prototyping area.

Downloadable apps, micro python, Arduino ide programming.
All kinds of GPIO pins, leds buttons, sound.
Check out https://hatchery.badge.team/

You can play with this virtually here!
https://wokwi.com/projects/335445228923126356

So much potential! Great start for a DIY project.

I won’t post about the workings, thats all well documented online.
I shall post about the hacks/findings i personally did.

UPDATE: 20220727
Made a micropython program to keep your NameTag level to the ground (Better version)

UPDATE: 20220812

Someone made a 8bit logic analyser using the pmod connector !

Mini C64 for MCH2022

Cool little C64 gadget for MCH2022

Next week i’ll be going to May Contain Hackers 2022, what to bring?
My old friend Bigred will be there, many others couldn’t make it …

What to bring and do:

  • Laptops
  • Arduino touch project?
  • My new 6502 breadboard computer?
  • The DVB-T / DAB / FM stick
  • Besides the emulators on my laptop, maybe i’ll bring this little thing
    (Or a real C64?)

Booting in 4 seconds!
Running Vice in 50 or 60 Hz
Low latency video!
Can emulate cartrides, floppy’s
When you connect joysticks or a real C64 keyboard to the GPIO pins it will use that.
SID sound using ReSid
CRT emulation
(look for BMC64 or combian)

Screens and DIY projects

Below some examples and connection diagrams to control displays.
More code and complete schematics will be added on this page or on a separate projects page.

UPDATE 20230119 Cost of 20×4 display in 1998

LCD

I’ve used a LCD display like this (HITACHI HD44780) on my PC in the 90s, and also written code to use this as a monitoring device on my amiga.

On Linux i used LcdProc – This module also was equiped with a serial connector
Now (2023) it is 8 euros!
;LCD Display Module             Parallel port
;        1 Vss                  20 GND
;        2 Vdd                  14 +5V
;        3 Vlc                  20 GND (contrast LCD display)
;        4 RS (register select) 11 BUSY
;        5 R/W                  12 POUT
;        6 E (enable)           13 SEL
;        7 DB0                   2 D0
;        8 DB1                   3 D1
;        9 DB2                   4 D2
;       10 DB3                   5 D3
;       11 DB4                   6 D4
;       12 DB5                   7 D5
;       13 DB6                   8 D6
;       14 DB7                   9 D7
Amiga code part
        bsr     initprt         ; CIA 8520 init
        bsr     initlcd         ; init lcd display module
        move.l  #0,d0
        rts

initprt:move.b  #$ff,$bfe301    ; parallel port is output
        move.b  $bfd200,d0
        ori.b   #$07,d0         ; select, p-out and busy
        move.b  d0,$bfd200      
        rts

initlcd:move.w  #$38,d0         ; multiple reset
        bsr     send
        bsr     delay2
        move.w  #$38,d0
        bsr     send
        bsr     delay2
        move.w  #$38,d0         ; 2*8 lines
        bsr     send
        bsr     delay2
        move.w  #$01,d0         ; clear display
        bsr     send
        bsr     delay2          ; wait
        move.w  #$0c,d0         ; display on
        bsr     send
        move.w  #$06,d0         ; Entry Mode Set
        bsr     send
        rts

send:   bsr     delay
        btst    #8,d0           ; test rs bit
        beq     reg0
        bsr     rs1             ; select register 1
        bra     skip
reg0:   bsr     rs0             ; select register 0
skip:
        bsr     delay
        bsr     rw0             ; read/write=0 
        bsr     delay
        bsr     e1              ; enable = 1
        bsr     delay
        move.b  d0,$bfe101      ; push data
        bsr     delay
        bsr     e0              
        bsr     delay
        rts

delay:  move.w  #$20,d1
dloop:  subi    #1,d1
        bne     dloop
        rts

delay2: move.w  #$800,d1
dloop2: subi    #1,d1
        bne     dloop2
        rts
Part of my MQTT display alarm thingy
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>  
LiquidCrystal_I2C lcd(0x27, 20, 4);
const char* ssid = "MYACCESSPOINT";
const char* password = "MYPASSWORD";
const char* mqtt_server = "mymqttserver";
const byte ledRed = 12;
const byte horn = 13;
int button = 2;
int press = 0;
boolean buttonToggle = true;


// Todo : DISPLAY 2ND LINE, DISPLAY SILENT, ...

WiFiClient espClient;
PubSubClient client(espClient);
bool toggle = false;
void setup_wifi() {
  delay(100);

  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  randomSeed(micros());
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length)
{
  if (length > 0) {
    toggle = true;
  }

  if (length == 0) {
    toggle = false;
  }

  Serial.print("Command from MQTT broker is : [");
  Serial.print(topic);

  Serial.println();
  Serial.print(" publish data is:");
  lcd.clear();
  lcd.backlight(); // turn off backlight

  {
  
    for (int i = 0; i < length; i++)
    {
      Serial.print((char)payload[i]);
      if (i < 16){
      lcd.setCursor(0, 0);
      lcd.setCursor(i, 0);
      } else {
      lcd.setCursor(0, 1);
      lcd.setCursor(i-16, 1);
      }
      lcd.write((char)payload[i]);
    }
  }


  Serial.println();
} 

void reconnect() {
  
  while (!client.connected())
  {
    Serial.print("Attempting MQTT connection...");
    
    String clientId = "mqttlcd";
    clientId += String(random(0xffff), HEX);

    if (client.connect(clientId.c_str()))
    {
      Serial.println("connected");

      client.subscribe("mqttlcd/message");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(6000);
    }
  }
} 

void setup() {
  Serial.begin(115200);
  pinMode(button, INPUT);
  digitalWrite(2, HIGH);
  pinMode(ledRed, OUTPUT);
  digitalWrite(ledRed, LOW);
  pinMode(horn, OUTPUT);
  digitalWrite(horn, LOW);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  lcd.init(); 
  lcd.backlight();
}

void loop() {

  
  if (!client.connected()) {
    reconnect();
  }
  if (toggle == true) {
    digitalWrite(ledRed, HIGH);
    digitalWrite(horn, HIGH);
    delay(200);
    digitalWrite(ledRed, LOW);
    digitalWrite(horn, LOW);
    delay(200);
  }
  if (toggle == false) {
    digitalWrite(ledRed, LOW);
    digitalWrite(horn, LOW);

  }

  client.setCallback(callback);
  client.loop();

  press = digitalRead(button);
  if (press == LOW)
  {
    if (buttonToggle)
    {
      digitalWrite(ledRed, HIGH);
      digitalWrite(horn, HIGH);
      buttonToggle = !buttonToggle;
    }
    else
    {
      digitalWrite(ledRed, LOW); 
      digitalWrite(horn, LOW);
      buttonToggle = !buttonToggle;
      toggle = false;
      client.publish("mqttlcd/button","pressed");
      lcd.clear();
      lcd.noBacklight(); // turn off backlight
    }
  }
  delay(500);  //delay for debounce
}

Oled

There are several oled displays, mostly controllable with i2c but some of them are SPI

SSD1306 – I2c connected

Using a wemos – Octoprint project for example
Octoprint (Note: this is NOT a multicolor display 1/4 of the display is yellow. )
My notification watch. Runs on a ESP12F connects to Wifi, has a piezo sound element
Using a raspberry (Part of my Lab Sensors Project)
pip3 install adafruit-circuitpython-ssd1306
git clone https://github.com/adafruit/Adafruit_Python_SSD1306 (old)
Edit file - comment SPI section

Some arduino’s have embedded displays like those i’ve used for a Lora project.

Other means of connecting : SPI

SPI connected display

Nextion

Nextion is a Human Machine Interface (HMI) solution combining an onboard processor and memory touch display with Nextion Editor software for HMI GUI project development.

Using the Nextion Editor software, you can quickly develop the HMI GUI by drag-and-drop components (graphics, text, button, slider, etc.) and ASCII text-based instructions for coding how components interact on the display side.

Nextion HMI display connects to peripheral MCU via TTL Serial (5V, TX, RX, GND) to provide event notifications that peripheral MCU can act on, the peripheral MCU can easily update progress, and status back to Nextion display utilizing simple ASCII text-based instructions.

My nextion domoticz box, tilt to wakeup
Domoticz controller

My biltong box using a Nextion

Raspberry displays

 3.5inch RPi Display – 480×320 Pixel – XPT2046 Touch Controller
edit cmdline.txt
add "fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo"
at the end
edit config.txt
add between custom comments at the bottom
dtoverlay=piscreen,speed=24000000,rotate=90
# Or check http://www.lcdwiki.com/3.5inch_RPi_Display

Above display’s i’ve used for Picore Players and the Lidar POC

To try: Getting above display running with a arduino
https://github.com/PaulStoffregen/XPT2046_Touchscreen

Raspberry HDMI display

Easiest of them all, just connect with HDMI, there is a adaptor for hdmi-hdmi (versions 1,2,3) and hdmi-mini-hdmi for RPi4 variants.

Epaper and 7-Segment displays

Other means of displaying information are for example

Epaper

ESP with epaper module, disconnected power for a while, artifacts appear.

7 Segment displays

I used a lot of 7-Segment display’s in the past. They look cool and are hardcore.

My homebrew computer uses this

Nixie tubes!

And there are https://en.wikipedia.org/wiki/Nixie_tube .. I’ve never had those

Above bigger 2D display i used with Wled and a digital microphone, so its sound reactive. The lower part i got in recently .

inmp441 digital microphone

Using OSB to record screens

While you can use screencapture to record virtual machines, to real machines it is a different story.

Virtual machines running locally or remote can be accessed with spice/vnc or rdesktop.
So you have a window displaying the remote screen, which you can capture using window capture.

There are also emulators which you can window-capture. But i want the real thing when available. Emulators give a too crisp screen output. And you want to have the real SID chip sound.

Hardware capturing:

I’ve got two capturing usb sticks:

Camlink 4K for hdmi capturing (Which i use mainly for my nikon)

Basetech BR116 RCA and S-Video capture (NTSC 720 x 480 , 30 FPS/PAL 720 x 576 , 25 FPS)

Devices and recording:

  • C64 – Use Basetech, and the DIN to RCA cable
  • Vic-20 – same as above
  • Raspberry – Use a HDMI and Camlink
  • Amiga – I use the basetech and grab the composite signal from the Scart connector, another solution is to use a A520 Modulator, which has Composite out. (There are schematics on the internet to connect hdmi to your amiga)
Amiga A520 Modulator

The 520 Modulator connects to the amiga using a DB23 connector, and a Y cable for the 2 rca audio jacks.
It outputs a composite video signal, and RF modulated signal to connect to a old Tube/Crt monitor

When recording video from those screens, i configure my OBS file format to MP4. This makes it easier to embed into websites. Only downside on writing to MP4 instead of mkv is the fact that the file probably isn’t recoverable when something crashes.

Audio capturing :

When capturing your movie don’t forget to add a audio source to your OBS sources.
Use Audio input capture, or you can use Audio output capture when sound is playing by your system.

Demo a friend made using a demomaker (Music starts half way)

Flightsim on a Amiga (See more on flightsims)
C64 Hellraiser (part 1) no de-comb/de-interlace filter

Note: check your output/cables
https://www.youtube.com/watch?v=entQosOLjEI

Portable Logitech Media Server again

See post: https://www.henriaanstoot.nl/2014/04/10/portable-squeeze-server/

In the past i’ve used a home build Logitech Squeezebox server (as it was called then), Picore player and tried volumio.
Picore player has been sitting in my livingroom for ages, but was converted to a Node-Red Dashboard and recently Home Assistant Dashboard. (Has been a dasticz daskboard also)

Today i build another version, smaller and with a screen.
Why? .. because of being ‘offline’ or ‘offgrid’ on our holidays.
The car we are driving only has a Aux input.

Most of the installation is as mentioned on:
https://docs.picoreplayer.org/projects/add-a-display/

I edited  /opt/bootsync.sh
to get /dev/sda1 mounted persistent
use pcp br after editing.

Default user/pass : tc piCore

Controlling the thing is via touch or a app on my phone using wifi hotspot.

  • Audio cable 3.5mm
  • Raspberry 3
  • Large usb thumbdrive
  • 3.5inch RPi Display – 480×320 Pixel – XPT2046 Touch Controller
  • car cigarette lighter adapter for power

PiCore uses below alliases

ceChange directory to /mnt/mmcblk0p2/tce
ceoChange directory to /mnt/mmcblk0p2/tce/optional
m1Mount the boot partition /mnt/mmcblk0p1
m2Mount the second partition /mnt/mmcblk0p2
c1Change directory to /mnt/mmcblk0p1
c2Change directory to /mnt/mmcblk0p2
vicfgEdit configuration file config.txt using vi
vicmdEdit boot file cmdline.txt using vi
u1Unmount the boot partition /mnt/mmcblk0p1
u2Unmount the second partition /mnt/mmcblk0p2

Shutting down piCore is done by cutting the power, due to everything being mounted readonly. EXEPT
When you are using LMS server installation, which uses a database.
But there is a tweak for a shutdown button.

I’m using GPIO 16 because i’ve got a screen connected.
Active LOW, means you have to connect a pushbutton/switch between GND and GPIO pin. (nearest Vcc OR Gnd)

Retropi handheld

I’ve got a retro-pi running for some time, now .. posting a little movie.
The gamehat i’ve got a week now.

Retropi met Darish Zone King Image

  • 512GB
  • 23000 games
  • 50 systems

Own hacks on this system:

  • Added dos emulator
  • Added DOS games
  • Added Amiga demos menu entry
  • Changed Font sized and look

I’ve got a bigben controller which i can connect to the Raspberry USB .

375403 (600×315)

A sms gateway

Sms form

Made a generic sms sender, for check_mk monitoring + sending password of accounts.
You can send sms by filling in a form, or using a url like:

http://smsgateway.local:8080/sms/0612341234/Message%20met%20spaties

It uses a Raspberry and a sim800L module.

Fritzing schematic
At work in a corner near a window (3d printed case)

Remove pin from simcard fix:

sudo minicom -b 115000 -o -D /dev/serial0

 AT+CPIN?
+CPIN: SIM PIN

AT+CPIN=0000
OK

AT+CLCK=”SC”,0,”0000″
OK

AT+CPIN?
+CPIN: READY 

Cron

@reboot sh /home/pi/launcher.sh 

Launcher

cat /home/pi/launcher.sh
#!/bin/bash
cd /home/pi
while true; do
/usr/bin/python newapi.py
done

newapi.py (uses flask)

import serial
import RPi.GPIO as GPIO     
import os, time
import sys

from flask import Flask, render_template, request
app = Flask(__name__)

from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, TextAreaField
from wtforms.validators import DataRequired

from flask import render_template

app.config['SECRET_KEY'] = 'you-will-never-guess'

class FormForm(FlaskForm):
    telnumber = StringField('telnumber', validators=[DataRequired()])
    messagepart = TextAreaField('Text', render_kw={"rows": 5, "cols": 20})
    submit = SubmitField('Send Sms')
 
@app.route("/sms/<number>/<message>")
def action(number, message):
        num = number.encode() 
        mes = message.encode() 
	GPIO.setmode(GPIO.BOARD)   
	# Enable Serial Communication
	port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)

	# Transmitting AT Commands to the Modem
	# '\r\n' indicates the Enter key
	port.write('AT'+'\r\n')
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	#port.write('ATE0'+'\r\n')      # Disable the Echo
	#rcv = port.read(10)
	#print rcv
	#time.sleep(1)
	port.write('AT+CMGF=1'+'\r\n')  # Select Message format as Text mode
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write('AT+CNMI=2,1,0,0,0'+'\r\n')   # New SMS Message Indications
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write('AT+CSCS="GSM"'+'\r\n')   
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	# Sending a message to a particular Number
	port.write('AT+CMGS="'+num+'"\r\n')
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write(mes+'\r\n')  # Message
	rcv = port.read(10)
	print rcv
	port.write("\x1A") # Enable to send SMS
	for i in range(10):
	    rcv = port.read(10)
	    print rcv
        return 'OK'
@app.route("/form")
def form():
    form = FormForm()
    return render_template('web.html', title='Web Sms', form=form)
@app.route('/data', methods = ['POST', 'GET'])
def data():
    if request.method == 'GET':
        return "The URL /data is accessed directly. Try going to '/form' to submit form"
    if request.method == 'POST':
  
        telnumber = request.form['telnumber']
        messagepart = request.form['messagepart']
        num = telnumber.encode() 
        mes = messagepart.encode()
	GPIO.setmode(GPIO.BOARD)   
	# Enable Serial Communication
	port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
	# Transmitting AT Commands to the Modem
	# '\r\n' indicates the Enter key
	port.write('AT'+'\r\n')
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	#port.write('ATE0'+'\r\n')      # Disable the Echo
	#rcv = port.read(10)
	#print rcv
	#time.sleep(1)
	port.write('AT+CMGF=1'+'\r\n')  # Select Message format as Text mode
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write('AT+CNMI=2,1,0,0,0'+'\r\n')   # New SMS Message Indications
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write('AT+CSCS="GSM"'+'\r\n')   
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	# Sending a message to a particular Number
	port.write('AT+CMGS="'+num+'"\r\n')
	rcv = port.read(10)
	print rcv
	time.sleep(1)
	port.write(mes+'\r\n')  # Message
	rcv = port.read(10)
	print rcv
	port.write("\x1A") # Enable to send SMS
	for i in range(10):
	    rcv = port.read(10)
	    print rcv
       
        return '<a href="/form">Nog een SMS sturen</a>'
@app.route("/checkmk")
def checkmk():
        # Enable Serial Communication
        port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
   
        port.write('AT'+'\r\n')
        rcv1 = port.read(30)
        time.sleep(1)

        port.write('AT+CPAS'+'\r\n')
        rcv2 = port.read(30)        
        time.sleep(1)
    
        port.write('AT+CGREG?'+'\r\n')
        rcv3 = port.read(30)
        time.sleep(1)
    
        port.write('AT+CGATT?'+'\r\n')
        rcv4 = port.read(30)
        time.sleep(1)
    
        port.write('AT+CSQ'+'\r\n')
        rcv5 = port.read(30)
        time.sleep(1)

        return 'OK of niet' + rcv1 + rcv2 + rcv3 + rcv4 + rcv5
if __name__ == "__main__":
   app.run(host='0.0.0.0', port=8080, debug=True)