-
Notifications
You must be signed in to change notification settings - Fork 3
110. Dev environnement and debug
WARNING: I've (slowly) started to migrate my Arduino/Esp projects to platformio, which makes most of this page obsolete.
I'll update it at some point.
Download it from https://www.arduino.cc/en/Main/software
There is also a web editor version, but I have not tried it yet.
Set up the folder you want to use to store your projects: clik on File, then Preferences and pick up your folder in the "Sketchbook location" field.
The "libraries" subdirectory will be created there.
Click on File, then Preferences. In the bottom field "Additional boards manager url", enter: http://arduino.esp8266.com/stable/package_esp8266com_index.json Then click OK to close the preferences dialog.
Click on Tools, then Board then Boards Manager. In the dialog, type esp in the search field
Select "esp8266 by ESP8266 community", then click "Install". Now in Tools/Board you'll see a new section with all ESP8266 related boards.
If you use an ESP01 board (silly name, right, it's a board with an ESP8266 chip), select "Generic ESP8266". For the other boards I've tried, it worked with either "Wemos D1 mini pro" or "Wemos D1 r2 & mini" depending on the board version
You should of course clone the "iotinator" repo, and one or more agent module repo, in the folder you chose as "sketchbook location".
To create your own agent module I recommend making a copy of iotSwitch, it's a very simple module that makes understanding the framework easy.
The expected/recommended folder structure looks like:
<path/to/sketchbook> |__ iotinator |__ libraries |__ <custom agent 1> |__ <custom agent 2>
In your the sketchbook folder "libraries" subdirectory, clone these repositories (they are not availabe as packaged libs yet)
git clone git@github.com:reivaxy/XIOTModule.git
git clone git@github.com:reivaxy/XUtils.git
git clone git@github.com:reivaxy/XOLEDDisplay.git
git clone git@github.com:reivaxy/XEEPROMConfig.git
git clone git@github.com:reivaxy/XIOTConfig.git
git clone git@github.com:reivaxy/XIOTDisplay.git
Many libraries are available as github repo, or from the library manager of the Arduino IDE.
You can either clone the repo, or add the library through Sketch/Include Libraries/Manage Libraries. Some are not available in the library manager so I've included the repo reference.
You will need to add:
- ArduinoJson by Benoit Blanchon RELEASE 5.6.6
I just discovered that release 5.13, which I had on my laptop but not on my desktop computer, broke stuff silently, and I flashed a now soldered esp01 with it :-(
-
NtpClientLib by German Martin
-
TimeLib by Paul Stoffregen:
git clone git@github.com:PaulStoffregen/Time.git
-
esp8266-oled-ssd1306 by ThingPulse, Daniel Eichhorn, Fabrice Weinberg
With this you should be able to compile "iotinator". As for agent modules, each may need additional libraries depending on what features it's implementing, of course.
The very basic iotSwitch (git@github.com:reivaxy/iotSwitch.git) agent module does not require any more libs, for instance.
Memory leaks are never a good thing, but especially in programs that are supposed to run 24/7, on modules that are not supposed to reset periodically.
The iotinator master module will send to Serial a message with its heap size each time it processes a GET request on its /api/list endpoint (1), and each time it finishes pinging the connected modules (2).
The modules will do the same each time they are pinged, and they will include this data to the ping response, allowing the master to monitor their heap usage. It will also send it to Serial for each pinged module (3):
(On this screen capture, the two modules Switch and Switch_1 do not have the same heap size, because they are not running the same version of the iotSwitch software, otherwise they would but this may not be true depending on modules features.)
If your program crashes, it will likely send an undecipherable stack trace to the serial line.
Undecipherable ? Not any longer, thanks to the EspExceptionDecoder:
https://github.com/me-no-dev/EspExceptionDecoder
Install it and in many cases it will be able to tell you the line of code where the issue occurred.
Both master and module programs come with abundant messages sent to Serial, and some classes also have optional debug messages that can be activated by un-commenting a #define clause. This will cause compilation warnings, but no problem.
If you know how to hook up a debugger it may help but so far I didn't have to (and it looks damn complicated).
The obvious tool is the Postman Chrome extension (or standalone application), but there is also a great Android App that can read postman exported collections (v1 format).
I find it pretty good.
The current directory structure for the modules UI files may not be great since they are in the "iotinator" repository instead on their modules' repo, but it offers the advantage of allowing easy UI debug, without the need for cumbersome nodejs, grunt, gulp, webpack or whatever new monthly fashionable stuff. But it could be nice once this UI is a little more stable.
All you need to do is have a little web server on your dev machine (I recommend the near 0 configuration Fenix server on Windows, for instance).
On MacOS/Linux, python may be an alternative:
cd <path/to/webSite/htdocs> python -m SimpleHTTPServer 8000
Just set up an instance of this server setting the root document on the 'webSite/htdocs' directory of the repo.
Then on the init page of iotinator, set this server address and port in the last field, named "Web App Host":
This field should otherwise be initialized to the webSite on which you uploaded the "app" directory (for instance http://www.iotinator.com)
You can also load the 'debug.html' page in your browser, and then you don't need a master and a module. A fake module list is fetched from the 'list' file in the 'api' directory.