Code Monkey home page Code Monkey logo

esp32s2-bme280-webusb's Introduction

esp32s2-bme280-webusb

Sends periodic bme280 humidity, temperature, pressure and battery voltage data from esp32s2 development board to sensor dashboard backend via Wi-Fi.

Is configurable via a web interface using webusb. Since the board uses native usb communication, the serial output will also be emulated via USB so it may not work as you would expect a regular serial connection - if it's configured wrongly, there will be no output in your serial monitor. If the board sleeps, when you connect it to USB, you will not be able to flash it. Board needs to be wide awake and listening to USB commands for flashing to work. When the board is connected to the computer - the neopixel of the esp32s2 will light up and the display should display PC instead of the usual measurements.

If you botch the code and manage to put it to sleep when on USB, boot the board into bootloader mode by holding the button BUT1 on the board when connecting to USB, then you will be able to flash via USB again.

Currently, this firmware can make it around 7 months on a 1200mA battery connected to the dev board. The board can be configured to send the measurements to the server once every N times via the parameter maxRtcRecords to optimize battery time.

Built with PlatformIO.

See also backend and frontend repo, or see it live with some sensor data from my living room.

Components

Additional things needed to assemble the PCB

  • PH2.0 8 pin connectors for the display (bent needle for the PCB)
  • min 2, max 4 2.0mm high spacers to mount the display above the ESP32S2, depending on how many sides of the display you want to fixate
  • PH2.0 2pin connector for the battery (if the battery doesn't already come with one)
  • bunch of male / female headers
  • 1x push button - right angled for RESET button
  • 1x push button - regular for BOOT button

Setup

  1. Have a sensor dashboard backend running (see https://github.com/xtrinch/sensor-dashboard-nestjs-backend) or use iotfreezer.
  2. remove the solder from LED1_ENABLE SMD jumper (i.e. open it) on the ESP32S2, because it consumes a large current
  3. solder the BAT_SENS and PWR_SENS jumpers on the ESP32S2, to be able to detect battery voltage levels
  4. Uncomment the part in main.cpp that routes VREF to a GPIO on the ESP32S2. Program the board, measure VREF and input it into import_env.py under REF_VOLTAGE (if it's e.g. 1.1, input 1100). This will be needed for accurate battery measurement and you cannot skip this step.
  5. Copy import_env.example.py to import_env.py and define your sensor dashboard url.
  6. Run pio run -t buildfs && pio run -t uploadfs to upload the icons the display uses for humidity/temperature
  7. While having your board plugged into the computer, reboot the board and configure it via the web interface (via webusb) of the sensor dashboard (iotfreezer).

Troubleshooting

If you cannot upload to your board on linux, input sudo chmod a+rw /dev/ttyUSB0.

To monitor across reboots, as uploading and monitoring does not work, use the following command on Linux: while [ true ]; do cat /dev/ttyACM0; done

To check out the usb descriptors, run lsusb -v. To check out the kernel logs for errors, run dmesg.

Convert icons

convert temperature-2-48.png -background white -alpha remove -alpha off -compress none -depth 24 -resize 48x48 temp-final.bmp

Production deploy

Make sure to turn off DEBUG to save power.

PCB

See schematics-w-display folder for full project. It was drawn in KiCad and it's a two sided PCB.

Image of Yaktocat

End product with casing

Casing is parametric and drawn in FreeCad 0.19. It is made to fit the above PCB. For FreeCad project, see casing-w-display folder.

Image of Yaktocat Image of Yaktocat

TODOs

  • use ULP to use power pin as ADC wakeup source
  • reference ADC voltage to parametrizable params?

esp32s2-bme280-webusb's People

Contributors

xtrinch avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.