## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• Aug 08 09:27
slaff closed #2540
• Aug 07 07:50
slaff opened #2540
• Aug 07 07:50
slaff milestoned #2540
• Aug 07 07:39
slaff unlabeled #2538
• Aug 07 07:39
slaff closed #2538
• Aug 07 04:56
slaff unlabeled #2539
• Aug 07 04:56
slaff closed #2539
• Aug 06 12:38
slaff review_requested #2539
• Aug 06 12:38
slaff labeled #2539
• Aug 06 12:38
slaff milestoned #2539
• Aug 06 12:23
SimonBrazell opened #2539
• Aug 05 12:09
slaff labeled #2538
• Aug 05 12:09
slaff milestoned #2538
• Aug 05 05:32
mikee47 edited #2538
• Aug 05 05:31
mikee47 opened #2538
• Aug 03 16:04
slaff closed #2536
• Jul 30 15:51
slaff closed #2537
• Jul 30 15:51
slaff milestoned #2537
• Jul 30 06:44
mikee47 opened #2537
• Jul 29 23:33
dependabot[bot] labeled #2536
Mike
@mikee47
That particular library doesn't require patches at its current version. I've just updated it to latest and it's missing Adafruit_I2CDevice so would require some work to get it there. I guess the question ATM is whether the later versions have bugfixes or features you require?
Vity
@Vity01
the Ada_BME280 library requires also https://github.com/adafruit/Adafruit_Sensor and https://github.com/adafruit/Adafruit_BusIO
I just need it to make (their) examples compilable
Vity
@Vity01
there might be a side effect for other Adafruit libs in Sming
Vity
@Vity01

I found another issue with the flashing on Windows make flash

...
ESPTOOL2 out/Esp8266/debug/firmware/rom0.bin
SSL support disabled
make[1]: Nothing to be done for application'.
make[1]: Leaving directory /c/tools/Sming/samples/Basic_Blink'
Killing Terminal to free COM5
/bin/sh: : command not found
make: [kill_term] Error 127 (ignored)
WriteFlash 0x00000=out/Esp8266/debug/firmware/rboot.bin 0x000fa000=out/Esp8266/debug/firmware/partitions.bin 0x00002000=out/Esp8266/debug/firmware/rom0.bin  0x000fc000=/C/tools/Sming/Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK/bin/esp_init_data_default.bin
Traceback (most recent call last):
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 114, in <module>
main()
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 106, in main
output = globals()['handle_' + args.command](args, config, part)
File "c:\tools\Sming\Sming\Components\Storage\Tools\hwconfig\hwconfig.py", line 52, in handle_flashcheck
filesize = os.path.getsize(filename)
File "c:\Python310\lib\genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/C/tools/Sming/Sming/Arch/Esp8266/Components/esp8266/ESP8266_NONOS_SDK/bin/esp_init_data_default.bin'
make: *** [flash] Error 1

The file c:\tools\Sming\Sming\Arch\Esp8266\Components\esp8266\ESP8266_NONOS_SDK\bin\esp_init_data_default.bin is there, but it looks like it's used somewhere where the path is not inflated into Windows path

Mike
@mikee47
I've started a PR #2407 which updates the library. Also, only requires #include <Adafruit_BME280_Library>. Perhaps you could test it?
Re. problem with flashing, the 'file not found' relates to '/C/tools/...' but previous info. indicates path should be '/c/tools/...'. Windows doesn't care but Make does. I suspect this is related to #2000. Try a make config-clean clean components-clean then rebuild.
Mike
@mikee47
Ignore that last comment. The problem is in Components/Storage/Tools/hwconfig/hwconfig.py line 52, requires filesize = os.path.getsize(fixpath(filename)). NB. I develop on Windows but haven't encountered this problem - I switched to WSL2 as it's considerably faster. I'll get a fix submitted shortly once I've checked it.
Vity
@Vity01
@mikee47 thanks for the PR, I will try it , it looks like I am not unable to build up I2C and I hope the newer library contains some fix
Yeah, meanwhile I disabled the filesize safety check - it will work for you in WSL2 because /c/ path works there
Mike
@mikee47
@Vity01 I've identified the likely problem with the new BME280 library, changes pushed to update/adafruit-bme280 branch. You'll need a git pull. Also updated adafruit libraries so will requiremake submodules-clean before building.
1 reply
vesley
@vesley
Hello @slaff, FileStream worked, but I have two problems with the file upload.
1. When I initialize the FileStream in the fileUploadMapper, I don't have the file name. I put a static name for testing, but I want to store the file with the name provided by the multipart/form-data request.
2. Before persisting the file I want to check if there is enough storage space on the SPIFFS file system and if the file name is not bigger than 32 characters (as SPIFFS doesn't allow filenames with more than 32 characters). If this conditions are not met I want not to store the file.
Is there a way to achieve what I want with Sming?
16 replies
Vity
@Vity01
hurray 97% for v4.5.0 :-)
slaff
@slaff

gpio: gpio_set_level(215): GPIO output gpio_num error

