Simple example built for esp-rust-board that sends temperature and humidity to MongoDB, using POST method.
To reproduce the example
- Setup MongoDB:
- Create an application
- Create a database
- Create a collection
- Rename
cfg.toml.example
tocfg.toml
- Fill the
cfg.toml
with:wifi_ssid
: Wifi SSIDwifi_pass
: Wifi passwordapi_key
: MongoDB API Keydata_source
: MongoDB Data Sourcedatabase
: MongoDB Database namecollection
: MongoDB Collection nameapp_id
: MongoDB App ID
To publish data into your collection using curl
:
curl https://data.mongodb-api.com/app/<app_id>/endpoint/data/v1/action/insertOne \
-H 'Content-Type: application/json' \
-H 'api-key: <api_key>' \
--data-raw \
'{
"dataSource": "<data_source>",
"database" : "<data_base>",
"collection" : "<collection>",
"document" : { "name": "Harvest",
"breed": "Labrador",
"age": 5 }
}'
For more information, see MongoDB documentation
This repository offers Dev Containers supports for:
Note
In order to use GitHub Codespaces the project needs to be published in a GitHub repository and the user needs to be part of the Codespaces beta or have the project under an organization.
If using VS Code or GitHub Codespaces, you can pull the image instead of building it
from the Dockerfile by selecting the image
property instead of build
in
.devcontainer/devcontainer.json
. Further customization of the Dev Container can
be achived, see .devcontainer.json reference.
When using Dev Containers, some tooling to facilitate building, flashing and simulating in Wokwi is also added.
-
Terminal approach:
scripts/build.sh [debug | release]
If no argument is passed,
release
will be used as default -
UI approach:
The default build task is already set to build the project, and it can be used in VS Code and GitHub Codespaces:
- From the Command Palette (
Ctrl-Shift-P
orCmd-Shift-P
) run theTasks: Run Build Task
command. Terminal
->Run Build Task
in the menu.- With
Ctrl-Shift-B
orCmd-Shift-B
. - From the Command Palette (
Ctrl-Shift-P
orCmd-Shift-P
) run theTasks: Run Task
command and selectBuild
. - From UI: Press
Build
on the left side of the Status Bar.
- From the Command Palette (
Note
When using GitHub Codespaces, we need to make the ports public, see instructions.
-
Terminal approach:
-
Using
flash.sh
script:scripts/flash.sh [debug | release]
If no argument is passed,
release
will be used as default
-
-
UI approach:
- From the Command Palette (
Ctrl-Shift-P
orCmd-Shift-P
) run theTasks: Run Task
command and selectBuild & Flash
. - From UI: Press
Build & Flash
on the left side of the Status Bar.
- From the Command Palette (
-
Any alternative flashing method from host machine.
The Dev Container includes the Wokwi Vs Code installed, hence you can simulate your built projects doing the following:
- Press
F1
- Run
Wokwi: Start Simulator
Note
We assume that the project is built in
debug
mode, if you want to simulate projects in release, please update theelf
andfirmware
proprieties inwokwi.toml
.
For more information and details on how to use the Wokwi extension, see Getting Started and Debugging your code Chapter of the Wokwi documentation.