Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
61
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 18, 2021, 07:26:12 PM »
I tried to install the ESP-IDF tools on my RPi 4B running Ubuntu 64 bit.

This sucks!


jrs@RPi-Dev:~/esp/esp-idf$ ./install.sh
Detecting the Python interpreter
Checking "python" ...
/home/jrs/esp/esp-idf/tools/detect_python.sh: line 16: python: command not found
Checking "python3" ...
Python 3.8.6
"python3" has been detected
Installing ESP-IDF tools
Installing tools: xtensa-esp32-elf, xtensa-esp32s2-elf, xtensa-esp32s3-elf, riscv32-esp-elf, esp32ulp-elf, esp32s2ulp-elf, openocd-esp32
ERROR: tool xtensa-esp32-elf does not have versions compatible with platform linux-arm64
jrs@RPi-Dev:~/esp/esp-idf$



On a positive note I was able to install the ESP32 development tools on my 4 GB / 2 core @ 2.13 ghz AMD old laptop. It's running Ubuntu 20.04 64 bit OS. Runs a lot faster than my RPi 3B.

62
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 18, 2021, 05:31:02 AM »
I have spent hours trying to get my DHT11 and DHT22 working on Micropython using the DHT library. The measure() call returns a ETIMEOUT with every attempt.

Has anyone gotten this to work?

You don't need to join the forum to respond. Send an e-mail to support@raspberrybasic.org with suggestions would be appreciated.
63
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 17, 2021, 12:11:11 AM »
ESP32-PICO-D4

Detailed Spec.

ESP32 contains two low-power Xtensa 32-bit LX6 microprocessors. (240 MHz) The internal memory includes:

* 448 KB of ROM for booting and core functions.
* 520 KB of on-chip SRAM for data and instructions.
* 8 KB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage; it is accessedby the main CPU during RTC Boot from the Deep-sleep mode.
* 8 KB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processorduring the Deep-sleep mode.
* 1 Kbit of eFuse: 256 bits are used for the system (MAC address and chip configuration) and the remaining768 bits are reserved for customer applications, including flash-encryption and chip-ID
* 4 MB Flash
* Wi-Fi and Bluetooth
$10


ESP32-DEVKITC32D

Detailed Spec.

ESP32-D0WD contains a dual-core Xtensa 32-bit LX6 MCU microprocessor. (240 MHz) The internal memory includes:

* 448 KB of ROM for booting and core functions.
* 520 KB of on-chip SRAM for data and instructions.
* 8 KB of SRAM in RTC, which is called RTC FAST Memory and can be used for data storage; it is accessedby the main CPU during RTC Boot from the Deep-sleep mode.
* 8 KB of SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processorduring the Deep-sleep mode.
* 1 Kbit of eFuse: 256 bits are used for the system (MAC address and chip configuration) and the remaining768 bits are reserved for customer applications, including flash-encryption and chip-ID.
* 4 MB Flash
* Wi-Fi and Bluetooth
$10


Raspberry Pi Pico

* Dual-core Arm Cortex-M0+ processor, flexible clock running up to 133 MHz
* 264KB on-chip SRAM
* 2MB on-board QSPI Flash
$4
64
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 16, 2021, 08:33:03 PM »
This is a ESP32-PICO MicroPython pystone_lowmem benchmark example. This also shows how to use upip to install additional libraries.