Should be fixed in the latest develop

slaff
@slaff
@/all We are planning a new release for 25th of December. Please test the code in the latest develop branch and let us know if you have noticed some issues.
vesley
@vesley
Hello @mikee47 & @slaff, is it possible to add a new method signature for HttpResourceTree::setDefault, which allows to register a default path and a plugin or a list of plugins? I want to secure all registered paths with basic authentication. Currently there is no way to secure the default path.
vesley
@vesley

Hello @mikee47 & @slaff, is it possible to add a new method signature for HttpResourceTree::setDefault, which allows to register a default path and a plugin or a list of plugins? I want to secure all registered paths with basic authentication. Currently there is no way to secure the default path.

I found out that I can use

server.path.set("*", handler, plugin)

to set a handler for the default path with a plugin.

slaff
@slaff
@/all Merry Christmas everyone - we have a present for you: https://github.com/SmingHub/Sming/releases/tag/4.5.0
Mike
@mikee47
@slaff Awesome teamwork and Merry Christmas to all !
kmihaylov
@kmihaylov

Hello. I'm trying to use multiple SPI buses (one for SD card and another one for some ICs). The global SPI object works fine (I setup it on SpiBus::HSPI). But I struggle to set secondary SPI object utilizing VSPI. I declare it with SpiClass spi2 and later try to spi2.setup(SpiBus::SPI3, SDpins);.

The application builds fine, but on startup I get 392117 [SPI] Bus #3 already assigned

These are the exact init lines for SPI:

    SPI.setup(SpiBus::HSPI, spispi);
SPI.begin();

spi2.setup(SpiBus::SPI3, SDpins);
spi2.begin();
Mike
@mikee47
I've just tested this and no issue. Can you post the complete code please? Open an issue if necessary.
kmihaylov
@kmihaylov
Thank you @mikee47 Let me check precisely and I'll post my results.
kmihaylov
@kmihaylov

@mikee47 , you're correct, as usual. I'm using the SDCard library. I did spi2.begin() before runTest(); that triggers SDCard_begin(PIN_CARD_SS, SPI_FREQ_LIMIT). This was the reason for the 'already assigned' bus.

It is possible that SDCard_begin() somehow overwrites stuff for the global SPI object? I'm loosing communication with the ICs on SPI's bus after runTest();.

I write the app with both SPI and spi2 buses and the first time after flashing both the SD card (on spi2) and the ICs on SPI's bus work OK. On the second restart of the board, however, the devices on the SPI bus do not work. I tried also flashinit and it still has this strange behavior.

kmihaylov
@kmihaylov
@mikee47 Well, my board is running now. I don't know how the above mentioned issue actually happens. What I found is that SPI and GPIO pins configuration might be tricky. Namely, if I set some GPIO pins (input/output) after SPI.setup(), then SPI might brake. I changed the order of some GPIO initialization functions and now the board is alive. I might have missed something and later I may try to reproduce this. Also I prepared pretty basic code to test (with MISO<->MOSI pins shorted) 2 SPI instances. https://pastebin.com/3w43sgPT (till 07.03.2023)
Anyway, thank you @mikee47 for your work on Sming and for your time providing support! Also thank you @slaff for managing and supporting the project!
slaff
@slaff
@/all we will release at the end of the month Sming v4.6. Help us find bugs by testing the latest develop version on your devices and report any issues. You can read more about the new features from here: #2509
vesley
@vesley

Hello @slaff, hello @mikee47, I'm playing with the Basic_Ota sample. I can successfully flash rom0 and rom1. But the spiff partition is only flashed when rom0 is written. When rom1 is written, then I see following message in the console:

Updating...
52062981 Partition 'spiffs1' not found

As there is only one spiffs partition, it is always 'spiffs0'. There is no 'spiffs1'. How can I determine the spiffs partition when rom1 is written?

The spiff partition is determined in the example with following lines:

    auto spiffsPart = findSpiffsPartition(part);
if(spiffsPart) {
// use user supplied values (defaults for 4mb flash in hardware config)
otaUpdater->addItem(SPIFFS_URL, spiffsPart, new Storage::PartitionStream(spiffsPart));
}

When part=rom1 then no spiff partition is found and therefore the update is skipped.

13 replies
Mateusz Zakarczemny
@Matzz

Hi guys,
I'm trying to write simple program which will write something to file and then read from it. My attempt compiles but I see unexpected (empty file output). Could I kindly as for some guide?

Storage::Partition dataPart;
String name = F("spiffs0");
dataPart = Storage::findPartition(name);
if(!dataPart) {
debug_w("Partition '%s' not found", name.c_str());
}
spiffs_mount(dataPart);

data.open(F("data.csv"), File::Append | File::ReadWrite);
uint64_t time = RTC.getRtcNanoseconds();
String startString = "=== Start time: ";
startString.concat(time);
startString.concat("\n");
data.write(startString);
data.flush();
Serial.println("Current data:");
String c = data.getContent();
Serial.println(c);
Serial.println("==== Data end");

The output is:

