Skip to content

Instantly share code, notes, and snippets.

@ndfred
Last active September 13, 2020 07:29
Show Gist options
  • Save ndfred/3d146ddb5c64e12753167f2836fa7ddf to your computer and use it in GitHub Desktop.
Save ndfred/3d146ddb5c64e12753167f2836fa7ddf to your computer and use it in GitHub Desktop.
Wemos LOLIN D32 Pro + SHT30 macOS Setup

To get USB access:

  • install the USB serial driver, check that you see a /dev/cu.wchusbserial1410 device when plugging in the board over USB

To deploy MicroPython on the board:

  • get the MicroPython firmware (get the SPIRAM variant to get access to the 4MB of RAM)
  • install esptool by running sudo pip install esptool
  • clear the flash by running esptool.py --chip esp32 --port /dev/cu.usbserial-1410 erase_flash
  • flash MicroPython by running esptool.py --chip esp32 --port /dev/cu.usbserial-1410 --baud 460800 write_flash -z 0x1000 esp32spiram-idf3-20190125-v1.10.bin
  • access MicroPython by running screen /dev/cu.usbserial-1410 115200
  • exit screen through CTRL + a then k

To setup a WiFi connection from the MicroPython prompt:

import network
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.config(dhcp_hostname="Sensor")
wifi.connect("WIFI_NETWORK", "WIFI_PASSWORD")

To read the temperature from the SHT30 sensor board from the MicroPython prompt:

import machine
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
address = i2c.scan()[0]
i2c.writeto(address, b'\x2C\x10')
data = i2c.readfrom(address, 6)
temperature = (((data[0] << 8 |  data[1]) * 175) / 0xFFFF) - 45
humidity = (((data[3] << 8 | data[4]) * 100.0) / 0xFFFF)
print("%.1f degrees, %.1f%% humidity" % (temperature, humidity))

See the reference SHT30 code for more info.

To deploy Arduino on the board:

  • download the Arduino IDE
  • right click on the app and select Open to bypass the app codesigning issues
  • after Arduino starts, open the Preferences window
  • in the Additional Board Manager URLs box, enter: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  • go to the Tools > Board > Board Manager menu, search for ESP32 and install that package
  • select LOLIN D32 PRO as your board and /dev/cu.usbserial-1410 as your serial port
  • click the arrow button to deploy your code to the board

To install esp-idf and use their serial logger:

  • run git clone --recursive https://github.com/espressif/esp-idf.git
  • install esp-idf through cd esp-idf ; ./install.sh
  • set the right environment variables through . ./export.sh
  • now you can run idf.py monitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment