Welcome to the MVP3000 ESP32/ESP8266 repository, an integral part of the MVP3000 rapid prototyping framework.
- Contents
- Introduction
- Getting Started
- Modules
- Implementation
- Application Note CO2-Lights (CO2-Ampel)
- Troubleshooting
- Contribute
- License
The MVP3000 framework is built to streamline the implementation of sensor and actuator hardware. It facilitates a seamless transitions between all development stages and thus speeds up the implementation cycle. It allows the rapid development of a MVP (minimum viable product) for demonstration purposes. It allows the rapid deployment in fabrication for the purpose of deskilling and improving process reliability. Designed around low-cost hardware and open-source software, its modular structure promotes fast, flexible, and agile hardware development.
A key feature of the framework is the seamless transition between the different development stages. Starting with the initial proof-of-concept script on the engineers laptop with a serial connection to perform first data analysis, moving to a laptop-independent data collection via wireless network allowing longer-term studies, towards a control device using a handheld Raspberry Pi with touchscreen.
- Get the hardware running in a basic proof-of-concept script.
- Include the MVP3000 framework in your code and feed it with the sensor data.
- Use the web interface for main settings regarding data handling.
- Receive data and send commands, all at the same time:
4.1. During development via the serial console.
4.2. Gain independence from wiring using WebSocket.
4.3. Remote data recording using an MQTT broker. - Use WebSocket or MQTT on an RaspberryPi to become laptop-independent and build an MVP
The MVP3000 framework is available via the Arduino Library Manager. Search for 'MVP3000' and install the latest version.
To manually install it please clone or download this repository and follow the instructions for either manual installation, using the Arduino IDE, or in PlatformIO.
A good starting point is the basic example. It does not include any module, and thus is not very useful beyond testing.
Compile a copy of the sketch and listen to the serial port using your IDE (baud rate: 115200). The serial output will look like this, with a time stamp, the log category, and the actual message:
0d 00:00:00 [I] Logger initialized.
0d 00:00:00 [I] Led timing changed to: 0 ms
0d 00:00:00 [W] File not found for reading: /cfgNet.json
0d 00:00:00 [I] AP started: device13061407, 192.168.4.1
0d 00:00:00 [W] File not found for reading: /cfgNetCom.json
0d 00:00:00 [W] File not found for reading: /cfgNetMqtt.json
0d 00:00:00 [I] Led timing changed to: 2000 ms
0d 00:00:02 [U] This text will be printed in purple to Serial and the log-websocket.
...
The ESP opens an access point. Connect to it with your computer and open its IP with your web browser to access the web interface.
Use the WebSocket log example to view the log output in a browser.
As a next step proceed with using one of the modules.
The LED indicates the device status:
- On - Connected as client to WiFi network.
- Slow blinking - Opened an access point without password to connect to for setup.
- Blinking - Connecting to WiFi network using the given credentials.
- Fast blinking - Fatal error, MVP3000 not operational. This should never happen!
The main page lists basic system information and settings and links to all loaded modules. It also lists
- Enter the network credentials of your local network in order to connect the ESP.
- Connect tries on boot before credentials are deemed wrong and an aceess point is opened. If the network connection was lost, the ESP will try to reconnect forever until restart.
- Force client mode on boot forever and do not fall back to opening an aceess point.
WARNING: If the credentials are wrong, the device will become inaccessible via the network! It can only be reset by re-flashing it!
WebSockets are provided mainly for the modules. An example for log output is available.
MQTT is provided for the modules and not used by the framework itself.
For more information on MQTT and developer resources also visit Eclipse Paho.
- Connection status.
- The external broker overrides any discoverd local broker.
- MQTT port.
- List of active (_data) and subscribed (_ctrl) topics.
UDP Auto Discovery allows to easily search the local network for other devices and servers, for example a MQTT server. There is no need to know device or server IPs in advance. Example Python scripts for the server and for discovery are available.
One can also listen to UDP communication with netcat:
nc -ukl [port]
- Discovered server, other ESP devices are not printed
- Port to use for discovery. This needs to be in accordance with the server-side pendant.
Typical use cases are available as modules to be loaded into the framework. First steps, examples, and options are given in the documentation of the respective module.
- Sensor Module: The sensor module receives sensor data from the user script and processes it. It handles averaging, offset, scaling, and tare. Main settings are available via web interface. It publishes the live data to the serial console, to WebSocket, and via MQTT. The latter two additionally allow to 'zero' the measurement by the end-user. Stored data can be downloaded as CSV.
- LED Module (work in progress)
- Manipulator Module (planned)
A bare-bone implementation of the framework looks as follows. However, without a module its usefulness is limited.
#include <MVP3000.h>
extern MVP3000 mvp;
// Xmodule code
// User code
void setup() {
// Xmodule code
mvp.setup();
// User code, mvp logging functionality is available
}
void loop() {
// User code
// Xmodule code
mvp.loop();
}
On ESP it is important to not use the blocking delay or while anywhere in the loop. This will impair the performance of the ESP, particularly the responsiveness of the network. As such it may significantly degrade the performance of the web interface and the output via WebSockets and MQTT.
Alternatives are to use the built-in LimitTimer or a custom method to wait using a timestamp variable.
The serial output is color-coded using ANSI escape sequences. If your serial monitor does not support this feature (Arduino IDE) it can be turned off to omit the symbols.
mvp.logDisableAnsiColor();
The logger can be used to send message to serial and the websocket.
mvp.log("This text will be timestamped and logged to serial, to websocket, and to the web interface.");
mvp.logFormatted("This is a number: %d", 123);
void addXmodule(_Xmodule *xmodule)
: Add a Xmodule to the MVP3000 system.void log(const String& message)
: Log a message at 'user' level.void logFormatted(const String& message, ...)
: Log a formatted message at 'user' level.void logDisableAnsiColor()
: Disable ANSI codes in serial output.void logSetLevel(CfgLogger::Level level)
: Change the logging level. The log level 'data' is only printed to serial and is omitted for the web page and WebSocket target.void logSetTarget(CfgLogger::OutputTarget target, boolean enable)
: Enable/disable the output targets of logging message. Console and web interface are enabled by default, WebSocket is disabled.void mqttHardDisable()
: Completely disable MQTT communication.void udpHardDisable()
: Completely disable the UDP discovery service in case it interferes with custom UDP code.void wsHardDisable()
: Completely disable WebSockets.void setAlternateRoot(AwsResponseFiller alternateResponseFiller, AwsTemplateProcessor alternateTemplateProcessor = nullptr, const String& mvpUri = "/mvp3000")
: Set an alternate page as web root and move the main MVP3000 page to a sub-page.
Please see also the available Helper Functions and Classes.
Most users will not need to create a custom module, particularly if a similar one already exists. We are happy to help implementing a missing feature.
In order to develop and integrate a new module into the MVP 3000 framework please follow the documentation to Custom Modules.
The CO2-Lights serves as a showcase application that highlights the versatility of the MVP3000 framework. This implementation uses the sensor module and the LED module. It features a custom landing page accessible via any smartphone or browser. The page provides real-time ambient CO2 concentration data alongside a historical graph, which updates automatically through WebSocket.
Q: I have problems accessing the web interface A: Are you on the same WiFi network as the device? Do you have the correct IP, it is displayed in the serial log during startup.
Q: The web interface sometimes takes forever to respond. A: Please check if there is any blocking delay or while in the loop. This significantly impairs user experience of all network related features on any ESP. Also check the libraries you use, particularly the sensor libraries often wait for the sensor to become ready.
Q: Some settings in my custom code are ignored?
A: The value set during compile time is overwritten by stored values (if stored) during initialization. Possibly factory reset the device.
We are looking forward to your input on this project, be it bug reports, feature requests, or a successful implementation that does something cool. In the latter case we will gladly link you.
Please follow the GitHub guide on how to contribute code to this project.
Licensed under the Apache License. See LICENSE for more information.
Copyright Production 3000