WebThings Arduino examples

First of all, THANK YOU!
I already started to code myself until I found WebThings. Exactly what I was looking for.

The server works fine, now I want to use an Arduino Uno to send some values to the WebThings Server.
Unfortunately I can’t even compile the examples. I started a thread in the Arduino forum.

Now I tried the example from the README, but that throws an error itself:
text section exceeds available space in boardSketch uses 59218 bytes (183%) of program storage space. Maximum is 32256 bytes.

Any hints what I might be missing here?

Seems like you may need to use a board with more flash available.

Correct, using an Arduino Mega helped for the sample code from the README.
But the example from the framework page still throws an error:

AppData\Local\Temp\cc84jTpu.ltrans1.ltrans.o: In function `global constructors keyed to 65535_0_WebthingsTes.ino.cpp.o.6193':

<artificial>:(.text.startup+0x2e8): undefined reference to `action_generator(ArduinoJson6152_1000010::BasicJsonDocument<ArduinoJson6152_1000010::DefaultAllocator>*)'

<artificial>:(.text.startup+0x2ea): undefined reference to `action_generator(ArduinoJson6152_1000010::BasicJsonDocument<ArduinoJson6152_1000010::DefaultAllocator>*)'

collect2.exe: error: ld returned 1 exit status

Thank you

Apologies, the website was missing a couple functions from the actual example.

void do_fade(const JsonVariant &input) {
  JsonObject inputObj = input.as<JsonObject>();
  long long int duration = inputObj["duration"];
  long long int brightness = inputObj["brightness"];


  ThingDataValue value = {.integer = brightness};
  int level = map(brightness, 0, 100, 255, 0);
  analogWrite(lampPin, level);

  ThingDataValue val;
  val.number = 102;
  ThingEventObject *ev = new ThingEventObject("overheated", NUMBER, val);

ThingActionObject *action_generator(DynamicJsonDocument *input) {
  return new ThingActionObject("fade", input, do_fade, nullptr);
1 Like