Raspberry BASIC

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - John Spikowski

Pages: [1] 2 3
1
ScriptBasic / Amazon Sidewalk
« on: April 13, 2023, 08:03:03 AM »
I was just notified by the Amazon Sidewalk support group that my test kit is on the way. Time to dust off my RPi's and brush up on the GPIO bus.

I may become more active on the forum once my test kit arrives.

2
General Discussion / Raspberry Central
« on: April 24, 2022, 08:59:17 PM »
I recently moved from Anacortes north to Lynden WA which is 5 miles from the Canadian boarder. Lynden has over 8,000 acres of Raspberry farms serving 70% of the US market.

Lynden has a population of 12,500 people.

3
General Discussion / ESP32 MicroPython
« on: March 14, 2021, 09:35:57 AM »
I was able to get MicroPython loaded on my ESP32-DEVKITC32D board. I'm using Putty on the RPi 3B to connect via /dev/ttyUSB0.


>>> help('modules')
__main__          gc                ubinascii         urandom
_boot             inisetup          ubluetooth        ure
_onewire          machine           ucollections      urequests
_thread           math              ucryptolib        uselect
_uasyncio         micropython       uctypes           usocket
_webrepl          neopixel          uerrno            ussl
apa106            network           uhashlib          ustruct
btree             ntptime           uheapq            usys
builtins          onewire           uio               utime
cmath             uarray            ujson             utimeq
dht               uasyncio/__init__ umqtt/robust      uwebsocket
ds18x20           uasyncio/core     umqtt/simple      uzlib
esp               uasyncio/event    uos               webrepl
esp32             uasyncio/funcs    upip              webrepl_setup
flashbdev         uasyncio/lock     upip_utarfile     websocket_helper
framebuf          uasyncio/stream   upysh
Plus any modules on the filesystem
>>>
>>> machine.freq(240000000)
>>> machine.freq()
240000000
>>>





4
General Discussion / RPI Zero Portable
« on: March 06, 2021, 09:20:26 PM »
I picked up a dongle like adapter for my RPi Zero running Raspian Lite. This gives me a USB portable Linux I connect to via WIFI / SSH.


PS C:\WINDOWS\system32> ssh pi@192.168.0.193
pi@192.168.0.193's password:
Linux raspberrypi 5.10.17+ #1403 Mon Feb 22 11:26:13 GMT 2021 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Mar  6 13:01:58 2021 from 192.168.0.191
pi@raspberrypi:~ $

pi@raspberrypi:~ $ free --mega
              total        used        free      shared  buff/cache   available
Mem:            450         110          93           7         246         278
Swap:           104           3         101
pi@raspberrypi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       117G  1.8G  111G   2% /
devtmpfs        183M     0  183M   0% /dev
tmpfs           216M     0  216M   0% /dev/shm
tmpfs           216M  3.1M  213M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           216M     0  216M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   48M  205M  19% /boot
tmpfs            44M     0   44M   0% /run/user/1000
pi@raspberrypi:~ $


Installed:

  • ScriptBasic source and runtime
  • MySQL (MariaDB) Server
  • Apache2 Web Server (running on WIFI connection)

5
BBC BASIC / BBC Micro
« on: February 17, 2021, 09:30:01 PM »
Hi Richard,

I just ordered the BBCMicro starter kit from Vilros.

Do you think BBC BASIC would run on it?


6
ScriptBasic / RPi Zero
« on: February 03, 2021, 02:56:01 AM »
As mentioned in the Pico thread I'm focusing my embedded scripting engine efforts to the RPi Zero. I built ScriptBasic from source on the Zero and running on 32 bit Raspian.  I'm working on building a GPIO extension module based on the public domain pigpio and or lg library.


7
ScriptBasic / Pico
« on: January 27, 2021, 08:53:40 PM »
I'm in the process of creating a ScriptBasic build for the new RPi Pico. ScriptBasic by design is an embeddable highly configurable micro controller scripting engine. It is used commercially by Banner Engineering and Controlled Soutions with their micro controller solutions.

