this is the full flow from zero to working messages in aws iot core.
- an aws account with access to iot core
- 1 esp32 board
- usb data cable
- wifi network (2.4ghz is usually easiest for esp32)
- any bluetooth device nearby (phone/watch/tag)
- node.js 20+ installed
- mosquitto installed locally
option a (winget):
winget install EclipseMosquitto.Mosquittooption b (manual):
- download installer from
https://mosquitto.org/download/ - install to
c:\mosquitto - make sure
c:\mosquittois in yourpath
check install:
mosquitto -h
mosquitto_passwd -h- open aws console
- go to
iot core - go to
manage -> all devices -> things - click
create thing - choose
create single thing - name it something like
esp32-espresense-bridge - choose
auto-generate a new certificate - download these files and keep them safe:
- device certificate (
*.pem.crt) - private key (
*-private.pem.key) - public key (
*-public.pem.key) - amazon root ca 1 (
AmazonRootCA1.pem)
- device certificate (
- create a policy (demo policy):
- action:
iot:Connect - action:
iot:Publish - action:
iot:Subscribe - action:
iot:Receive - resource:
* - this wildcard is okay for a quick test, but tighten it before production
- action:
- attach that policy to the certificate
- copy your aws endpoint:
iot core -> settings -> device data endpoint- it usually looks like
xxxxxxxxxxxx-ats.iot.us-east-1.amazonaws.com
from repo root:
npm install
copy-item config/.env.example .envopen .env and fill all values:
LOCAL_MQTT_HOST: your pc local ip (not localhost)LOCAL_MQTT_PORT: usually1883LOCAL_MQTT_USERNAME+LOCAL_MQTT_PASSWORD: your local broker loginAWS_IOT_ENDPOINT: from aws iot settingsAWS_ROOT_CA_PATH: full path toAmazonRootCA1.pemAWS_CERT_PATH: full path to cert fileAWS_PRIVATE_KEY_PATH: full path to private key fileMOSQUITTO_PASSWORD_FILE_PATH: where you want local password fileMOSQUITTO_OUTPUT_CONF_PATH: where generated bridge config goes
tip: use forward slashes in windows paths to keep it simple.
example command:
mosquitto_passwd -c C:/mosquitto/config/passwords.txt usernameenter password when prompted.
then set the same values in .env:
LOCAL_MQTT_USERNAME=usernameLOCAL_MQTT_PASSWORD=<the password you entered>
npm run check
npm run build:mosquittothis creates the bridge config file at MOSQUITTO_OUTPUT_CONF_PATH.
mosquitto -c C:/mosquitto/config/bridge-espresense.conf -vif your output path is different, use that path instead.
leave this terminal running.
- plug esp32 into your pc
- open
https://espresense.com/firmware - click connect, pick your esp32 serial device
- install firmware (erase + install)
- set wifi ssid/password
- open the device web page after it boots
- mqtt settings:
- server: your pc local ip (
LOCAL_MQTT_HOST) - port:
1883 - username:
LOCAL_MQTT_USERNAME - password:
LOCAL_MQTT_PASSWORD
- server: your pc local ip (
- room name: whatever you want (
office,lab, etc) - save and restart
open terminal a:
npm run watch:localyou should start seeing espresense messages on espresense/devices/#.
optional test without hardware:
npm run send:sampleopen aws console -> iot core -> mqtt test client:
- subscribe to
espresense/devices/# - you should see messages forwarded by the bridge
if not working, check troubleshooting.
get your local ip:
ipconfigfind ipv4 address for your active adapter.
test if port 1883 is open locally:
test-netconnection -computername 127.0.0.1 -port 1883