Building
Building with the Arduino IDE
Download and install the latest Arduino IDE
Download MppPublish.zip to find the MppLibrary source and the sketches (*.ino) files you want to use (see below)
Start the IDE and open one of the MPP .ino sketches. E.g., MppProtocol.ino contains instructions on how to build custom MPP devices. MppDevice.ino is a basic device with minimal function.
Configure the board:
File > Preferences, look for "Additional Boards Manager URL".
For the ESP8266 use:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
For the ESP32 (coming soon) use:
https://dl.espressif.com/dl/package_esp32_index.jsonUnder Tools > Board > Board Manager (at the top of the list) install the esp8266 by ESP8266 Community.
Select esp8266 2.7.4.Sketch > Include Library > Manage Libraries. For ESP8266 Select:
EEPROM
ESP8266WebServer
ESP8266WiFi
Sketch > Include Library > add .zip library:
Choose the MppLibrary.zip file downloaded from below.
To update the library find it in your arduino directory "libraries" folder (open preferences and look for the "Sketchbook location") and either delete it and re-install or extract the new version over it.
Configure the board settings for your board. Generally they are board specific
Use the correct board size or smaller (for compatibility). I use 1MB (FS:none OTA:~503KB) for the included bins
Exceptions: legacy
flash frequency 40MHz
Debug level none
Debug port: disabled
Debug level: none
SSL basic
lwIP Variant: "V2 Lower Memory"
Erase only sketch
Crystal 26MHz
Espressif FW nonos-sdk 2.2.1+119 (191122)
VTables: in flash
reset your choice (usually DTR)
flashmode your choice (usually DOUT)
CPU 80MHz
Use the button to compile and upload the sketch.
If the sketch uses the ADC_MODE macro you may need to remove the 'extern "C++" {} wrapper from the .ino file.Reset the board, use the serial monitor at 115200 bps
Enter "help" on the command line to verify. If the board doesn't respond, try resetting it to look for error messages. If the response is garbled try again at 76800.
Use the command "sta {ssid} {password}" (without the braces) to configure your WIFI.
Reset, use the command "wifi" to see the assigned device IP, then visit that page with a web browser to configure the device MPP properties.
For OTA updates:
Sketch > Export to export the bin file
Load the device's web page. Select the bin file, and "Upload Firmware".
Watch the progress at the bottom of the page, and the OTA confirmation.
The device will restart with the new firmware, use "back" to refresh the page.
Building with Eclipse
I'm using the Sloeber plugin with the C/C++ CDT plugin as the Arduino CDT plugin is broken for the ESP8266 at the time of writing.
Install C/C++ CDT and the Sloeber plugin from the eclipse marketplace.
Under the "Arduino" menu choose preferences.
Third party URLs:
http://downloads.arduino.cc/packages/package_index.json
https://raw.githubusercontent.com/jantje/hardware/master/package_jantje_index.json
https://raw.githubusercontent.com/jantje/ArduinoLibraries/master/library_jantje_index.json
http://arduino.esp8266.com/stable/package_esp8266com_index.json
http://downloads.arduino.cc/libraries/library_index.jsonPlatforms and boards: esp8266 (same version as above)
Library Manager: ArduinoJson, ESP8266Wifi, ESP8266WebServer, EEPROM as above.
You'll probably want to disable the automatic missing library handling as it often pulls in more than you need - Window/Preferences/Arudino, look for install & import.
Create a project for each sketch you will build (Arduino>Create new sketch)
Download and add a sketch to the project. MppProtocol.ino is an example of how to build custom MPP devices, MppDevice, MppRelay, MppRelays examples for simple devices. Special instructions for use are included in the header comment of the .ino files.
Download and extract MppPublish.zip to get all of the source files. At a minimum you need MppLibrary.zip from there.
Add the extracted MppLibrary folder (Arduino>add source folder to selected project) to your sketch as a source folder (should show as a dynamic link which makes it easy to update). This should also pull in the necessary libraries (same as in the Arduino DE above).
Sometimes Sloeber adds the base WiFi in which drags along SPI. If this happens remove the MppLibrary, fix the libraries back to the proper set, then re-add MppLibrary
In the project properties for Arduino pick the correct board and port. Typically "Erase Flash" as "Only Sketch" is sufficient. To recover from a bad MPP properties file use "All Flash Contents". See other valuesin arduino builds above.
Build and upload the project. Note compile errors marked in the libraries can be ignored. Build errors cannot be ignored.
Add a serial monitor at 115200bps, examine and configure wifi, etc.
Notes and Instructions
Use the device's on board web server to update to the latest firmware (bin) files.
It's best not to change the included MppLibrary files. If you need changes let me know - this prevents your changes being impacted by version updates.
Device properties are mostly the same as the LUA versions. Devices will be discovered and will work with AutomationManager. The device web page or AutomationManager can be used to manage the device properties.
NOTE that pin numbers are different than the LUA version. In Arduino, GPIO0 is on pin 0, GPIO1 is on pin 1, etc. See Pin Outs.