The repository contains Arduino/ESP32 code for the Sensaurus project. These sketches/libraries are used for the hub board and sensaur/actuator devices that plug into the hub board.
The device boards connect to the hub using audio cables that carry power and serial data. The communication between the hub and the devices uses a single serial line for both transmitting and receiving (i.e. half-duplex serial).
The owner ID corresponds to the person or organization who owns or manages a device. It is assigned by the server.
The hub ID is assigned using the hub configuration utility. (For ESP32 hubs, we expect to do configuration over BLE.)
The device ID is a 32-bit integer (displayed in hexidecimal) that is self-assigned by each device (sensor/actuator board). The device ID is stored on the device and preserved when it is moved from one hub to another. Device IDs are randomly generated, so they may not be globally unique, though it should be reasonable to assume they are unique within a single owner.
Each device can have multiple components (e.g. temperature and humidity). Components are identified by the device ID, followed by a dash, followed by the first five letters of component type. (It is up to the device designer to make sure the first five letters of the component types are not repeated on a single device.)
The hub can communicate with an MQTT server. We use the following topics:
[owner_id]/hub/[hub_id]/status(JSON dictionary with wifi, firmware, etc. info from hub)
[owner_id]/hub/[hub_id]/config(JSON dictionary with polling rate, firmware updates, etc.)
[owner_id]/hub/[hub_id]/devices(JSON dictionary of device info by device_id)
[owner_id]/hub/[hub_id]/sensors(JSON dictionary with sensor values (from hub) by component_id)
[owner_id]/hub/[hub_id]/actuators(JSON dictionary with actuator values (for hub) by component_id)
[owner_id]/device/[device_id](string value of current hub_id for this device)
Installing ESP32 software
- Install Arduino IDE
- Go to Arduino IDE preferences; set
Additional Board Manager URLsto
- Go to
Board Manager..., search for
esp32, select result and click
Compiling the code
- Go to Arduino IDE preferences and set the
Sketchbook locationto the
sensaurusfolder. This allows the IDE to find the required libraries.
- (Restart Arduino IDE?)
- Press Ctrl-R (or Command-R) to compile. It may take a little while given the various library dependencies.
Uploading to ESP32
- Plug in the ESP32 board
DOIT ESP32 DEVKIT V1from board list (or other board type if needed)
- Select serial port
- Press Ctrl-U (or Command-U) to upload.
- After IDE shows
BOOTbutton on ESP32 for several seconds (until upload starts).
Running the hub simulator
The simulator is in the
- Use pip to install
- Use the AWS IoT web interface to create a new "thing." Get the certificates and host name from the web interface.
- Create a sub-folder called
hub-simcontaining the key and certificates for this hub.
config.hjsonand edit the host, certificate paths, etc. as needed. (You can leave the
hub_idas is for now.)