If you have interest in joining me in this adventure, send support@raspberrybasic.org a request to join the forum.

8
General Discussion / LG Library
« on: January 14, 2021, 05:44:13 AM »
I was able to compile the lg library under Ubuntu 20.04 LTS 64 bits on the RPi 4B 8GB with no errors or complaints with the make file included.

Since I don't have anything connected to my GPIO bus I wanted to see if the lgGpiochipOpen() fuction would return anything. A positive response is zero or greater. I got a -78
 as a response. I assume since there is no chips on the bus it's returning an error code. There is an example for the DHT11 which I have that is going to be my next test.

Code: C
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <lgpio.h>
  5.  
  6. #define LFLAGS 0
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10.    int h;
  11.    h = lgGpiochipOpen(0);
  12.    printf("%i\n", h);
  13.    if (h >= 0)
  14.    {printf("Got Here\n");}
  15.    lgGpiochipClose(h);
  16. }
  17.  

DHT11 Example
Code: C
  1. /*
  2. dhtxx.c
  3. 2020-11-18
  4. Public Domain
  5.  
  6. http://abyz.me.uk/lg/lgpio.html
  7.  
  8. gcc -Wall -o dhtxx dhtxx.c -llgpio
  9.  
  10. ./dhtxx gpio ...
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdint.h>
  15. #include <stdlib.h>
  16. #include <unistd.h>
  17. #include <inttypes.h>
  18.  
  19. #include <lgpio.h>
  20.  
  21. #define DHTAUTO 0
  22. #define DHT11   1
  23. #define DHTXX   2
  24.  
  25. #define DHT_GOOD         0
  26. #define DHT_BAD_CHECKSUM 1
  27. #define DHT_BAD_DATA     2
  28. #define DHT_TIMEOUT      3
  29.  
  30. /*
  31. gcc -o dhtxx dhtxx.c -llg
  32. */
  33.  
  34. #define MAX_GPIO 32
  35.  
  36. static int decode_dhtxx(uint64_t reading, int model, float *rh, float *temp)
  37. {
  38. /*
  39.       +-------+-------+
  40.       | DHT11 | DHTXX |
  41.       +-------+-------+
  42. Temp C| 0-50  |-40-125|
  43.       +-------+-------+
  44. RH%   | 20-80 | 0-100 |
  45.       +-------+-------+
  46.  
  47.          0      1      2      3      4
  48.       +------+------+------+------+------+
  49. DHT11 |check-| 0    | temp |  0   | RH%  |
  50.       |sum   |      |      |      |      |
  51.       +------+------+------+------+------+
  52. DHT21 |check-| temp | temp | RH%  | RH%  |
  53. DHT22 |sum   | LSB  | MSB  | LSB  | MSB  |
  54. DHT33 |      |      |      |      |      |
  55. DHT44 |      |      |      |      |      |
  56.       +------+------+------+------+------+
  57.  
  58. */
  59.    uint8_t byte[5];
  60.    uint8_t chksum;
  61.    float div;
  62.    float t, h;
  63.    int valid;
  64.    int status;
  65.  
  66.    byte[0] = (reading    ) & 255;
  67.    byte[1] = (reading>> 8) & 255;
  68.    byte[2] = (reading>>16) & 255;
  69.    byte[3] = (reading>>24) & 255;
  70.    byte[4] = (reading>>32) & 255;
  71.  
  72.    chksum = (byte[1] + byte[2] + byte[3] + byte[4]) & 0xFF;
  73.  
  74.    valid = 0;
  75.  
  76.    if (chksum == byte[0])
  77.    {
  78.       if (model == DHT11)
  79.       {
  80.          if ((byte[1] == 0) && (byte[3] == 0))
  81.          {
  82.             valid = 1;
  83.  
  84.             t = byte[2];
  85.  
  86.             if (t > 60.0) valid = 0;
  87.  
  88.             h = byte[4];
  89.  
  90.             if ((h < 10.0) || (h > 90.0)) valid = 0;
  91.          }
  92.       }
  93.       else if (model == DHTXX)
  94.       {
  95.          valid = 1;
  96.  
  97.          h = ((float)((byte[4]<<8) + byte[3]))/10.0;
  98.  
  99.          if (h > 110.0) valid = 0;
  100.  
  101.          if (byte[2] & 128) div = -10.0; else div = 10.0;
  102.  
  103.          t = ((float)(((byte[2]&127)<<8) + byte[1])) / div;
  104.  
  105.          if ((t < -50.0) || (t > 135.0)) valid = 0;
  106.       }
  107.       else /* AUTO */
  108.       {
  109.          valid = 1;
  110.  
  111.          /* Try DHTXX first. */
  112.  
  113.          h = ((float)((byte[4]<<8) + byte[3]))/10.0;
  114.  
  115.          if (h > 110.0) valid = 0;
  116.  
  117.          if (byte[2] & 128) div = -10.0; else div = 10.0;
  118.  
  119.          t = ((float)(((byte[2]&127)<<8) + byte[1])) / div;
  120.  
  121.          if ((t < -50.0) || (t > 135.0)) valid = 0;
  122.  
  123.          if (!valid)
  124.          {
  125.             /* If not DHTXX try DHT11. */
  126.  
  127.             if ((byte[1] == 0) && (byte[3] == 0))
  128.             {
  129.                valid = 1;
  130.  
  131.                t = byte[2];
  132.  
  133.                if (t > 60.0) valid = 0;
  134.  
  135.                h = byte[4];
  136.  
  137.                if ((h < 10.0) || (h > 90.0)) valid = 0;
  138.             }
  139.          }
  140.       }
  141.  
  142.       if (valid)
  143.       {
  144.          status = DHT_GOOD;
  145.  
  146.          *rh = h;
  147.          *temp = t;
  148.       }
  149.       else status = DHT_BAD_DATA;
  150.    }
  151.    else status = DHT_BAD_CHECKSUM;
  152.  
  153.    return status;
  154. }
  155.  
  156. static int status;
  157. static float h=0, t=0;
  158.  
  159. void afunc(int e, lgGpioAlert_p evt, void *data)
  160. {
  161.    int i;
  162.    uint64_t edge_len, now_tick;
  163.    static int bits = 0;
  164.    static uint64_t reading = 0;
  165.    static uint64_t last_tick = 0;
  166.  
  167.    for (i=0; i<e; i++)
  168.    {
  169.       if (evt[i].report.level != LG_TIMEOUT)
  170.       {
  171.          now_tick = evt[i].report.timestamp;
  172.          edge_len = now_tick - last_tick;
  173.          last_tick = now_tick;
  174.          if (edge_len > 1e6) // a millisecond
  175.          {
  176.             reading = 0;
  177.             bits = 0;
  178.          }
  179.          else
  180.          {
  181.             reading <<= 1;
  182.             if (edge_len > 1e5) reading |= 1; // longer than 100 micros
  183.             ++bits;
  184.          }
  185.       }
  186.       else
  187.       {
  188.          status = decode_dhtxx(reading, DHTAUTO, &t, &h);
  189.          reading = 0;
  190.          bits = 0;
  191.       }
  192.    }
  193. }
  194.  
  195. int main(int argc, char *argv[])
  196. {
  197.    int i, g;
  198.    int v;
  199.    int loop;
  200.    int fd;
  201.    int chip;
  202.    int num_gpio;
  203.    int gpio[MAX_GPIO];
  204.    int err;
  205.    int count;
  206.  
  207.    chip = lgGpiochipOpen(0);
  208.  
  209.    if (argc > 1)
  210.    {
  211.       num_gpio=argc-1;
  212.       if (num_gpio > MAX_GPIO) num_gpio = MAX_GPIO;
  213.       for (g=0; g<num_gpio; g++) gpio[g] = atoi(argv[g+1]);
  214.    }
  215.    else
  216.    {
  217.       num_gpio = 1;
  218.       gpio[0] = 4;
  219.    }
  220.  
  221.    if (chip >= 0)
  222.    {
  223.       lgGpioSetUser(chip, "niagra");
  224.       lgGpioSetSamplesFunc(afunc, (void*)123456);
  225.  
  226.       for (g=0; g<num_gpio; g++)
  227.       {
  228.          lgGpioSetWatchdog(chip, gpio[g], 1000); /* millisecond watchdog */
  229.       }
  230.  
  231.       for (loop=0; loop<200000; loop++)
  232.       {
  233.          for (g=0; g<num_gpio; g++)
  234.          {
  235.             err = lgGpioClaimOutput(chip, 0, gpio[g], 0);
  236.             if (err) fprintf(stderr, "set out err %d\n", err);
  237.  
  238.             usleep(15000);
  239.  
  240.             err = lgGpioClaimAlert(
  241.                chip, 0, LG_RISING_EDGE, gpio[g], -1);
  242.             if (err) fprintf(stderr, "set event err %d\n", err);
  243.  
  244.             count = 0;
  245.             status = DHT_TIMEOUT;
  246.  
  247.             while ((status == DHT_TIMEOUT) && (++count<11)) usleep(1000);
  248.  
  249.             printf("%d %.1f %.1f (g=%d)\n", status, t, h, gpio[g]);
  250.  
  251.             fflush(NULL);
  252.          }
  253.          sleep(3);
  254.       }
  255.  
  256.       lgGpiochipClose(chip);
  257.    }
  258.    else
  259.    {
  260.       fprintf(stderr, "open /dev/gpiochip0 failed (%d)\n", chip);
  261.    }
  262. }
  263.  


