https://toitlang.org/ logo
Join Discord
Powered by
# help
  • Pixelstrip on ESP32S3
    w

    woody

    02/23/2025, 11:02 AM
    Hi, I got the ESP32-S3-DevKitC-1 and flashed it with
    Copy code
    jag flash esp32s3-spiram-octo
    , I'm using SDK version: v2.0.0-alpha.174. I tried to get the RGB LED running with this program:
    Copy code
    import pixel-strip
    import gpio
    
    main:
      rgb-pin := gpio.Pin 38 --output=true
    //  while true:
    //    // sleep --ms=0 => 40 µs
    //    // sleep --ms=1..9 => 10ms
    //    // sleep --ms=10..x => 20ms..10+x
    //    rgb-pin.set 1
    //    sleep --ms=1
    //    rgb-pin.set 0
    //    sleep --ms=1
    
      rgb := pixel-strip.PixelStrip.uart 1 --pin=rgb-pin --invert-pin=false
      while true:
        rgb.output #[0xff] #[0xff] #[0xff]
        print "white"
        sleep --ms=1000
        rgb.output #[0xff] #[0] #[0]
        print "red"
        sleep --ms=1000
        rgb.output #[0] #[0xff] #[0]
        print "green"
        sleep --ms=1000
        rgb.output #[0] #[0] #[0xff]
        print "blue"
        sleep --ms=1000
    Program compiled and downloaded fine, but on the LED nothing happened. I measured Pin 38 with an Oscilloscope an it stay permanently low. What do I miss in my program? Or is the package buggy?
    f
    k
    • 3
    • 27
  • subabase demo
    m

    mvdlande

    02/23/2025, 1:43 PM
    Hello, I'm trying to get the supabase demo to work, see https://docs.toit.io/tutorials/network/supabase. I have created a test database using the given sql script. But, when I run the code, I get the following error: ****************************************************************************** Decoding by
    jag
    , device has version ****************************************************************************** EXCEPTION error. FAILED: 400 - Could not find the 'device-id' column of 'temperatures' in the schema cache 0: Client.request_ \supabase.toit:290:7 1: PostgRest.insert \supabase.toit:422:25 2: main database.toit:21:15 ****************************************************************************** In subabase I also see an error: POST 400 /rest/v1/temperatures No query parameters in this request I have also changed the supabase library to toit-supabase@0.3 and modified the demo code accordingly ... uri := "https://$(PROJECT-ID).supabase.co" client := supabase.Client --uri=uri --anon=ANON-KEY ... But the error remains. Has anybody seen this error before? What can i do to resolve this? Regards, Maurits😀 https://cdn.discordapp.com/attachments/1343216544230146089/1343216545102430288/subabase_error.jpg?ex=67bc7764&is=67bb25e4&hm=de8e79f2d1445708100d8924579ea4cd8d43b223093ffa056490d919969701eb&
    • 1
    • 1
  • Using reset reason
    s

    Spruiid

    02/26/2025, 1:25 PM
    https://libs.toit.io/#reset-reason(0%2C0%2C0%2C) Greetings, is there example code on how to use the reset-reason function in combination with watchdog?
    f
    • 2
    • 3
  • using i2c from within the c-envelope and the toit container
    a

    AbedN

    02/26/2025, 2:00 PM
    Hi, I'm running a toit container code on top of my custom c-envelope and it happens to be that both need i2c for different usages; i am getting this error when i run the container: E (11421) i2c: i2c driver install error ****************************************************************************** Decoding by
    jag
    , device has version ****************************************************************************** EXCEPTION error. UNKNOWN ERROR 0xffffffff(-1) 0: i2c-init_ /i2c.toit:324:3 1: Bus /i2c.toit:58:12 2: LBI2CDevice /devices/i2c.toit:14:10 3: RH2.I2C-DEVICE /devices/rh2.toit:10:24 4: run-global-initializer__. /core/objects.toit:291:28 5: run-global-initializer__ /core/objects.toit:257:1 6: RH2.I2C-WRITER /devices/rh2.toit:12:31 7: run-global-initializer__. /core/objects.toit:291:28 8: run-global-initializer__ /core/objects.toit:257:1 9: RH2.out /devices/rh2.toit:16:12 10: Comms.sendSwitching_ /services/comms.toit:265:15 11: Comms.send /services/comms.toit:246:5 12: main echo.toit:48:8 ****************************************************************************** [jaguar] ERROR: program 3e919e89-5ded-63a7-c1df-5f8a8ed7ae4d stopped - exit code 1) is there a way to go around this without having to move all i2c communication tasks to either side of the stack?
    f
    • 2
    • 4
  • Waiting for a list of tasks
    a

    addshore

    02/26/2025, 3:12 PM
    Im trying sometihng like
    Copy code
    tasks := []
    tasks.add (task (:: log.info "foo")
    tasks.add (task (:: do.something "else")
    tasks.do: |t| t.wait
    log.info "all done"
    But I believe this isn't doing what I'd expect. Is there a way to wait for a collection of actions such as tasks in this way?
    k
    • 2
    • 7
  • Stop jag startup on crashed container after `-D jag.disabled -D jag.timeout=16h`
    a

    addshore

    03/04/2025, 6:54 AM
    I have a jag container that I start with
    -D jag.disabled -D jag.timeout=16h
    , however if it crashes or restarts jag seems to come back. Is there a way to prevent this?
    k
    f
    • 3
    • 5
  • Wifi Access Point - Auth Mode
    c

    crockedile

    03/10/2025, 12:37 PM
    Currently working on a project that involves using the the esp32 as a wifi access point with a captive portal. I have everything working at this point, but would like to be establishing an open network if possible, rather than one requiring a password: "wifi.establish --name="espfi" --ssid="espfi" --password="password" --broadcast=true" Per error codes, it seems the code above requires the "--password" argument. Is there a way around this? I tried --password=NULL, --password="" and even attempted --authmode="open" hoping it was undocumented. No luck.
    f
    • 2
    • 16
  • too many DHTXX devices ?
    k

    kaxori

    03/14/2025, 11:06 AM
    For plant cultivation, I would like to use several DHTxx sensors to check the favorable germination environment. The prototype uses an ESP32 'wroom'. Four sensors can be configured in the application. An exception error is generated when initializing the fifth sensor:
    Copy code
    EXCEPTION error.
    ALREADY_IN_USE
       0: gpio-use_                 <sdk>\gpio\gpio.toit:855:5
    The Toit DHTxx package uses RMT-devices. ESP32 shout provide 8 RMT channels. Is it possible to use more than 4 devices on an ESP32-Wroom ?
    f
    • 2
    • 11
  • jag flash raises EXCEPTION error.ILLEGAL_UTF_8
    a

    AbedN

    03/17/2025, 7:32 AM
    Hi, I am running into the above issue when running jag flash build/esp32c6/toit-firmware.bin --chip esp32c6. it works with idf.py flash though when running jag monitor afterwards the device doesn't connect to network
    k
    f
    • 3
    • 19
  • Is there a way to build / flash, while ignoring code sections
    a

    addshore

    03/18/2025, 10:11 AM
    I c++ I can do something like
    Copy code
    #ifdef FOO_BAR
        doStuff();
    #endif
    Is there a similar way to do this sort of thing with toit? The primary usecase for me would be to entirely avoid building verbose log lines, which in their call might create long strings etc, when there is no expectaiton for that log line to every be used? The only alternative right now I guess would be commenting and un commenting lines continually?
    f
    • 2
    • 25
  • I2S on 2.0.0-alpha.175 causing panic
    r

    Rikke

    03/18/2025, 11:20 AM
    I have updated my toit sdk to 175, and I have changed the use of I2S to match the new syntax:
    i2s_bus = i2s.Bus --tx=pin --sample_rate=100_000 --bits_per_sample=32 --buffer_size=(buf.size + reset.size) --use-apll=false
    to
    Copy code
    i2s_bus = i2s.Bus
          --master=true
          --mclk=null
          --tx=pin
          --sck=null
          --ws=null
    
        i2s_bus.configure
          --sample_rate=100_000 
          --bits_per_sample=32 
    
        i2s_bus.start
    But in 1 out of 20 reboots(ish) I get a panic when starting up the i2s:
    Copy code
    Guru Meditation Error: Core  1 panic'ed (Cache disabled but cached memory region accessed). 
    
    Core  1 register dump:
    PC      : 0x400d5904  PS      : 0x00060035  A0      : 0x80088c96  A1      : 0x3ffb2b50  
    A2      : 0x3ffd48e8  A3      : 0x3ffb2b70  A4      : 0x3ffd4810  A5      : 0x3ffaf960  
    A6      : 0x00000003  A7      : 0x00060723  A8      : 0x80080eef  A9      : 0x00060923  
    A10     : 0x3ffd4810  A11     : 0x00000002  A12     : 0x00000000  A13     : 0x3ffb4484  
    A14     : 0x00000001  A15     : 0x3ffafa84  SAR     : 0x00000001  EXCCAUSE: 0x00000007  
    EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
    
    
    
    *******************************************
    Decoding by `jag`, device has version <2.0.0-alpha.175>
    *******************************************
    Crash in native code:
    Backtrace: 0x400d5901:0x3ffb2b50 0x40088c93:0x3ffb2b70 0x40087079:0x3ffb2bb0 0x40089b39:0x3ffb2bd0 0x4008544a:0x3ffaf9b0 0x4008558b:0x3ffaf9d0
    0x400d5901: toit::primitive_toit_callback_deinit(toit::Process*, toit::Object**) + 0x15
    0x40088c93: i2s_dma_rx_callback + 0x8b
    0x40087079: esp_random + 0x15
    0x40089b39: interrupt_hlevel_restore + 0x11
    0x4008544a: spi_flash_disable_cache$constprop$0 + 0x6
    0x4008558b: spi_flash_guard_set + 0x3
    *******************************************
    I am using
    i2s_bus.write
    to write to the pin. It works fine most of the time, but am I starting up the I2S too early?
    f
    k
    • 3
    • 210
  • Quite often my `jag run` commands hang, and I'm trying to figure out why!
    a

    addshore

    03/21/2025, 11:24 AM
    Sometimes my jag run commands hang for quite a while, sometimes they are super quick, and sometimes they are supre slow. Recently I got this set of traces from one that was hanging and ultimately failed Any thoughts on the best way to help possibly identify what is going on, and make it go away?
    f
    k
    • 3
    • 81
  • How to detect the data type of an object?
    k

    kaxori

    03/25/2025, 3:14 PM
    The value of '**nested**' should be detected as '**map**'. How can I achieve this ?
    Copy code
    map := {
                "simple":"value", 
                "nested": 
                  {
                    "A":1,
                    "B":2
                  }
              }
    f
    • 2
    • 34
  • Cant build jaguar after pulling latest master, Couldn't determine merge-base for upstream/release-v1
    a

    addshore

    03/26/2025, 3:06 PM
    Copy code
    ~/dev/github/toitlang/jaguar (main) make
    rm -f /home/adam/dev/github/toitlang/jaguar/build/sdk.build
    make -C /home/adam/dev/github/toitlang/jaguar/../toit version-file esp32
    make[1]: Entering directory '/home/adam/dev/github/toitlang/toit'
    make rebuild-cmake
    make[2]: Entering directory '/home/adam/dev/github/toitlang/toit'
    mkdir -p build/host
    (cd build/host && cmake /home/adam/dev/github/toitlang/toit -G Ninja -DHOST_TOIT=/home/adam/dev/github/toitlang/toit/build/host/sdk/bin/toit -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/home/adam/dev/github/toitlang/toit/toolchains/host.cmake --no-warn-unused-cli)
    Not searching for unused variables given on the command line.
    CMake Error at tools/gitversion.cmake:135 (message):
      Couldn't determine merge-base for upstream/release-v1.6 and origin/master
    Call Stack (most recent call first):
      tools/gitversion.cmake:155 (common_ancestor)
      CMakeLists.txt:57 (compute_git_version)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/adam/dev/github/toitlang/toit/build/host/CMakeFiles/CMakeOutput.log".
    make[2]: *** [Makefile:138: rebuild-cmake] Error 1
    make[2]: Leaving directory '/home/adam/dev/github/toitlang/toit'
    make[1]: *** [Makefile:114: build/host/CMakeCache.txt] Error 2
    make[1]: Leaving directory '/home/adam/dev/github/toitlang/toit'
    make: *** [Makefile:87: /home/adam/dev/github/toitlang/jaguar/build/sdk.build] Error 2
    k
    f
    • 3
    • 27
  • Watchdogs & jag monitor
    a

    addshore

    03/27/2025, 9:30 AM
    Im playing around with watchdogs for one of the first times in toit. When the watchdog times out, jag monitor disconnects (probably fine) however I stop seeing any output from the ESP, when reconnecting, even though my container is still running / has restarted
    Copy code
    [watchdog] ERROR: watchdog too late {id: lightbug/otl/link}
    [toit] INFO: entering deep sleep for 50ms
    Error: Port has been closed
    ~/dev/lb/io/toit (main) jag monitor --attach
    Starting serial monitor of port '/dev/ttyACM0' ...
    What (if anything) am I doing wrong?
    k
    • 2
    • 15
  • DS3231 driver and package registry
    p

    pkarsy

    03/30/2025, 6:17 PM
    Hi I have recently found about toit and as I am working (as a hobbyist) on a project using the DS3231 real time clock I decided to create a driver for it. The driver has the github page https://github.com/pkarsy/toit-ds3231 Although with very limited testing, seems to work OK. The problems started when I tried to register the project to https://pkg.toit.io The name of the project was "ds3231-toit" (github name) and I registered the version v0.8.0 After reading a recommendation in the documentation, I renamed it to "toit-ds3231" (a bad idea it seems) Unfortunatelly now there are 2 ds3231 drivers appearing as separate projects in the package registry The old one of course is absolete and it should be removed How can I do this ? Also there are some revisions in the new driver I rather delete. I am not familiar with releases and semantic versioning and I messed up the release. Is there any way to delete some specific version ? Thank you in advance Panagiotis PS. The language is fantastic ! I never had any expectation such a good option will ever exist for embedded programming. This includes the very good syntax the jag and artemis tools and of course the VS-code plugin
    f
    • 2
    • 11
  • wifi
    f

    Fernan

    04/12/2025, 9:24 PM
    Hello, I need to read the wifi rssi dbm of my esp32
    f
    • 2
    • 5
  • Best repo example for creating more than 1 pre built envelope
    a

    addshore

    04/14/2025, 9:37 AM
    I imagine the answer is either https://github.com/toitlang/envelopes or https://github.com/toitlang/template-custom-envelope I want to maintain a repo that will / can contain multiple envelopes / fw builds for use by us (containing a selection of pre installed containers) As far as I can tell template-custom-envelope is primarily setup for a single envelope For multiple, am I better of replicating the main envelopes repo?
    f
    • 2
    • 5
  • Multiple named arguments
    a

    addshore

    04/16/2025, 11:01 AM
    I was thinking of doing sometihng like this
    constructor action/Lambda --then/Lambda?=null:
    But I would want to be able to call it with multiple named arguments Such as
    foo --then=(::print foo) --then=(::print bar)
    However this isn't possible in toit, what would the closest thing be? Or is there an example of fluid / chained function calls
    f
    • 2
    • 6
  • Support for ESP32 Power Management
    i

    inneos

    04/17/2025, 3:16 PM
    I was wondering if Toit does support the power management features implemented in esp-idf? https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/power_management.html For battery-powered devices, this helps keep power consumption minimal.
    f
    • 2
    • 10
  • :question: ESPnow & Wifi alternaltely possible ?
    k

    kaxori

    04/21/2025, 4:04 PM
    I got a simple ESPnow-example working. Jag is disabled for a long time and a boot button press is used to exit the app. Now it would be nice to switch programmatically between ESPnow and Wifi (MQTT, ...). Is that possible ?
    f
    • 2
    • 7
  • Is there an easy way to access the wifi credentials configured for jag within toit code?
    a

    addshore

    04/22/2025, 3:59 PM
    I have a case where I want to display this info on a screen, but can't currntly find the pkg, lib or sdk part to let me see this easily. Is it possible?
    k
    • 2
    • 4
  • Is there a way to install a container with -D jag.disabled , but make it disable forever
    a

    addshore

    04/23/2025, 7:15 AM
    I have a flash ESP, but I would like to disable jag forever, without needing to reflash it without jag Is this possible? or should I just set a very large timeout?
    f
    k
    • 3
    • 15
  • How to accurately capture fan speed (TAC Pin) on ESP32?
    a

    Arubinu

    04/25/2025, 7:29 PM
    Hello, I would like to measure the speed of my fan (12V) using the TAC pin. On ATmega microcontrollers, if I'm not mistaken, there's ISR support (interrupt service routine) that allows you to catch each pulse. What would be the equivalent approach on Toit.io for ESP32 devices? When I simply create a task with
    (gpio.Pin MY_PIN).do:
    , I don't get reliable results. But I suspect the issue comes from how
    .do:
    behaves inside a task, since it appears to be blocking...
    f
    • 2
    • 19
  • 🛠 Remaining memory
    a

    Arubinu

    04/28/2025, 3:44 PM
    Is there a way to get feedback on how much space is still available (taking into account a safety margin for operation if possible)? I haven't found anything other than the amount of KB the program is taking up. https://cdn.discordapp.com/attachments/1366439943345274940/1366439943555121262/image.png?ex=6810f3dd&is=680fa25d&hm=0c882cac6da12ad00bf59b57eb29c90b16678ebedd06d0618ca825d26c463327&
    f
    • 2
    • 21
  • Jag monitor over Ethernet
    a

    Arubinu

    04/28/2025, 7:23 PM
    Is it possible to access the monitor from the network via the IP address or name given to the ESP32?
    f
    • 2
    • 7
  • How to present function comments?
    a

    Arubinu

    05/01/2025, 1:35 PM
    I'd like to clarify how the functions/methods work, but I don't see anything official. Did I miss it? Example:
    Copy code
    cpp
    /**
     * @fn float ** merci(int*, double**,char*,int)
     * @param   \b param1 
     * @param   \b param2
     * @param   \b param3
     * @param   \b param4
     * @brief   votre briefing concernant la fonction
     * @details  les détails de la fonction
     * @return  ce qu'elle retourne
     */
    k
    f
    • 3
    • 8
  • Captive Portal + Artemis
    b

    bpmct

    05/03/2025, 10:48 PM
    I am hoping to run a fleet of devices that I can hand to friends and they can initialize on their own wifi after plugging in via a captive portal. From there, I'd love to push updates. Architectually, I'm still getting my footing here so I was wondering if anybody had any pointers on whether this is possible today/things to look our for or any recommendations on how to do this... I am assuming I could register it on my WiFi, and then have some "fallback" captive portal if the connection fails... seems the safest because it'd also allow people to move their devices but unsure what this means in practice or whether artemis supports this
    f
    • 2
    • 9
  • Device unregisters with `jag` (esp32s3)
    b

    bpmct

    05/04/2025, 3:29 PM
    I'm noticing that sometimes, I have to manually specify
    jag flash --port /dev/cu.usbmodem2101
    but it otherwise does not show up on
    jag port
    ,
    jag flash
    , or
    jag monitor
    . I am also finding cases where it lets me manually specify the port with
    jag flash
    , but
    jag monitor
    isn't able to pick it up... Any ideas? I'm using an esp32s3 and this version:
    Copy code
    ➜  toit-zygote git:(fixes) ✗ jag version
    Version:         v1.50.3
    SDK version:     v2.0.0-alpha.179
    Build date:      2025-04-01T08:09:19Z
    f
    • 2
    • 58
  • Artemis - REST API & Offline Devices
    b

    bpmct

    05/05/2025, 9:34 PM
    I am interested in allowing devices to be offline for a large amount of time (e.g. hours, days, months) but when plugged in, they re-join the fleet and may even fetch OTA updates. I also want to be able to programmatically query an API to understand which devices are offline or offline? For the offline length, it seems like I just need to set
    max-offline
    to a very long number. However, I'm not sure if artemis has the built-in capability to query whether something is on or off, besides looking at
    events
    . Is there a REST API I should be programmatically querying, or should I be sending health to artemis via events, or using an external backend to keep track of devices and health? Thanks!
    f
    • 2
    • 18