Code: Python
  1. >>>
  2. MPY: soft reboot
  3. MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
  4. Type "help()" for more information.
  5. >>> import network
  6. >>> sta_if = network.WLAN(network.STA_IF)
  7. >>> sta_if.active()
  8. False
  9. >>> sta_if.active(True)
  10. True
  11. >>>
  12. >>> sta_if.scan()
  13. [(b'jrs', b'\xd8\x07\xb6\xf8\xb1\x97', 10, -31, 4, False), (b'BillingsHouse', b'D\x1c\x12\xd8\x99\x96', 1, -64, 3, False), (b'Nika', b'\xec\xaa\xa02\xb0h', 6, -79, 3, False), (b'chicken shit', b'\xd4\xab\x82\xc7\x8d\x92', 1, -84, 3, False), (b'AOL', b'\xbc\x9bh\xa6\x0f\x18', 11, -84, 3, False), (b'2018NEW3beginsYIP!', b'\xd4\xab\x82\xc3\x15\xea', 11, -84, 3, False), (b'My Bell', b'\x80>H\xb7o\xc5', 11, -86, 4, False), (b'Anahouse', b'\x84\x00-\x03\xc1\x98', 11, -89, 3, False), (b'Guapo', b'\xac\xdbHB\xa9\x86', 11, -89, 3, False), (b'IslandHouse', b'P\xd4\xf7\x02b\x89', 2, -90, 3, False), (b'password', b'<z\x8a9\xce`', 1, -91, 3, False), (b'BK WiFi', b'\\\xe3\x0e\xbc\x13\xb5', 6, -91, 3, False), (b'UmbrellaCorp', b'\x84\xd8\x1bfu\xce', 1, -95, 3, False)]
  14. >>> sta_if.connect('jrs', 'MY_PASSWORD')
  15. >>> sta_if.isconnected()
  16. True
  17. >>> import upip
  18. >>> upip.install("micropython-pystone_lowmem")
  19. Installing to: /lib/
  20. Warning: micropython.org SSL certificate is not validated
  21. Installing micropython-pystone_lowmem 3.4.2.post4 from https://micropython.org/pi/pystone_lowmem/pystone_lowmem-3.4.2.post4.tar.gz
  22. >>> import pystone_lowmem
  23. >>>
  24. >>> pystone_lowmem.main()
  25. Pystone(1.2) time for 500 passes = 536ms
  26. This machine benchmarks at 932 pystones/second
  27. >>>
  28.  

This is the same benchmark but using my ESP32-DEVKITC32D board and increasing the processor frequency rate.

Code: Python
  1. >>>
  2. MPY: soft reboot
  3. MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
  4. Type "help()" for more information.
  5. >>> import network
  6. >>> sta_if = network.WLAN(network.STA_IF)
  7. >>> sta_if.active()
  8. False
  9. >>> sta_if.active(True)
  10. True
  11. >>> sta_if.connect('jrs', 'MY_PASSWORD')
  12. >>> sta_if.isconnected()
  13. True
  14. >>> import upip
  15. >>> upip.install("micropython-pystone_lowmem")
  16. Installing to: /lib/
  17. Warning: micropython.org SSL certificate is not validated
  18. Installing micropython-pystone_lowmem 3.4.2.post4 from https://micropython.org/pi/pystone_lowmem/pystone_lowmem-3.4.2.post4.tar.gz
  19. >>> import pystone_lowmem
  20. >>> pystone_lowmem.main()
  21. Pystone(1.2) time for 500 passes = 537ms
  22. This machine benchmarks at 931 pystones/second
  23. >>> import machine
  24. >>> machine.freq(240000000)
  25. >>> pystone_lowmem.main()
  26. Pystone(1.2) time for 500 passes = 432ms
  27. This machine benchmarks at 1157 pystones/second
  28. >>>
  29.  

I retried the ESP32-PICO (not related to RPi Pico) and increased the frequency to 240000000 it ran faster than my ESP32-DEVKITC32D board.  :o


>>> pystone_lowmem.main()
Pystone(1.2) time for 500 passes = 428ms
This machine benchmarks at 1168 pystones/second
>>>


I need to do a side-by-side comparison to see what makes them different.

I found a post that shows the RPI Pico pystone_lowmem results.


>>> exec(open('Pi_Pico_Pystone_lowmem.py').read())
Pystone(1.2) time for 500 passes = 460ms
This machine benchmarks at 1086 pystones/second

>>>

65
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 15, 2021, 09:28:47 PM »
I got MicroPython running on my ESP32-PICO board. The sensor blinks each time it's scanned.

Picture


pi@RPi3B:~/esp $ /home/pi/esp/esp-idf/components/esptool_py/esptool/esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v3.1-dev
Serial port /dev/ttyUSB0
Connecting........_
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5f:c1:54
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 5.1s
Hard resetting via RTS pin...
pi@RPi3B:~/esp $