9
General Discussion / WiringPi
« on: January 01, 2021, 09:22:16 AM »
It seems that WiringPi doesn't work with the RPi 4b 8GB.

Code: [Select]
ubuntu@rpi4b:~$ sudo gpio readall
Oops - unable to determine board type... model: 17
ubuntu@rpi4b:~$

10
General Discussion / RPi Gitlab Setup
« on: December 29, 2020, 11:51:49 PM »
I have installed Gitlab-ee on my new RPi 4B 8GB. The install seemed to go fine. Problem is I can't reach the Gitlab login screen.  :-\

I setup a gitlab.basic-sandbox.us DNS A record on my AWS Route53 DNS service. I have reconfigured Gitlab a couple of times with no error.

When I enter https://basic-sandbox.us in my browser it returns the Apache default index.html page.

Does anyone have an idea how to debug this to get it running?


ubuntu@rpi4b:~$ sudo gitlab-ctl status
down: alertmanager: 1s, normally up, want up; run: log: (pid 3233) 2615s
run: gitaly: (pid 3254) 2615s; run: log: (pid 3243) 2615s
run: gitlab-exporter: (pid 3239) 2615s; run: log: (pid 3232) 2615s
run: gitlab-workhorse: (pid 3259) 2615s; run: log: (pid 3250) 2615s
run: grafana: (pid 3256) 2615s; run: log: (pid 3245) 2615s
run: logrotate: (pid 3252) 2615s; run: log: (pid 3238) 2615s
run: nginx: (pid 19171) 2s; run: log: (pid 3230) 2615s
run: node-exporter: (pid 3253) 2615s; run: log: (pid 3241) 2615s
run: postgres-exporter: (pid 3249) 2615s; run: log: (pid 3234) 2615s
run: postgresql: (pid 3255) 2615s; run: log: (pid 3244) 2615s
run: prometheus: (pid 3240) 2615s; run: log: (pid 3231) 2615s
run: puma: (pid 3262) 2615s; run: log: (pid 3247) 2615s
run: redis: (pid 3251) 2615s; run: log: (pid 3235) 2615s
run: redis-exporter: (pid 3261) 2615s; run: log: (pid 3242) 2615s
run: sidekiq: (pid 3246) 2615s; run: log: (pid 3237) 2615s
ubuntu@rpi4b:~$