60056 mount() returned 0 (Success)
60673 File system initialised
Current data:

==== Data end

Why I cannot see what I wrote to this file?

Mike
@mikee47
Try adding data.seek(0, SeekOrigin::Start) before the call to getContent..
1 reply
Mike
@mikee47
Issue is because of global File object, which takes a reference to the global filesystem pointer in its constructor. However, this hasn't yet been created. I've created a PR to fix this...
I hadn't considered using long-term file handles. If you're only accessing the file once every 5 seconds I would recommend using a temporary File object instead.
Mateusz Zakarczemny
@Matzz
@mikee47 Fixed, now it works fine. Thanks!
BTW is that normal that I cannot use
System.deepSleep when nework is disabled DISABLE_NETWORK := 0?
/opt/esp-quick-toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld: /opt/sming/Sming/out/Esp8266/debug/lib/clib-Sming-f4fec80f9836e7cd9a2801547ac6ca01.a(System.o): in function _ZN11SystemClass10initializeEv':
/opt/sming/Sming/Platform/System.cpp:69: undefined reference to system_deep_sleep_set_option'
/opt/esp-quick-toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld: /opt/sming/Sming/Platform/System.cpp:75: undefined reference to system_deep_sleep'
/opt/esp-quick-toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld: /opt/sming/Sming/out/Esp8266/debug/lib/clib-Sming-f4fec80f9836e7cd9a2801547ac6ca01.a(System.o): in function _ZN11SystemClass9deepSleepEj16DeepSleepOptions':
/opt/sming/Sming/Platform/System.cpp:134: undefined reference to system_deep_sleep_set_option'
/opt/esp-quick-toolchain/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/10.2.0/../../../../xtensa-lx106-elf/bin/ld: /opt/sming/Sming/Platform/System.cpp:138: undefined reference to system_deep_sleep'
collect2: error: ld returned 1 exit status
Mike
@mikee47
Sleep hasn't been implemented with No-WiFi. See SmingHub/Sming#2004 for some background.
(It would be a lot easier if Espressif released the SDK source code!)
Mateusz Zakarczemny
@Matzz

@mikee47 Thanks for update. I tried to implement that with wifi enabled but also failed.
When I use System.deepSleep(1*1000); in init method I get:

r123568 mount() returned 0 (Success)
123938 File system initialised
124004 spif5fs mounted
Current data:
=== Start time: 180289815482625

==== Data end

Startup end,
mode : null
enter deep sleep��sll��|�d�|�d�
c|����s�cd�b��oo�log���
cx��drlrl�{��o�c�gcp�

On console and program hangs.
If I try to use deepSleep in timer method the result is quite similar

==== Data end

Printing sensors data end.
enter deep sleep��

and nothing later.
(repo https://github.com/Matzz/Tempreader)

I didn't found any examples for using that method with Sming. Maybe I need to preconfigure something?

slaff
@slaff
@mikee47 I hope your solar installation is going forward. Do you think you will have time to share also your faster button library? See SmingHub/Sming#2250
Mike
@mikee47
@Matzz In SDK description for system_deep_sleep says "Hardware has to support deep-sleep wake up (XPD_DCDC connects to
EXT_RSTB with a 0-Ωresistor)". Connecting a jumper between RST and GPIO 16 has the desired effect. Probably also worth adding a pinMode(16, WAKEUP_PULLUP); in init().
1 reply
Mike
@mikee47
@Matzz Latest develop has a fix so that global/static File objects work as expected.
Simon Brazell
@SimonBrazell
Hello, I'm attempting to build an ultrasonic tank level sensor using the JSN-SR04T and an ESP8266, I decided to use Sming as it had all the networking features I desired (Wifi, MQTT) but I'm unable to get even the most basic example of distance measurements working as it should. All measurements the device takes are consistently low (about 20cm lower than they should be). This same or similar code works on an Arduino build perfectly. Any ideas what the issue could be? Here is the latest iteration of my code using the included Ultrasonic package:
#include <SmingCore.h>
#include <Libraries/Ultrasonic/Ultrasonic.h>

#define TRIG_PIN 2
#define ECHO_PIN 5
#define SAMPLES 10

Timer procTimer;
Ultrasonic ultrasonic = Ultrasonic();

void measure()
{
uint32_t distance = 0;
for (int i = 0; i < SAMPLES; i++)
{
uint32_t dist = ultrasonic.rangeCM();
Serial.print(dist);
Serial.println(" cm");
distance += dist;
delayMilliseconds(60);
}
distance /= SAMPLES;
Serial.print("Average: ");
Serial.print(distance);
Serial.println(" cm");
}

void init()
{
Serial.begin(SERIAL_BAUD_RATE);
ultrasonic.begin(TRIG_PIN, ECHO_PIN);
delayMilliseconds(60);
measure();
procTimer.initializeMs(10000, measure).start();
}
Or rather they seem to be around 30% lower than they should be.
Same problem occurs if I build and upload the Ultrasonic_HCSR04 example from the provided samples.
Mike
@mikee47