pi@RPi3B:~/esp $ /home/pi/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-idf4-20210202-v1.14.bin
esptool.py v3.1-dev
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5f:c1:54
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Compressed 1484624 bytes to 951640...
Wrote 1484624 bytes (951640 compressed) at 0x00001000 in 24.2 seconds (effective 491.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
pi@RPi3B:~/esp $

66
General Discussion / Re: ESP32 MicroPython
« Last post by John Spikowski on March 15, 2021, 12:45:30 AM »
I was able to get my DS18B20 temperature sensor to work with the ESP32-DEVKITC32D board.

The interpretive method of programming sure beats having to compile an image and flash it to the controller with each experiment.

I'm going to flash my ESP32-PICO with MicroPython to free up my faster board for more demanding projects.


>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import time, ds18x20
=== from machine import Pin
=== import onewire
===
=== ow = onewire.OneWire(Pin(12))
=== ds = ds18x20.DS18X20(ow)
=== i = 1
=== while i < 11:
===   roms = ds.scan()
===   ds.convert_temp()
===   for rom in roms:
===     print("Sensor " + str(rom) + ": " + str(ds.read_temp(rom)))
===   time.sleep_ms(2000)
===   i += 1
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.3125
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
Sensor bytearray(b'(\xff&\xc2\x80\x17\x04\x93'): 22.375
>>> print(rom)
bytearray(b'(\xff&\xc2\x80\x17\x04\x93')
>>> print(roms)
[bytearray(b'(\xff&\xc2\x80\x17\x04\x93')]
>>> print(ow)
<OneWire object at 3ffe5360>
>>> print(ds)
<DS18X20 object at 3ffe5370>
>>>

67
General Discussion / ESP32 MicroPython
« Last post by John Spikowski 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
>>>




68
General Discussion / Re: RPI Zero Portable
« Last post by John Spikowski on March 08, 2021, 04:58:49 AM »
This is an example of using the OpenWeather API with Curl and the ScriptBasic LIKE function to parse the returned JSON response.

Note: I dislike the ScriptBasic function name JOKER().

Code: Script BASIC
  1. ' OpenWeather - Curl Example
  2.  
  3. IMPORT curl.bas
  4.  
  5. FUNCTION MATCH(segment)
  6.   MATCH = JOKER(segment)
  7. END FUNCTION
  8.  
  9. place = COMMAND()
  10.  
  11. ch = curl::init()
  12. curl::option(ch, "URL", "http://api.openweathermap.org/data/2.5/weather?q=" & place & "&units=imperial&appid=MY_API_ID")
  13. curl::option(ch, "CUSTOMREQUEST", "GET")
  14. response = curl::perform(ch)
  15. curl::finish(ch)
  16.  
  17. PRINT "\n", response,"\n\n"
  18.  
  19. IF response LIKE "*lon\":*,\"lat\":*}*temp\":*,*pressure\":*,*humidity\":*}*dt\":*,*country\":\"*\"*timezone\":*,*name\":\"*\"*" THEN
  20.   PRINT "Country:    ", MATCH(13), "\n"
  21.   PRINT "City:       ", MATCH(17), "\n"
  22.   PRINT "Longitude:  ", MATCH(2), "\n"
  23.   PRINT "Latitude:   ", MATCH(3), "\n"
  24.   PRINT "Date/Time:  ", FORMATDATE("MM/DD/YEAR 0H:0m:0s", MATCH(11) + MATCH(15)), "\n"
  25.   PRINT "Tempreture: ", MATCH(5), " F\n"
  26.   PRINT "Pressure:   ", MATCH(7), " hPa\n"
  27.   PRINT "Humidity:   ", MATCH(9), " %\n"
  28. END IF
  29.  


pi@raspberrypi:~/sb/examples $ time scriba curlweather.sb Anacortes,US

{"coord":{"lon":-122.6127,"lat":48.5126},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":45.27,"feels_like":34.83,"temp_min":42.01,"temp_max":48.2,"pressure":1016,"humidity":53},"visibility":10000,"wind":{"speed":11.5,"deg":60},"clouds":{"all":1},"dt":1615229908,"sys":{"type":1,"id":3524,"country":"US","sunrise":1615214245,"sunset":1615255505},"timezone":-28800,"id":5785657,"name":"Anacortes","cod":200}

Country:    US
City:       Anacortes
Longitude:  -122.6127
Latitude:   48.5126
Date/Time:  3/8/2021 10:58:28
Tempreture: 45.27 F
Pressure:   1016 hPa
Humidity:   53 %

real    0m0.437s
user    0m0.091s
sys     0m0.073s
pi@raspberrypi:~/sb/examples $ time scriba curlweather.sb New York,US

{"coord":{"lon":-74.006,"lat":40.7143},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":40.05,"feels_like":30.9,"temp_min":37.4,"temp_max":42.8,"pressure":1030,"humidity":26},"visibility":10000,"wind":{"speed":5.75,"deg":0},"clouds":{"all":1},"dt":1615229912,"sys":{"type":1,"id":4610,"country":"US","sunrise":1615202327,"sunset":1615244097},"timezone":-18000,"id":5128581,"name":"New York","cod":200}

Country:    US
City:       New York
Longitude:  -74.006
Latitude:   40.7143
Date/Time:  3/8/2021 13:58:32
Tempreture: 40.05 F
Pressure:   1030 hPa
Humidity:   26 %

real    0m0.332s
user    0m0.120s
sys     0m0.049s
pi@raspberrypi:~/sb/examples $ time scriba curlweather.sb London,GB

{"coord":{"lon":-0.1257,"lat":51.5085},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}],"base":"stations","main":{"temp":46.92,"feels_like":42.51,"temp_min":45,"temp_max":48.2,"pressure":1022,"humidity":53},"visibility":10000,"wind":{"speed":1.14,"deg":0},"clouds":{"all":100},"dt":1615230315,"sys":{"type":1,"id":1414,"country":"GB","sunrise":1615185018,"sunset":1615225950},"timezone":0,"id":2643743,"name":"London","cod":200}

Country:    GB
City:       London
Longitude:  -0.1257
Latitude:   51.5085
Date/Time:  3/8/2021 19:05:15
Tempreture: 46.92 F
Pressure:   1022 hPa
Humidity:   53 %

real    0m0.333s
user    0m0.111s
sys     0m0.053s
pi@raspberrypi:~/sb/examples $

69
General Discussion / Re: RPI Zero Portable
« Last post by John Spikowski on March 07, 2021, 09:40:05 PM »
This is an example of using the MySQL extension module with ScriptBasic on the RPi Zero.

Code: Script BASIC
  1. ' MySQL Demo Program
  2.  
  3. INCLUDE mysql.bas
  4.  
  5. dbh = mysql::RealConnect("localhost","root","mypswd","classicmodels")
  6. mysql::query(dbh,"SELECT * FROM products WHERE productLine = 'Classic Cars'")
  7.  
  8. WHILE mysql::FetchHash(dbh,column)
  9.   PRINT column{"productCode"}," - ",column{"productName"}," - ",FORMAT("%~$###.00~",column{"MSRP"}),"\n"
  10. WEND
  11.  
  12. PRINTNL
  13. PRINT "The database handle is: ",dbh,"\n"
  14. PRINT "Affected rows by SELECT: ",mysql::AffectedRows(dbh),"\n"
  15. PRINT "Character set name is: ",mysql::CharacterSetName(dbh),"\n"
  16. PRINT "Last error is: ",mysql::ErrorMessage(dbh),"\n"
  17. PRINT "Client info is: ",mysql::GetClientInfo(),"\n"
  18. PRINT "Host info is: ",mysql::GetHostInfo(dbh),"\n"
  19. PRINT "Proto info is: ",mysql::GetProtoInfo(dbh),"\n"
  20. PRINT "Server info is: ",mysql::GetServerInfo(dbh),"\n"
  21. PRINT "PING result: ",mysql::Ping(dbh),"\n"
  22. PRINT "Thread ID: ",mysql::ThreadId(dbh),"\n"
  23. PRINT "Status is: ",mysql::Stat(dbh),"\n"
  24.  
  25. mysql::Close(dbh)
  26.  


pi@raspberrypi:~/sb/examples $ scriba mysql_demo.sb
S10_1949 - 1952 Alpine Renault 1300 - $214.30
S10_4757 - 1972 Alfa Romeo GTA - $136.00
S10_4962 - 1962 LanciaA Delta 16V - $147.74
S12_1099 - 1968 Ford Mustang - $194.57
S12_1108 - 2001 Ferrari Enzo - $207.80
S12_3148 - 1969 Corvair Monza - $151.08
S12_3380 - 1968 Dodge Charger - $117.44
S12_3891 - 1969 Ford Falcon - $173.02
S12_3990 - 1970 Plymouth Hemi Cuda - $ 79.80
S12_4675 - 1969 Dodge Charger - $115.16
S18_1129 - 1993 Mazda RX-7 - $141.54
S18_1589 - 1965 Aston Martin DB5 - $124.44
S18_1889 - 1948 Porsche 356-A Roadster - $ 77.00
S18_1984 - 1995 Honda Civic - $142.25
S18_2238 - 1998 Chrysler Plymouth Prowler - $163.73
S18_2870 - 1999 Indy 500 Monte Carlo SS - $132.00
S18_3232 - 1992 Ferrari 360 Spider red - $169.34
S18_3233 - 1985 Toyota Supra - $107.57
S18_3278 - 1969 Dodge Super Bee - $ 80.41
S18_3482 - 1976 Ford Gran Torino - $146.99
S18_3685 - 1948 Porsche Type 356 Roadster - $141.28
S18_4027 - 1970 Triumph Spitfire - $143.62
S18_4721 - 1957 Corvette Convertible - $148.80
S18_4933 - 1957 Ford Thunderbird - $ 71.27
S24_1046 - 1970 Chevy Chevelle SS 454 - $ 73.49
S24_1444 - 1970 Dodge Coronet - $ 57.80
S24_1628 - 1966 Shelby Cobra 427 S/C - $ 50.31
S24_2766 - 1949 Jaguar XK 120 - $ 90.87
S24_2840 - 1958 Chevy Corvette Limited Edition - $ 35.36
S24_2887 - 1952 Citroen-15CV - $117.44
S24_2972 - 1982 Lamborghini Diablo - $ 37.76
S24_3191 - 1969 Chevrolet Camaro Z28 - $ 85.61
S24_3371 - 1971 Alpine Renault 1600s - $ 61.23
S24_3432 - 2002 Chevy Corvette - $107.08
S24_3856 - 1956 Porsche 356A Coupe - $140.43
S24_4048 - 1992 Porsche Cayenne Turbo Silver - $118.28
S24_4620 - 1961 Chevrolet Impala - $ 80.84
S700_2824 - 1982 Camaro Z28 - $101.15

The database handle is: 1
Affected rows by SELECT: 38
Character set name is: latin1
Last error is:
Client info is: 10.3.27
Host info is: Localhost via UNIX socket
Proto info is: 10
Server info is: 10.3.27-MariaDB-0+deb10u1
PING result: -1
Thread ID: 0
Status is: Uptime: 8093  Threads: 8  Questions: 486  Slow queries: 0  Opens: 31  Flush tables: 1  Open tables: 25  Queries per second avg: 0.060
pi@raspberrypi:~/sb/examples $

70
General Discussion / Re: RPI Zero Portable
« Last post by John Spikowski on March 07, 2021, 06:12:35 PM »
I install PHP 7.3 for Apache and phpMyAdmin. With my RPi mapped drive I can use UltraEdit on my Windows laptop. Running Raspian Lite seems to make the RPi Zero run efficiently. I think I've created a nice Linux sidekick for my Windows 10 laptop.  8)
Pages: 1 ... 5 6 [7] 8 9 10