This is the banner that shows after logging into to RPi 4B 8GB.


Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-1026-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Dec 29 18:26:42 PST 2020

  System load:  2.69                Temperature:           44.8 C
  Usage of /:   12.9% of 116.97GB   Processes:             319
  Memory usage: 66%                 Users logged in:       1
  Swap usage:   0%                  IPv4 address for eth0: 23.90.90.91

 * Introducing self-healing high availability clusters in MicroK8s.
   Simple, hardened, Kubernetes for production, from RaspberryPi to DC.

     https://microk8s.io/high-availability

0 updates can be installed immediately.
0 of these updates are security updates.


11
Programming Challenges / GUI Login
« on: December 25, 2019, 01:20:47 AM »
This round of the language challenge series is to create a desktop GUI login dialog. Be as creative as you wish. To get things started here is a Python /wx example.

Python WX

Code: Python
  1. import wx
  2.  
  3. ########################################################################
  4. class LoginDialog(wx.Dialog):
  5.     """
  6.    Class to define login dialog
  7.    """
  8.  
  9.     #----------------------------------------------------------------------
  10.     def __init__(self):
  11.         """Constructor"""
  12.         wx.Dialog.__init__(self, None, title="Login")
  13.         self.logged_in = False
  14.  
  15.         # user info
  16.         user_sizer = wx.BoxSizer(wx.HORIZONTAL)
  17.  
  18.         user_lbl = wx.StaticText(self, label="Username:")
  19.         user_sizer.Add(user_lbl, 0, wx.ALL|wx.CENTER, 5)
  20.         self.user = wx.TextCtrl(self)
  21.         user_sizer.Add(self.user, 0, wx.ALL, 5)
  22.  
  23.         # pass info
  24.         p_sizer = wx.BoxSizer(wx.HORIZONTAL)
  25.  
  26.         p_lbl = wx.StaticText(self, label="Password:")
  27.         p_sizer.Add(p_lbl, 0, wx.ALL|wx.CENTER, 5)
  28.         self.password = wx.TextCtrl(self, style=wx.TE_PASSWORD|wx.TE_PROCESS_ENTER)
  29.         self.password.Bind(wx.EVT_TEXT_ENTER, self.onLogin)
  30.         p_sizer.Add(self.password, 0, wx.ALL, 5)
  31.  
  32.         main_sizer = wx.BoxSizer(wx.VERTICAL)
  33.         main_sizer.Add(user_sizer, 0, wx.ALL, 5)
  34.         main_sizer.Add(p_sizer, 0, wx.ALL, 5)
  35.  
  36.         btn = wx.Button(self, label="Login")
  37.         btn.Bind(wx.EVT_BUTTON, self.onLogin)
  38.         main_sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
  39.  
  40.         self.SetSizer(main_sizer)
  41.  
  42.     #----------------------------------------------------------------------
  43.     def onLogin(self, event):
  44.         """
  45.        Check credentials and login
  46.        """
  47.         stupid_password = "pa$$w0rd!"
  48.         user_password = self.password.GetValue()
  49.         if user_password == stupid_password:
  50.             print ("You are now logged in!")
  51.             self.logged_in = True
  52.             self.Close()
  53.         else:
  54.             print ("Username or password is incorrect!")
  55.  
  56. ########################################################################
  57. class MyPanel(wx.Panel):
  58.     """"""
  59.  
  60.     #----------------------------------------------------------------------
  61.     def __init__(self, parent):
  62.         """Constructor"""
  63.         wx.Panel.__init__(self, parent)
  64.  
  65.  
  66. ########################################################################
  67. class MainFrame(wx.Frame):
  68.     """"""
  69.  
  70.     #----------------------------------------------------------------------
  71.     def __init__(self):
  72.         """Constructor"""
  73.         wx.Frame.__init__(self, None, title="Main App")
  74.         panel = MyPanel(self)
  75.  
  76.         # Ask user to login
  77.         dlg = LoginDialog()
  78.         dlg.ShowModal()
  79.         authenticated = dlg.logged_in
  80.         if not authenticated:
  81.             self.Close()
  82.  
  83.         self.Show()
  84.  
  85. if __name__ == "__main__":
  86.     app = wx.App(False)
  87.     frame = MainFrame()
  88.     app.MainLoop()
  89.  


12
Nim / Nim IUP
« on: December 23, 2019, 08:51:56 PM »
This is a Nim version of the ScriptBasic iup3buttons example.

Code: Text
  1. # IUP Button / Event Example
  2.  
  3. import iup
  4.  
  5. proc Btn1_clicked(ih:PIhandle):cint {.cdecl.}=
  6.   echo "BUTTON 1 Event"
  7.  
  8. proc Btn2_clicked(ih:PIhandle):cint {.cdecl.}=
  9.   echo "BUTTON 2 Event"
  10.  
  11. proc Btn3_clicked(ih:PIhandle):cint {.cdecl.}=
  12.   echo "BUTTON 3 Event"
  13.  
  14. discard iup.open(nil, nil)
  15. var win = iup.dialog(nil)
  16. discard iup.setAttributes(win, "TITLE=\"Test Dialog\", SIZE=300x")
  17. var horzbox = iup.hbox(nil)
  18. discard iup.setAttributes(horzbox, "GAP=5")
  19. var btn1 = iup.button("", nil)
  20. discard iup.setAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  21. var btn2 = iup.button("", nil)
  22. discard iup.setAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  23. var btn3 = iup.button("", nil)
  24. discard iup.setAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  25. iup.append(horzbox, btn1)
  26. iup.append(horzbox, btn2)
  27. iup.append(horzbox, btn3)
  28. iup.append(win, horzbox)
  29. discard iup.setCallback(btn1, "ACTION", cast[ICallback](Btn1_clicked))
  30. discard iup.setCallback(btn2, "ACTION", cast[ICallback](Btn2_clicked))
  31. discard iup.setCallback(btn3, "ACTION", cast[ICallback](Btn3_clicked))
  32. discard iup.show(win)
  33. discard iup.mainLoop()
  34. iup.close()
  35.  


ubuntu@rpi4b:~/repo/Nim/examples$ ./iup3buttons
BUTTON 1 Event
BUTTON 2 Event
BUTTON 3 Event
ubuntu@rpi4b:~/repo/Nim/examples$


13
Nim / Nim Manual
« on: December 23, 2019, 01:44:54 AM »
This is a link to the Nim Manual.

It's a good resouce to get started with Nim.

14
General Discussion / Ubuntu 64 RPI 4B
« on: December 15, 2019, 08:08:16 AM »
On AIR's lead, I was able to  install Ubuntu server 19.10.1 on my RPi 4B 4GB. I then installed the Unity Desktop. This is so cool to run what I have on my laptop  on my RPi.

It seems to run well.

I said 5 years ago that I was done with 32 bit Linux. That was until the Raspberry Pi came along. I'm done with hobby Raspbian 32 and relieved I'm running on a commercial grade supported 64 bit OS.

15
FreeBasic / FreeBasic RPi Install
« on: December 15, 2019, 01:19:34 AM »
Here is the install instructions for installing FreeBasic on the Raspberry Pi.

Quote
wget http://users.freebasic-portal.de/stw/builds/linux-armv7a-hf-debian/freebasic.deb
wget http://users.freebasic-portal.de/stw/builds/freebasic-headers.deb
sudo dpkg -i freebasic.deb
sudo dpkg -i freebasic-headers.deb
apt-get update
apt-get install -f

Pages: [1] 2 3